Function Repository Resource:

TensorIndexJuggling

Given a metric, convert between covariant and contravariant components of a tensor

Contributed by: Lars Ulke-Winter
 ResourceFunction["TensorIndexJuggling"][tensor,metric] uses metric to convert tensor, having only covariant components (lower indices), into the corresponding tensor with all contravariant components (upper indices). ResourceFunction["TensorIndexJuggling"][tensor,metric,"From"→"AllContravariant","To"→"AllCovariant"] converts tensor, having only contravariant components, into the corresponding tensor with all covariant components. ResourceFunction["TensorIndexJuggling"][tensor,metric,"From"→spec1,"To"→spec2] transforms between upper and lower indices as indicated by "From" and "To".

Details and Options

Index juggling is done via the covariant tensor metric gij. To convert contravariant components to covariant, use tigij=tj.
Input tensor can be of any rank and should be a List or a StructuredArray.
The speci can be chosen from among the following: "AllCovariant", "AllContravariant" or {c1,c2,}, where the ci are either of the literals "Con" or "Cov".

Examples

Basic Examples (4)

Transform a covariant rank-2 tensor in a cylindrical coordinate system to its contravariant form tijtij:

 In[1]:=
 Out[1]=

Transform a covariant rank-2 tensor in cylindrical coordinates to its mixed form tijtij:

 In[2]:=
 Out[3]=

Convert tijtij for a SymmetrizedArray:

 In[4]:=
 Out[4]=

Attempting the conversion tijtij changes nothing:

 In[5]:=
 Out[8]=

Scope (17)

Index juggling of base vectors in cylindrical frame (3)

 In[9]:=

Get the contravariant base through raising the index:

 In[10]:=
 Out[10]=

Check the orthonormality relationship gi·gj=δij:

 In[11]:=
 Out[11]=

Index juggling of the metric tensor in cylindrical frame (4)

 In[12]:=
 Out[10]=

Get the contravariant components of the metric:

 In[13]:=
 Out[11]=

This result is the same as the Wolfram Language built-in function:

 In[14]:=
 Out[15]=

 In[16]:=
 Out[17]=

Contraction of two opposing indices leads to an invariant scalar (6)

 In[18]:=
 Out[73]=

Define a Cartesian rank-2 tensor:

 In[74]:=
 Out[75]=

Contract the indices:

 In[76]:=
 Out[76]=

Use the resource function TensorCoordinateTransform to transform t to cylindrical coordinates with covariant transformation behavior tij:

 In[77]:=
 Out[129]=

Contraction should not be invariant:

 In[130]:=
 Out[130]=

But contraction of opposing indices should be:

 In[131]:=
 Out[131]=

Contraction of opposing indices in a rank-6 tensor  (4)

Start with a rank-6 tensor in a Cartesian basis and form the contraction tijkijkl:

 In[132]:=
 Out[132]=

Transform to an different affine system with given mapping:

 In[133]:=

Contraction of the indices of the same type does not lead to an invariant:

 In[134]:=
 Out[134]=

Contraction of the right opposing index pairs, after index juggling, leads to the same result as in the original coordinate system:

 In[135]:=
 Out[135]=

Properties & Relations (1)

If the mapping rule between the two coordinate frames exists, index juggling can also be done using the resource function TensorCoordinateTransform. However, if only the metric of the space is available, then TensorIndexJuggling is recommended:

 In[136]:=
 Out[136]=

Lars Ulke-Winter

Version History

• 1.0.0 – 03 October 2019