Cadabra
a field-theory motivated approach to computer algebra

unwrap

Move objects out of derivatives, accents or exterior products.
Move objects out of Derivatives, Accents or exterior (wedge) products when they do not depend on these operators. The most basic example is Accents, which will get removed from objects which do not depend on them, as in the following example:
\hat{#}::Accent; \hat{#}::Distributable; B::Depends(\hat); ex:=\hat{A+B+C};
\(\displaystyle{}\text{Attached property Accent to }\widehat{\#}.\)
\(\displaystyle{}\text{Attached property Distributable to }\widehat{\#}.\)
\(\displaystyle{}\text{Attached property Depends to }B.\)
\(\displaystyle{}\widehat{A+B+C}\)
\hat{A + B + C}
distribute(_);
\(\displaystyle{}\widehat{A}+\widehat{B}+\widehat{C}\)
\hat{A} + \hat{B} + \hat{C}
unwrap(_);
\(\displaystyle{}\widehat{B}\)
\hat{B}
Derivatives will be set to zero if an object inside does not depend on it. All objects which are annihilated by the derivative operator are moved to the front (taking into account anti-commutativity if necessary),
\partial{#}::PartialDerivative; {A,B,C,D}::AntiCommuting; x::Coordinate; {B,D}::Depends(\partial{#});
\(\displaystyle{}\text{Attached property PartialDerivative to }\partial{\#}.\)
\(\displaystyle{}\text{Attached property AntiCommuting to }\left[A, B, C, D\right].\)
\(\displaystyle{}\text{Attached property Coordinate to }x.\)
\(\displaystyle{}\text{Attached property Depends to }\left[B, D\right].\)
ex:=\partial_{x}{A B C D};
\(\displaystyle{}\partial_{x}\left(A B C D\right)\)
\partial_{x}(A B C D)
unwrap(_);
\(\displaystyle{}-A C \partial_{x}\left(B D\right)\)
-A C \partial_{x}(B D)
Note that a product remains inside the derivative; to expand that use prodrule. Here is another example:
\del{#}::LaTeXForm("\partial"). \del{#}::Derivative; X::Depends(\del{#}); ex:=\del{X*Y*Z};
\(\displaystyle{}\text{Attached property Derivative to }\partial{\#}.\)
\(\displaystyle{}\text{Attached property Depends to }X.\)
\(\displaystyle{}\partial\left(X Y Z\right)\)
\del(X Y Z)
product_rule(_);
\(\displaystyle{}\partial{X} Y Z+X \partial{Y} Z+X Y \partial{Z}\)
\del(X) Y Z + X \del(Y) Z + X Y \del(Z)
unwrap(_);
\(\displaystyle{}\partial{X} Y Z\)
\del(X) Y Z
Note that all objects are by default constants for the action of Derivative operators. If you want objects to stay inside derivative operators you have to explicitly declare that they depend on the derivative operator or on the coordinate with respect to which you take a derivative.
The final case where unwrap acts is when exterior products contain factors which are scalars (or forms of degree zero). The following example shows this.
{f,g}::DifferentialForm(degree=0). {V, W}::DifferentialForm(degree=1). {V,g}::AntiCommuting; foo := f V ^ W g;
\(\displaystyle{}\text{Attached property AntiCommuting to }\left[V, g\right].\)
\(\displaystyle{}\left(f V\right)\wedge \left(W g\right)\)
f V ^ W g
unwrap(_);
\(\displaystyle{}-f g V\wedge W\)
-f g V ^ W
As this example shows, unwrap takes into account commutativity properties (hence the sign flip).
Copyright © 2001-2021 Kasper Peeters
Questions? info@cadabra.science