[Feature] Add integration by parts#212
Merged
matthew-mccall merged 21 commits intoApr 17, 2026
Merged
Conversation
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.
57a7b66 to
557fef4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.