# Nice use case for symbolic tensors?

I come from before the times of symbolic tensors in Mathematica, and am used to working with concrete tensors and custom commands to contract them using Transpose, Dot, etc.

I recently realized that Mathematica now allows you to work (nicely?) with symbolic tensors, but I am struggling a bit to understand the use case of purely symbolic tensors. Does anybody have a nice example of such a thing?

To elaborate, for me an obvious use case would be to consider

\$Assumptions = {m ∈ Matrices[{4, 4}, Reals, Antisymmetric[{1, 2}]], v ∈ Vectors[4, Reals]}

mvv=TensorProduct[m,v,v];

TensorContract[mvv,{{1,3},{2,4}}]


and get zero. Unfortunately things do not seem to be defined for this [they are, see answer below!]. Not even (the completely obvious):

TensorContract[m,{1,2}]


gives zero.

I am not looking for an explanation of how to implement this in Mathematica, I am just wondering whether someone can point out a nice example where working with tensors symbolically offers a particular advantage.

(Also, any comments on why TensorContract does not come with a version that takes two tensors and contracts them in a given way? Am I missing some obvious built-in function?)

Tensor simplification can be an expensive computation, so it is not performed automatically. You need to use TensorReduce on symbolic tensor expressions, like you would use Simplify in more general expressions:

In[]:= TensorContract[m, {1, 2}] // TensorReduce
Out[]= 0


To contract the tensor product of several tensors use something like:

TensorContract[TensorProduct[m, m, m], {{2, 3}, {4, 5}, {1, 6}}]


which TensorReduce can also show is zero.

I think the main advantage of working with symbolic tensors is that you can focus on the relevance of symmetry in the tensor expressions, instead of having to look at large scalar polynomials and trying to find patterns. It also allows you to perform computations with arbitrary dimension, given that you can start with Matrices[{dim, dim}, Reals, Symmetric[{1, 2}]] for example, where dim is a symbol.

• That's great, thanks! I really should have had a better look at the documentation and not missed TensorReduce.. Now things make sense. – Stijn Dec 9 '20 at 20:49