You can do something similar there; e.g. instead of what I wrote for ex2
, write
ex2:= S_{\kappa} = D_{\kappa\mu\nu} T^{\mu\nu};
Then you can use this $S_\kappa$ tensor again in another expression and substitute similar to what I did above.
In other words: do not view the Python name for an expression (ex1
and ex2
) above as a tensor; rather, write out that tensor explicitly. If you find it confusing, you could e.g. write
T:= T^{\mu\lambda} = ...
instead of the first line, so use the same name T
for the expression and for the tensor that it defines.
This all comes from the fact that in Cadabra there is a difference between the "programming language" (Python) and the "maths language" (LaTeX). Python names do not know about indices.