Cadabra
a field-theory motivated approach to computer algebra

evaluate

Evaluate components of a tensor expression.
Given an abstract tensor expression and a set of rules for the components of tensors occurring in this expression, evaluate the components of the full expression. The minimal information needed for this to work is a declaration of the indices used, and a declaration of the values that those indices use:
{r,t}::Coordinate. {m,n,p,s}::Indices(values={t,r}). ex:= A_{n m} B_{m n p} ( C_{p s} + D_{s p} );
\(\displaystyle{}A_{n m} B_{m n p} \left(C_{p s}+D_{s p}\right)\)
The list of component values should be given just like the list of rules for the substitute algorithm, that is, as equalities
rl:= [ A_{r t} = 3, B_{t r t} = 2, B_{t r r} = 5, C_{t r} = 1, D_{r t} = r**2*t, D_{t r}=t**2 ];
\(\displaystyle{}(A_{r t} = 3, B_{t r t} = 2, B_{t r r} = 5, C_{t r} = 1, D_{r t} = r^{2} t, D_{t r} = t^{2})\)
The evaluate algorithm then works out the values of the components of the ex expression, which will be denoted with a $\square$ in its output,
evaluate(ex, rl);
\(\displaystyle{}\begin{aligned}\square{}_{r}= & 6r^{2} t+6\\ \square{}_{t}= & 15t^{2}\\ \end{aligned} \)
Copyright © 2001-2024 Kasper Peeters
Questions? info@cadabra.science