Cadabra
a field-theory motivated approach to computer algebra

expand

Write out products of objects with implicit indices.
Write out products of matrices and vectors inside indexbrackets, inserting new dummy indices for the contraction. This requires that the objects inside the index bracket are properly declared to have Matrix or ImplicitIndex properties. Here is an example with multiple matrices:
{a,b,c,d,e}::Indices; {A,B,C,D}::Matrix; ex:= (A B C D)_{a b};
\(\displaystyle{}\text{Attached property Indices(position=free) to }\left(a, b, c, d, e\right).\)
\(\displaystyle{}\text{Attached property Matrix to }\left(A, B, C, D\right).\)
\(\displaystyle{}\left(A B C D\right)\,_{a b}\)
expand(_);
\(\displaystyle{}A_{a c} B_{c d} C_{d e} D_{e b}\)
Compare the above to the following example, in which one of the objects inside the bracket is no longer a matrix:
ex:= (A B Q D)_{a b};
\(\displaystyle{}\left(A B Q D\right)\,_{a b}\)
expand(_);
\(\displaystyle{}A_{a c} B_{c d} Q D_{d b}\)
Finally, an example with matrices carrying additional labels, as well as a vector object:
{\alpha,\beta}::Indices; \Gamma{#}::Matrix; v::ImplicitIndex;
\(\displaystyle{}\text{Attached property Indices(position=free) to }\left(\alpha, \beta\right).\)
\(\displaystyle{}\text{Attached property Matrix to }\Gamma\left(\#\right).\)
\(\displaystyle{}\text{Attached property ImplicitIndex to }v.\)
ex:=(\Gamma_{r} v)_{\alpha};
\(\displaystyle{}\left(\Gamma_{r} v\right)\,_{\alpha}\)
expand(_);
\(\displaystyle{}\left(\Gamma_{r}\right)\,_{\alpha \beta} v_{\beta}\)
Copyright © 2001-2024 Kasper Peeters
Questions? info@cadabra.science