Differential forms
Cadabra can handle the calculus of differential forms. Differential forms are declared by attaching the propertyDifferentialForm
to an object, as in the example below, where we declare
four forms, with degree 0 to 3, and one form with symbolic degree $p$.A0::LaTeXForm("A^{(0)}").
A1::LaTeXForm("A^{(1)}").
A2::LaTeXForm("A^{(2)}").
A3::LaTeXForm("A^{(3)}").
Bp::LaTeXForm("B^{(p)}").
A0::DifferentialForm(degree=0);
A1::DifferentialForm(degree=1);
A2::DifferentialForm(degree=2);
A3::DifferentialForm(degree=3);
Bp::DifferentialForm(degree=p);
\(\displaystyle{}\text{Attached property DifferentialForm to }A^{(0)}.\)
\(\displaystyle{}\text{Attached property DifferentialForm to }A^{(1)}.\)
\(\displaystyle{}\text{Attached property DifferentialForm to }A^{(2)}.\)
\(\displaystyle{}\text{Attached property DifferentialForm to }A^{(3)}.\)
\(\displaystyle{}\text{Attached property DifferentialForm to }B^{(p)}.\)
The exterior product (or wedge product) of forms is denoted with a
^
symbol (make sure to put a space
before and after this symbol to avoid confusion with a superscript).ex:=A1 ^ A2 + A2 ^ A1;
\(\displaystyle{}A^{(1)}\wedge A^{(2)}+A^{(2)}\wedge A^{(1)}\)
A1 ^ A2 + A2 ^ A1
sort_product(_);
\(\displaystyle{}2A^{(1)}\wedge A^{(2)}\)
2A1 ^ A2
ex:=A1 ^ A2 ^ A1;
sort_product(_);
\(\displaystyle{}A^{(1)}\wedge A^{(2)}\wedge A^{(1)}\)
A1 ^ A2 ^ A1
\(\displaystyle{}0\)
0
ex:= A3 ^ A2 ^ A1 ^ A2;
sort_product(_);
\(\displaystyle{}A^{(3)}\wedge A^{(2)}\wedge A^{(1)}\wedge A^{(2)}\)
A3 ^ A2 ^ A1 ^ A2
\(\displaystyle{}-A^{(1)}\wedge A^{(2)}\wedge A^{(2)}\wedge A^{(3)}\)
An exterior derivative can be declared by using the
ExteriorDerivative
property. Applying an exterior
derivative twice produces zero, and it obeys the product rule taking into account the degree of differential forms.d{#}::ExteriorDerivative;
d{#}::LaTeXForm("{\rm d}").
\(\displaystyle{}\text{Attached property ExteriorDerivative to }d{\#}.\)
ex2:= d{ @(ex) };
\(\displaystyle{}-{\rm d}\left(A^{(1)}\wedge A^{(2)}\wedge A^{(2)}\wedge A^{(3)}\right)\)
-d(A1 ^ A2 ^ A2 ^ A3)
product_rule(_);
\(\displaystyle{}-{\rm d}{A^{(1)}}\wedge A^{(2)}\wedge A^{(2)}\wedge A^{(3)}+A^{(1)}\wedge {\rm d}{A^{(2)}}\wedge A^{(2)}\wedge A^{(3)}+A^{(1)}\wedge A^{(2)}\wedge {\rm d}{A^{(2)}}\wedge A^{(3)}+A^{(1)}\wedge A^{(2)}\wedge A^{(2)}\wedge {\rm d}{A^{(3)}}\)
-d(A1) ^ A2 ^ A2 ^ A3 + A1 ^ d(A2) ^ A2 ^ A3 + A1 ^ A2 ^ d(A2) ^ A3 + A1 ^ A2 ^ A2 ^ d(A3)
ex:= d{ A1 ^ A2 ^ d{ A3 } };
\(\displaystyle{}{\rm d}\left(A^{(1)}\wedge A^{(2)}\wedge {\rm d}{A^{(3)}}\right)\)
d(A1 ^ A2 ^ d(A3))
product_rule(_);
\(\displaystyle{}{\rm d}{A^{(1)}}\wedge A^{(2)}\wedge {\rm d}{A^{(3)}}-A^{(1)}\wedge {\rm d}{A^{(2)}}\wedge {\rm d}{A^{(3)}}\)
d(A1) ^ A2 ^ d(A3)-A1 ^ d(A2) ^ d(A3)
sort_product(_);
\(\displaystyle{}A^{(2)}\wedge {\rm d}{A^{(1)}}\wedge {\rm d}{A^{(3)}}-A^{(1)}\wedge {\rm d}{A^{(2)}}\wedge {\rm d}{A^{(3)}}\)
A2 ^ d(A1) ^ d(A3)-A1 ^ d(A2) ^ d(A3)
Two forms in a product can only be swapped around if one of their degrees is zero:
ex4:= A2 A0 + A0 A2;
sort_product(_);
\(\displaystyle{}A^{(2)} A^{(0)}+A^{(0)} A^{(2)}\)
A2 A0 + A0 A2
\(\displaystyle{}2A^{(0)} A^{(2)}\)
2A0 A2
In a wedge product, forms can be swapped around taking into account their degree:
ex5:= A3 ^ A1 - A1 ^ A3 + A2 ^ A2 ^ A0;
sort_product(_);
\(\displaystyle{}A^{(3)}\wedge A^{(1)}-A^{(1)}\wedge A^{(3)}+A^{(2)}\wedge A^{(2)}\wedge A^{(0)}\)
A3 ^ A1-A1 ^ A3 + A2 ^ A2 ^ A0
\(\displaystyle{}-2A^{(1)}\wedge A^{(3)}+A^{(0)}\wedge A^{(2)}\wedge A^{(2)}\)
-2A1 ^ A3 + A0 ^ A2 ^ A2
Differential forms can have tensor indices, e.g. for vielbeine or spin connections:
{a,b,c}::Indices;
{e^{a}, \omega^{a}_{b}}::DifferentialForm(degree=1);
\(\displaystyle{}\text{Attached property Indices(position=free) to }\left[a, b, c\right].\)
\(\displaystyle{}\text{Attached property DifferentialForm to }\left[e^{a}, \omega^{a}\,_{b}\right].\)
ex:=d{e^{a}} = - \omega^{a}_{b} ^ e^{b};
\(\displaystyle{}{\rm d}{e^{a}} = -\omega^{a}\,_{b}\wedge e^{b}\)
d(e^{a}) = -\omega^{a}_{b} ^ e^{b}
cv:= d{ @(ex) };
\(\displaystyle{}0 = -{\rm d}\left(\omega^{a}\,_{b}\wedge e^{b}\right)\)
0 = -d(\omega^{a}_{b} ^ e^{b})
distribute(cv);
product_rule(cv);
\(\displaystyle{}0 = -{\rm d}\left(\omega^{a}\,_{b}\wedge e^{b}\right)\)
0 = -d(\omega^{a}_{b} ^ e^{b})
\(\displaystyle{}0 = -{\rm d}{\omega^{a}\,_{b}}\wedge e^{b}+\omega^{a}\,_{b}\wedge {\rm d}{e^{b}}\)
0 = -d(\omega^{a}_{b}) ^ e^{b} + \omega^{a}_{b} ^ d(e^{b})
substitute(cv, ex);
\(\displaystyle{}0 = -{\rm d}{\omega^{a}\,_{b}}\wedge e^{b}-\omega^{a}\,_{b}\wedge \omega^{b}\,_{c}\wedge e^{c}\)
0 = -d(\omega^{a}_{b}) ^ e^{b}-\omega^{a}_{b} ^ \omega^{b}_{c} ^ e^{c}
rename_dummies(cv);
\(\displaystyle{}0 = -{\rm d}{\omega^{a}\,_{b}}\wedge e^{b}-\omega^{a}\,_{b}\wedge \omega^{b}\,_{c}\wedge e^{c}\)
0 = -d(\omega^{a}_{b}) ^ e^{b}-\omega^{a}_{b} ^ \omega^{b}_{c} ^ e^{c}
Some more random assorted ramblings below, not finished yet!!!
ex4:= d{ @(ex5) };
\(\displaystyle{}{\rm d}\left(-2A^{(1)}\wedge A^{(3)}+A^{(0)}\wedge A^{(2)}\wedge A^{(2)}\right)\)
d(-2A1 ^ A3 + A0 ^ A2 ^ A2)
distribute(_);
\(\displaystyle{}-2{\rm d}\left(A^{(1)}\wedge A^{(3)}\right)+{\rm d}\left(A^{(0)}\wedge A^{(2)}\wedge A^{(2)}\right)\)
-2d(A1 ^ A3) + d(A0 ^ A2 ^ A2)
product_rule(_);
\(\displaystyle{}-2{\rm d}{A^{(1)}}\wedge A^{(3)}+2A^{(1)}\wedge {\rm d}{A^{(3)}}+{\rm d}{A^{(0)}}\wedge A^{(2)}\wedge A^{(2)}+A^{(0)}\wedge {\rm d}{A^{(2)}}\wedge A^{(2)}+A^{(0)}\wedge A^{(2)}\wedge {\rm d}{A^{(2)}}\)
-2d(A1) ^ A3 + 2A1 ^ d(A3) + d(A0) ^ A2 ^ A2 + A0 ^ d(A2) ^ A2 + A0 ^ A2 ^ d(A2)
sort_product(_);
\(\displaystyle{}-2A^{(3)}\wedge {\rm d}{A^{(1)}}+2A^{(1)}\wedge {\rm d}{A^{(3)}}+A^{(2)}\wedge A^{(2)}\wedge {\rm d}{A^{(0)}}+2A^{(0)}\wedge A^{(2)}\wedge {\rm d}{A^{(2)}}\)
-2A3 ^ d(A1) + 2A1 ^ d(A3) + A2 ^ A2 ^ d(A0) + 2A0 ^ A2 ^ d(A2)
{i,j,k,l}::Indices(values={1,2,3});
{i,j,k,l}::Integer(1..3);
\epsilon^{i j k}::EpsilonTensor;
d{#}::ExteriorDerivative;
d{#}::LaTeXForm("{\rm d}").
\(\displaystyle{}\text{Attached property Indices(position=free) to }\left[i, j, k, l\right].\)
\(\displaystyle{}\text{Attached property Integer to }\left[i, j, k, l\right].\)
\(\displaystyle{}\text{Attached property EpsilonTensor to }\epsilon^{i j k}.\)
\(\displaystyle{}\text{Attached property ExteriorDerivative to }d{\#}.\)
ex:=\epsilon^{i j k};
\(\displaystyle{}\epsilon^{i j k}\)
\epsilon^{i j k}
evaluate(_, $$);
\(\displaystyle{}\square{}^{i}{}^{j}{}^{k}\left\{\begin{aligned}\square{}^{1}{}^{2}{}^{3}= & 1\\[-.5ex]
\square{}^{1}{}^{3}{}^{2}= & -1\\[-.5ex]
\square{}^{2}{}^{1}{}^{3}= & -1\\[-.5ex]
\square{}^{2}{}^{3}{}^{1}= & 1\\[-.5ex]
\square{}^{3}{}^{1}{}^{2}= & 1\\[-.5ex]
\square{}^{3}{}^{2}{}^{1}= & -1\\[-.5ex]
\end{aligned}\right.
\)
\components^{i j k}({{1, 2, 3} = 1, {1, 3, 2} = -1, {2, 1, 3} = -1, {2, 3, 1} = 1, {3, 1, 2} = 1, {3, 2, 1} = -1})
rl:= { \Sigma^{1} = \cos{\psi} d{\theta} + \sin{\psi} \sin{\theta} d{\phi},
\Sigma^{2} = -\sin{\psi} d{\theta} + \cos{\psi} \sin{\theta} d{\phi},
\Sigma^{3} = \cos{\theta} d{\phi} + d{\psi} };
\(\displaystyle{}\left[\Sigma^{1} = \cos{\psi} {\rm d}{\theta}+\sin{\psi} \sin{\theta} {\rm d}{\phi}, \Sigma^{2} = -\sin{\psi} {\rm d}{\theta}+\cos{\psi} \sin{\theta} {\rm d}{\phi}, \Sigma^{3} = \cos{\theta} {\rm d}{\phi}+{\rm d}{\psi}\right]\)
{\Sigma^{1} = \cos(\psi) d(\theta) + \sin(\psi) \sin(\theta) d(\phi), \Sigma^{2} = -\sin(\psi) d(\theta) + \cos(\psi) \sin(\theta) d(\phi), \Sigma^{3} = \cos(\theta) d(\phi) + d(\psi)}
tst:= -1/2 \epsilon^{i j k} \Sigma^{j} ^ \Sigma^{k};
\(\displaystyle{} - \frac{1}{2}\epsilon^{i j k} \Sigma^{j}\wedge \Sigma^{k}\)
evaluate(tst, rl);
\(\displaystyle{}0\)