Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Hi Folks,

The results from the following code are mathematically correct but I'm not certain that the ; used in the subscripts is legal. Can anybody enlighten me please? BTW the ; notation is a common abbreviation for covariant derivatives in general relativity.

{a,b,c,d,e#}::Indices(position=fixed).

\partial_{#}::PartialDerivative.

deriv1 := A?_{; a}     -> \partial_{a}{A?}.
deriv2 := A?_{; a ; b} -> \partial_{a}{A?_{; b}} - \Gamma^c_{a b} A?_{; c}.

substitute (deriv2,deriv1);

Mab := M_{; a ; b};

substitute (Mab,deriv2);

Many thanks, Leo

in General questions by (1.8k points)

1 Answer

+1 vote
 
Best answer

That will not in general do the right thing, at least not as it stands, but read on. Cadabra interprets the ';' as just another index name. So M_{; a ; b} is a tensor with 4 indices, two of which are the same and called ;, instead of e.g. c. You can see what can go wrong if you try to enter

ex:= A_{; a} + B_{a};

This is a valid mathematical expression, but Cadabra thinks the first term has two indices, and refuses to accept this.

Now you can try to work your way around this by declaring ; as a Symbol,

;::Symbol;

which happily gets parsed and interpreted correctly. Now the ex as written above is accepted. You can probably get quite far with this. Let me know if you run into any issues and we'll see what can be done.

Note also that users will be tempted to write these things as

ex:= A_{;a} + B_{a};

(without the space between the ; and the a), in which case you again get warned about an expression with two different indices (one called ;a and one called a).

by (82.5k points)
selected by

Hi Kasper, Many thanks for the quick and informative reply. I had tried including ; in the list of indices but that failed (which is not a surprise). I can easily get by without using the ; It looked so nice when I bumped into it so I was hoping it might be legal. C'est la vie. Cheers, Leo

Well, as I said, try with the ;::Symbol, that may get you quite far. I'd like to know what's still missing in order to be able to use this notation, as it's kinda neat.

Okay, I'll play with ;::Symbol, and I'll let you now how far I get (but marking exam papers will keep me busy for the next few days).

I extended the original code from above to compute the Riemann tensor by commuting two covariant derivatives. It works with or without the ;::Symbol; trick. Here is the code

{a,b,c,d,e,f,i,j,k,l,m,n#}::Indices(position=independent).

\partial_{#}::PartialDerivative.

\Gamma^{a}_{b c}::Depends(\partial{#}).
\Gamma^{a}_{b c}::TableauSymmetry(shape={2}, indices={1,2});

#;::Symbol;  # same results with or without this

# generic rule for first two covariant derivs of a downstairs-vector

deriv1 := A?_{a ; b} -> \partial_{b}{A?_{a}} - \Gamma^{c}_{a b} A?_{c}.
deriv2 := A?_{a ; b ; c} -> \partial_{c}{A?_{a ; b}}
                          - \Gamma^{d}_{a c} A?_{d ; b}
                          - \Gamma^{d}_{b c} A?_{a ; d}.

substitute (deriv2,deriv1);

Mabc := M_{a ; b ; c}.

substitute (Mabc,deriv2)

distribute   (Mabc)
product_rule (Mabc);

Macb := M_{a ; c ; b}.

substitute (Macb,deriv2)

distribute   (Macb)
product_rule (Macb);

diff := @(Mabc) - @(Macb).

sort_product   (diff)
rename_dummies (diff)
canonicalise   (diff)
sort_sum       (diff)
factor_out     (diff,$M_{a?}$);
...