Skip to content

[Feature] Add integration by parts#212

Merged
matthew-mccall merged 21 commits into
open-algebra:masterfrom
bguyott:feature-integration-by-parts
Apr 17, 2026
Merged

[Feature] Add integration by parts#212
matthew-mccall merged 21 commits into
open-algebra:masterfrom
bguyott:feature-integration-by-parts

Conversation

@bguyott

@bguyott bguyott commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Add an implementation of integration by parts in the Multiply class that supports logarithms, polynomials, and Euler's number. Trigonometry and inverse trigonometry are not supported as they are not yet implemented in Oasis.

bguyott added 17 commits April 17, 2026 16:42
Implemented a system to follow LIPET rules, differentiated u and integrated dv, started work on the tree that will perform the integration by parts according to the formula. No test cases yet.
The implementation of the IBP formula: integral of udv = uv - integral of vdu. The function should return the correct value of the simplified subtraction done from IBP. I had also made several corrections to my prior code. I used the object's self-reference to attain its most and least significant operands rather than making a copy to ensure it remains a subclass of Expression and not an instance of Expression, where it would lose its method overrides which is critical for IBP.

# Conflicts:
#	src/Multiply.cpp
Test cases involving Integration By Parts with Euler's Number and first/second degree variables have been completed.
Added a new test for integrating the multiplication (using IBP) between a variable raised to an real number and the natural logarithm.
Integration of an instance of the Exponent class containing an EulerNumber base raised to a degree-one Variable has been implemented.
After running test cases, the code was rewritten to rely on the Multiply instance's most and least significant operands, thereby preserving method overrides needed for integration.
The first test case on integrating xe^x passed. However, if solving an integral by parts requires applying IBP again, then the constant will become negative. This was solved by multiplying the coefficient by -1. This does not work for higher levels of recursion. A more thorough fix that relies on recursion level tracking will be included in the next commit.
Implemented a solution for the coefficient of the variable C being negative. This previously occurred when subtracting a positive C variable.
Fixed the Integration By Parts test case with a polynomial and euler's number. The tree was not previously in accordance with the way expressions are simplified. It is now fixed.
Added functionality to detect whether operands should be swapped according to the rules of LIPET in determining which expression is u and which expression is dv.

Also added a check to prevent infinite recursion.
There was a typo where dv was differentiated when it should have been integrated. This commit remedies that, along with several bug fixes such as factoring out a constant of the integrand when applying IBP.

The methodology for handling the constant C was also changed to be more reliable and consistent, removing the need for a recursion level counter.
With the modified implementation of IBP in the previous commit, test cases two and three required alteration to their trees due to how SimplifyVisitor simplifies expressions. These test cases now pass.
Removed a deprecated method before rebasing.
IBP is finished, removing the comment stating it was a work in progress.
@bguyott bguyott force-pushed the feature-integration-by-parts branch from 57a7b66 to 557fef4 Compare April 17, 2026 20:42
@bguyott bguyott added the core Related to the OASIS library itself label Apr 17, 2026
@matthew-mccall matthew-mccall self-requested a review April 17, 2026 21:30

@matthew-mccall matthew-mccall left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@matthew-mccall matthew-mccall merged commit c365484 into open-algebra:master Apr 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Related to the OASIS library itself

Projects

Development

Successfully merging this pull request may close these issues.

2 participants