Index notation

Sections in this chapter:

Introduction
Inputs for index notation
Examples

For other chapters go to Index

Introduction

As mentioned before, TTC has  been designed to deal with tensors as single objects (not a sample of components) and most of its functions act according to this, i.e using the intrinsic notation. However, there are some operations such as the contractions or the raising and lowering indices that are denoted in an easier way using the so called abstract index notation. See Wald pp.23

This kind of operations usually appears mixed in a single expression increasing the difficulty of doing intrinsic inputs.
An example of this could be the following expression for the the Weyl tensor.

We will think that an expression like stands for the whole tensor

and the indices are a good way to indicate some operations to be done over the tensor. That is the way TTC understand this kind of inputs. The Output will be a single tensor.

Some difficulties arise in using this notation. As we have explained Type of a tensor, TTC is very rigurous in the type of tensors. So, while in handwriting notation equals, for TTC they are two different tensors ( and so the corresponding inputs are disctinget: the first ot type (+,+,-,-), and the second of type (-,-,+,+). Also , if you want to lower the second index in , an expression like cannot be used because it gives a tensor of type (-,+,+) and not of type (+,-,+) as desired. In fact, TTC provides an easier way of doing this kind of operation, you can simply write the analogous to .

Inputs for index notation

The function that provides the capability of working index notation is Index. Owing to the fact that in some computations (raising and lowering indices and covariant derivative) the metric tensor is needed, an argument giving the name of the metric is necessary. So, every input in index notation has to be of the form

Index[ g][expr]

where g is the name of the metric and expr is the expression typed in index notation. Equivalently, the form

expr// Index[g]

can be used. When no metric is needed, g can be omitted.

expr// Index[ ]

With regard to expr TTC follows as closely as possible the manuscript notation, representing every tensorial object by a unic Mathematica object and the indices in an argument representing the operation to be done on the tensor in the form

A ij kA[i, -j, -k]

in particular if the tenor A is of type (+1,-1,-1) this input means no operations on A, that is it's A itself
It is convenient to remember here the general rule introduced in Natural basis :

REMEMBER: a lower index in both, a basis element or a component of a tensor, is indicated in TTC by a minus sign.

in order to develop some examples, we define the cartesian and polar coordinates and the euclidean metric in this coordinate system.

In[2]:= InputCoordInates[cart, {x, y, z}];

In[3]:= InputCoordInates[polar, {r, phi}];

In[4]:= e = ZZ[cart]; u = ZZ[polar];

In[5]:= g = u[r, r] + r^2 u[phi, phi];

In[6]:= InputMetric[eucl, polar, g]

                  2
Out[6]= dr*.dr + r  dphi*.dphi
Now, we define the same tensors T and Q and show the way of calling them in index

notation. It is very important to realize that an expression like Ti j stands for the whole tensor . Likewise, Qi j means 

In[7]:= T = a e[1, 3] + 5 e[2, 3]

Out[7]= a dx*.dz + 5 dy*.dz

In[8]:= T[-i, -j] // Index[ ]

Out[8]= a dx*.dz + 5 dy*.dz

In[9]:= Q = x e[-2, -3] - y e[-1, -1]

Out[9]= x Dy*.Dz - y Dx*.Dx

In[10]:= Q[i, j] // Index[ ]

Out[10]= x Dy*.Dz - y Dx*.Dx
To compute the tensor product in index notation it is enough to type Ti jQk l. It has to be stressed that this tensor is different from. Qi jTk l
In[10]:= T[-i, -j] Q[k, l] // Index[ ]

Out[10]= a x dx*.dz*.Dy*.Dz - a y dx*.dz*.Dx*.Dx +

>    5 x dy*.dz*.Dy*.Dz - 5 y dy*.dz*.Dx*.Dx

In[13]:= Q[i, j] T[-k, -l] // Index[ ]

Out[13]= a x Dy*.Dz*.dx*.dz + 5 x Dy*.Dz*.dy*.dz -

>    a y Dx*.Dx*.dx*.dz - 5 y Dx*.Dx*.dy*.dz
Contractions can easily be done using index notation. You only have to type it as it was a handwritten expression. For example, we compute Ti jQj k and Qi j T j k
In[11]:= T[-i, -j] Q[j, k] // Index[ ]

Out[11]= 0

In[14]:= Q[i, j] T[-j, -k] // Index[ ]

Out[14]= -(a y) Dx*.dz
The Symmetric and Antisymmetric operators allow to simetrize or antisimetrize a full covariant or contravariant tensor, but when they act upon a mixt tensor they fail in obtainig a result.
The index notation generalizes these operators allowing symmetrizations and antisymmetrizations like A[i j k l]. The notation to symmetrize and antisymmetrize follows the scheme ( only permissible in explicit (E) tensor calculus)

A(i j) A[.< -i, -j >.]

A[i j] A[.<< -i, -j >>.]

Next, we define the tensor t and get the symmetric and antisymmetric parts using index notation.

In[15]:= t = 2 a e[1, 2] + 2 b e[3, 1]

Out[15]= 2 a dx*.dy + 2 b dz*.dx

In[19]:= St = t[.<-i, -j>.] // Index[ ]

Out[19]= a dx*.dy + b dx*.dz + a dy*.dx + b dz*.dx

In[20]:= At = t[.<<-i, -j>>.] // Index[ ]

Out[20]= a dx*.dy - b dx*.dz - a dy*.dx + b dz*.dx
Covariant derivatives can also be computed using index notation ( semicolon derivative). The results obtained with CovariantD and AbsoluteD can be achieved easily employing the correspondence

A[i, -j, .; -k]

Being and two vectors in polar coordinates, we compute (the absolute derivative v )and (the covariant derivative of A in the direction of v).

In[22]:= v = u[-1]

Out[22]= Dr

In[25]:= v[i, .;-j] // Index[eucl]

         1
Out[25]= - Dphi*.dphi
         r

In[26]:= A = u[-1] + r u[-2]

Out[26]= r Dphi + Dr

In[28]:= A[i, .;-j] v[j] // Index[eucl]

Out[28]= 2 Dphi
Partial derivatives of components of tensors can be computed in the same way (colon derivative). The appropiate notation is now:

A[-i, -j, ., -k]

The user has to remember that partial differentiation of a tensor does not generally yields another tensor and has to be carefully in using it.

TTC raises and lowers indices in an automatic way. If you have a tensor with a lower index and want to raise it, just type the tensor in index notation moving the subscript to the upper position. For instance, to obtain fromyou have to proceed as it follows.

In[31]:= A[-i] // Index[eucl]

               3
Out[31]= dr + r  dphi

Examples

in this section we develop several examples in order to gain some familiarity with index notation. First of all, we declare the spherical coordinates and the metric tensor on a sphere of radius a. The name of the coordinate system is sph2, their symbols {th, ph} and the name of the metric SPH. Finally, we assign the symbols g and R to the metric and Riemann tensors, respectively.
In[2]:= InputCoordinates[sph2, {th, ph}]; e = ZZ[sph2];

In[3]:= InputMetric[SPH, sph2, a^2 (e[1, 1] + SIn[th]^2 e[2, 2]) ];

In[4]:= g = Metric[SPH, sph2];

In[5]:= R = Riemann[SPH, sph2];
Riemann , the 4-covariant version of the Riemann tensor. From it we compute raising the first index, and then the Ricci tensor and the curvature scalarmaking the corresponding contractions. On the other

hand, the Bianchi identities are checked in the form .

In[6]:= R[i, -j, -k, -l] // Index[SPH]

Out[6]= -Dph*.dth*.dth*.dph + Dph*.dth*.dph*.dth +

            2                             2
>    SIn[th]  Dth*.dph*.dth*.dph - SIn[th]  Dth*.dph*.dph*.dth

In[7]:= R[i, -j, -i, -k] // Index[SPH]

                          2
Out[7]= dth*.dth + SIn[th]  dph*.dph

In[8]:= R[i, j, -i, -j] // Index[SPH]

        2
Out[8]= --
         2
        a

In[9]:= R[-i, -j, .<-k, -l, .;-m>.] // Index[SPH]

Out[9]= 0
in many cases, a tensor T is defined from a given tensor Q through . in TTC, this kind of definitions are not allowed because indices cannot appear in the left hand side of an assignation. However, you can still obtain T from Q fixing somehow the right order of the indices in the right hand side. For instance, we define the symmetrized Riemann tensorusing the following trick of notation ( here 0[...] is undersdtood by TTC as the zero tensor and can be used to fix the order of the index.
In[10]:= S = 0[-i, -j, -k, -l] -
                 (1/3) ( R[-i, -k, -j, -l] +
                      R[-i, -l, -j, -k] ) // Index[SPH]

             2        2
         -2 a  Sin[th]
Out[10]= -------------- dth*.dth*.dph*.dph +
               3

      2        2
     a  SIn[th]
>    ----------- dth*.dph*.dth*.dph +
          3

      2        2
     a  SIn[th]
>    ----------- dth*.dph*.dph*.dth +
          3

      2        2
     a  SIn[th]
>    ----------- dph*.dth*.dth*.dph +
          3

      2        2
     a  SIn[th]
>    ----------- dph*.dth*.dph*.dth -
          3

        2        2
     2 a  SIn[th]
>    ------------- dph*.dph*.dth*.dth
           3
The possible mixture in the same session of intrinsic and index notation makes TTC a powerful working tool. Let us have a look at some examples. Next, we define a vector field, check that it satisfies the Killing's equations

and obtain n, a unitary vector field in the direction of v. Then, we build a tensor t using MatrixToTensor and the projector , project (the second

index) onto the space orthogonal to n and give to it the name T. Finally, we check that and 

In[27]:= v = e[-2]

Out[27]= Dph

In[30]:= v[-i, .;-j] + v[-j, .;-i] // Index[SPH]

Out[30]= 0

In[31]:= n = Unitary[SPH][v]

         Csc[th]
Out[31]= ------- Dph
            a

In[32]:= m = {{a, 4}, {-2, b}}

Out[32]= {{a, 4}, {-2, b}}

In[33]:= t = MatrixToTensor[m, {1,1}, sph2]

Out[33]= b Dph*.Dph - 2 Dph*.Dth + 4 Dth*.Dph + a Dth*.Dth

In[34]:= g[-i, -j] - n[-i] n[-j] // Index[SPH]

          2
Out[34]= a  dth*.dth

In[35]:= P = %;

In[36]:= t[i, j] P[-j, k] // Index[SPH]

Out[36]= -2 Dph*.Dth + a Dth*.Dth

In[37]:= T=%;

In[38]:= T[i, j] n[-j]//Index[SPH]

Out[38]= 0

In[39]:= T[i, j] n[-i]//Index[SPH]

Out[39]= -2 a SIn[th] Dth
The above examples are only a small sample of the possibilities that has TTC when working in the index notation. The user can put together different operations in the same expression and thus make very elaborated inputs.

This page is maintained by XavierJaén.