# Symbolic Tensors

*Mathematica* offers a large number of functions to efficiently manipulate lists, matrices, and arrays of any depth and dimension. Among them there are functions to perform algebraic operations, like sums, products, inner or outer products, transpositions, etc. *Mathematica* also has powerful algorithms to manipulate algebraic combinations of expressions representing those arrays. These expressions are called *symbolic arrays* or *symbolic tensors*. By assuming given properties about those symbolic arrays (mainly rank, dimension, and symmetry), you can construct and prove results which are valid for arbitrary members of large domains of arrays obeying those properties.

Matrices are rank 2 arrays and can be symmetric, antisymmetric, or not have any symmetry at all. Higher-rank tensors can be fully symmetric or fully antisymmetric, but they can also have many other types of symmetries under transposition of their levels or slots. Relevant tensors in physics and mathematics usually have symmetry: the symmetric inertia tensors, the antisymmetric electromagnetic field, the rank 4 stiffness tensor in elasticity, the rank 4 Riemann curvature tensor of a manifold, the fully antisymmetric volume forms, etc. Even when you work with elementary objects without symmetry, like vectors, the repeated use of them leads to the appearance of symmetry. *Mathematica* introduces a general language to describe arbitrary transposition symmetries of arrays of any depth and dimension, both for ordinary arrays and for symbolic arrays. See "Tensor Symmetries" for a description of the language of symmetries.

## Symbolic Array Domains

A given symbolic expression expr will be taken to belong to a given domain adom of arrays by using an assumption of the form Element[expr, adom], where adom specifies the properties shared by all arrays of that domain.

Arrays[{d_{1},...,d_{r}},dom,sym] | arrays of given dimensions, component type, and symmetry |

Matrices[{d_{1},d_{2}},dom,sym] | matrices of given dimensions, component type, and symmetry |

Vectors[d_{1},dom] | vectors of given dimension and component type |

In[1]:= |

Out[1]= |

In[2]:= |

Out[2]= |

In[3]:= |

Out[3]= |

In[4]:= |

Out[4]= |

In[5]:= |

In[6]:= |

Out[6]= |

In[7]:= |

Out[7]= |

In[8]:= |

Out[8]= |

In[9]:= |

Out[9]= |

In[10]:= |

Out[10]= |

A general symbolic tensor expression can be understood as a linear combination of terms formed by combining the symbolic tensors using three basic operations: tensor products, transpositions, and contractions. Other basic algebra operations can be decomposed in terms of these.

TensorProduct[t_{1},t_{2},...] | tensor product of tensors |

TensorTranspose[t,perm] | transposition of tensor t by permutation perm |

TensorContract[t,pairs] | contraction of the pairs of slots in the tensor t |

In[11]:= |

In[12]:= |

Out[12]= |

In[13]:= |

Out[13]= |

In[14]:= |

Out[14]= |

In[15]:= |

Out[15]= |

In[16]:= |

Out[16]= |

In[17]:= |

Out[17]= |

In[18]:= |

Out[18]= |

In[19]:= |

Out[19]= |

## Tensor Canonicalization

As usual in computer algebra, one of the most important computational steps is converting general expressions into a canonical form, if possible. When only transposition symmetries are involved, it is always possible to bring symbolic tensor polynomials to such canonical form, using specialized group theory algorithms. However, for complicated cases involving large ranks, it could consume considerable time and memory.

TensorExpand[texpr] | expand tensor sums and products |

TensorReduce[texpr] | canonicalize terms with respect to symmetry |

In[20]:= |

In[21]:= |

Out[21]= |

In[22]:= |

Out[22]= |

In[23]:= |

Out[23]= |

In[24]:= |

Out[24]= |

In[25]:= |

Out[25]= |

In[26]:= |

Out[26]= |

In[27]:= |

Out[27]= |

The next example explores the trace of powers of an antisymmetric matrix. For such a matrix in any dimension, Tr[MatrixPower[A, n]] vanishes for odd n but not for even n. This is illustrated by constructing the power and trace in terms of TensorProduct and TensorContract and then canonicalizing the expression using TensorReduce.

In[28]:= |

In[29]:= |

In[30]:= |

Out[30]= |

In[31]:= |

Out[31]= |

In[32]:= |

Out[32]= |

In[33]:= |

Out[33]= |

In[34]:= |

Out[34]= |

In[35]:= |

Out[35]= |

In[36]:= |

Out[36]= |

A more complicated example is given by the canonicalization of scalar polynomials in the Riemann tensor. Here, only its transposition symmetries are used (also known as permutation symmetries or monoterm symmetries), and not the Riemann cyclic symmetries.

In[37]:= |

In[38]:= |

Out[38]= |

In[39]:= |

Out[39]= |

In[40]:= |

Out[40]= |

In[41]:= |

In[42]:= |

Out[43]= |

In[44]:= |

Out[44]= |

In[45]:= |

Out[45]= |

In[46]:= |

Out[46]= |