Cadabra
a field-theory motivated approach to computer algebra

integrate_by_parts

Integrate by parts away from the indicated expression
Integrate by parts. This requires an expression with an object carrying a Derivative property. The algorithm should be given an expression that any derivatives should be integrated away from. An example makes this more clear:
\partial{#}::PartialDerivative; ex:= \int{ \partial_{m}{ A } B C D }{x};
\(\displaystyle{}\text{Attached property PartialDerivative to }\partial{\#}.\)
\(\displaystyle{}\int{}\partial_{m}{A} B C D\, {\rm d}x\)
integrate_by_parts(_, $A$);
\(\displaystyle{}-\int{}A \partial_{m}\left(B C D\right)\, {\rm d}x\)
product_rule(_);
\(\displaystyle{}-\int{}A \left(\partial_{m}{B} C D+B \partial_{m}{C} D+B C \partial_{m}{D}\right)\, {\rm d}x\)
distribute(_);
\(\displaystyle{}-\int{}\left(A \partial_{m}{B} C D+A B \partial_{m}{C} D+A B C \partial_{m}{D}\right)\, {\rm d}x\)
Note that integrate_by_parts only does the formal manipulation of moving the derivative around. If you want to discard derivatives of objects which are constant, you need to use the Depends property to indicate on which coordinates or derivatives objects depend, and the unwrap algorithm to eliminate derivatives of constants, as in the following lines.
{B,D}::Depends(\partial);
\(\displaystyle{}\text{Attached property Depends to }\left(B, \mmlToken{mo}[linebreak="goodbreak"]{} D\right).\)
unwrap(ex);
\(\displaystyle{}-\int{}\left(A \partial_{m}{B} C D+A B C \partial_{m}{D}\right)\, {\rm d}x\)
Copyright © 2001-2024 Kasper Peeters
Questions? info@cadabra.science