Symbolic Tensor Calculus Using Index Notation
Symbolic Tensor Calculus Using Index Notation
Symbolic Tensor Calculus Using Index Notation
net/publication/243666441
CITATIONS READS
3 738
3 authors, including:
Xavier Jaén
Universitat Politècnica de Catalunya
64 PUBLICATIONS 448 CITATIONS
SEE PROFILE
All content following this page was uploaded by Xavier Jaén on 09 November 2016.
Reuse of AIP Publishing content is subject to the terms at: https://publishing.aip.org/authors/rights-and-permissions. Download to IP: 104.249.167.47 On: Wed,
09 Nov 2016 10:00:08
Symbolictensor calculus using index notation
P. Castellvi
Department de Fisica Aplicada, Universitat Politknica de Catalunya, Dr. Maraticb 44,
08028 Barcelona, Spain
X. Ja&?’ and E. Llanta”‘3b’
Department de Fisica i Enginyeria Nucleal; Universitat Politbica de Catalunya Mhdul BI-Campus
Nord, Gran Capith sin., 08034 Barcelona, Spain
(Receh*ed 20 June 1994; accepted 2 February 1995)
We present a Mathematics program which implements tensor calculus using index notation.
Common operations, such as contractions, lowering and raising of indices, symmetrization and
antisymmetrization, and covariant derivatives, are implemented in such a manner that the notation
for the inputs is close to that found iri textbooks. The optimization of the time to perform the
calculations has been one of the main objectives when writing the code. This program has been
merged with the package TTC, recently published in this journal, so the user can use both intrinsic
notation and index expressions when performing tensor calculus. 0 1995 American Institute of
Physics.
Out[2]={XX,{X1,X2,X3}}
{cs,{r,th,ph,tH
The output informs us about all the coordinate systems that are actually in use in TTC:
In[3]:=e=ZZ[cs,];
This is a convenient input to avoid writing every time ZZ [ cs , . . . 1. Now the symbol for the basis elements will be
just e (or any other user symbol). We can practice a little by making several inputs of basis tensor elements:
In[4]:={e[t,-r],e[t]*.e[-r],e[t,t],e[t]^2,e[{r,t}],e[r]*-e[t]}
Out[4]={dt*.Dr,dt*.Dr,dt*.dt,dt*.dt,dr*^dt,dr*~dt}
Note that there is more than one way to make the same input. The symbol * . means in this system an outer product and
it is used for inputs and outputs. An integer power of a tensor is understood with the outer product instead of times, as is
Note that R itself is the (covariant) Riemann tensor. The has to be understood in the index notation sense. Index
input In [ 7 ] is analogous to writing Rijkr , when one is itself has an argument which is the label of the metric we
using index notation to express, in fact, the whole tensor. want to use if needed. If there is no metric, and conse-
R,jk, does not mean one component or a set of components quently the input has not metric operations, just write In-
more or less ordered. It just means the tensor R is its co- dex [I. The indexes i,j,k,l... in R[-i,-j,-k,
variant version, and the use of the index is a useful way to -11, and in the rest of the session, have to be symbols and
indicate the covariant character of R. The output is just R.
can be substituted by another set of symbols.
The function Index[ SW] is the way we indicate to TTC
that the input (more exactly, the argument of Index[ SW]) To raise the first index of R we have to just input:
In[8]:=R[i,-j,-k,-l]//Index[sw]
2m 2m
Out[8]= ------------ Dt*.dr*.dr*.dt + __----------- Dt*.dr*.dt*.dr + ...
(2m-r)r* r*(-2m+r)
In this case, In [ 7 ] is analogous to Rikl. Note that we use the same symbol R, i.e., the covariant version of the Riemann
tensor, but now the result is another tensor (also in the tensorial type sense) and the operation-the raising of the first
index-is indicated by the signs of the indexes.
Another similar input and output is
In[g]:=R[-i,-j,k,-l]//Index[sw]
m m
Out[9]= ------------- dr*.dth*.Dth*.dr - - dr*.dth*.Dr*.dth + . ..
r* ( -2m+r ) r
To indicate contraction we just repeat the index, as in the convention summation of Einstein:
Reuse of AIP Publishing content is subject to the terms at: https://publishing.aip.org/authors/rights-and-permissions. Download to IP: 104.249.167.47 On: Wed,
09 Nov 2016 10:00:08 COMPUTERS IN PHYSICS,
VOL.9, NO.3, MAY/JUN 1995 331
In[lO]:=R[i,-j,-i,-l]//Index[sw]
Out[ lO]=O
In [ 10 ] is just the Ricci tensor or Rji, where, as usual, a sum over i= 1 , . . . ,n is understood. The dimension of the manifold
is n, in our case the space-time dimension, i.e., 4. The output is 0, since Schwarzschild space time is a vacuum solution of
Einstein’s field equations.
To indicate the symmetrization of indices we use the symbols .( and ). enclosing the indices that we want to
symmetrize. Analogously to indicate antisymmetrizations we use . (( and )) . .
The ciclicity property of the Riemann tensor can be checked:
InlIIl:=R[-i,.c-j,-k,-l>.]//Index[sw]
Out[ ll]=O
m m
Out[12]= ------------ dr*.dr*.Dt*.dt + ---------mm--_- dr*.dr*.Dph*.dph + ...
(2m-r)r* 2r2 ( -2m+r )
where In1 12 ] stands for R~~jl and, as usual, we have to understand that the index k is not symmetrized.
In the next input we intro d uce the way to express covariant derivatives. For example, the differential Bianchi identities
are
In[l3]:=R[-i,-j,.<-k,-l,.;-p>.]//Index[sw]
Out[ 13]=0
where the symbol . ; followed by an index is used to mimic the semicolon notation for the covariant derivative. Now the
tensor has five indexes. The new index can be treated as the others, and we can, for example, symmetrize it. In [ 13 ] stands
for Rij(kl;p) .
Another usual index operation is a multiple contraction, as in the following example:
In[14]:=R[-i,-j,-k,-l]R[i,j,k,l]//Index[sw]
48m2
Out[ 14]= -----
r6
Reuse of AIP
338Publishing content
COMPUTERS is subject
IN PHYSICS, to the
VOL. terms
9,NO. at: https://publishing.aip.org/authors/rights-and-permissions.
3,MAY/JUN 1995 Download to IP: 104.249.167.47 On: Wed, 09
Nov 2016 10:00:08
. _ * _-.I,-- _ _
In[15 ] :=s=o [-i,-j,-k,-11
+1/3(R[-i,-k,-j,-l]+R[-i,-l,-],-k])//Inciex[sw]
‘~ . -
2m 2m Sin[th]*
Out[15]= --------- dr*.dr*.dth*.dth + _____------- dr*.dr*.dph*.dph - ...
6m-3r 6m-3r
Note that the S in the right-hand side appears without indices, since the result of Index [SW] in the left-hand side is
a tensor and indices constitute only a suitable way to indicate some operations. In this way, the components of the tensor S
will be ordered as indicated by the indices in the 0 tensor.
In the next example we make some tensor operations on a scalar function:
In[l7]:=f[r][.;i,.;-i]//Index[sw]
Enter the name of the coordinates of f [r], Interrupt [] or Dialog []
=cs
-2 m f’[r]+ 2 r f’[r]-2 m r f”[r]+r* f”[r]
r*
I
In [ 17 ] stands for f’ being f a function of r. TTC asks for where the square brackets [ and ] are used to indicate an-
the basis or coordinate system of the scalar function f [ r ] tisymmetrization of indices. Note that in this expression,
which is cs in this case. and as is usual, the symbol R is used for the Riemann and
In all of these examples,as we have commented,the Ricci tensors and also for the curvature scalar. This is indi-
indexes i, j,k,l.. . have to be symbols. In interacting cated by the number of indices they have in each case.
with Mathematics as in the above session, this will not Obviously, in TIC we cannot use an analogy to this, since
produce any problem, but if we want to define some func- knowledge of the number of indices does not suffice to
tion using index notation and save it in a file for future use distinguish the algorithms for the Riemann and Ricci ten-
this can be a problem. Let us see how we can proceed.
sors. For this reason, we have to use different symbols for
Suppose we want to define an algorithm for the Weyl tensor
IV(Ref. 6, p. 325, Eq. 13.50): the Riemann and Ricci tensors when writing inputs for
TIT.
We write in a file that we call weyl .m the following
Wabcd= Rnbcd- 2&@[b,l+ f 8=EC$]dlR, (5) code:
I
Weyl[g-,x-]:=Weyl[g,x]=
Module[{Rie,Ric,R,Dl,a,b,c,d},
Rie=Riemann[g,x];
Ric=Ricci[g,x];
R=Curvature[g,x];
Dl=IdentityTensor[x,l,-l]
Index[gl[
Rie[a,b,-c,-d] -
2 Dl[.=Ga,. 4-c]Ric[b%.,-dB.]+
l/3 Dl[.+a,.+-c]Dl[b+.,-dB.1 R
Reuse of AIP Publishing content is subject to the terms at: https://publishing.aip.org/authors/rights-and-permissions. Download to IP: 104.249.167.47 On: Wed,
09 Nov 2016 10:00:08 COMPUTERS INPHYSICS,VOL.9,NO.3,MAY/JUN 1995 339
Note that we use the Mathematics utility Module to course, the computing time and the amount of memory
define local variables Rie, Ric, R, Dl, in order to needed increase with the difficulty of the desired manipu-
shorten and make more readable our code for the Weyl lation.
tensor. Also, we define the indices as local variables. In this The target user of TTC is a person needing to perform
way, we are sure that in this expression a, b, c, d are tensor calculus for research or academic purposes. We have
indices and will not be shadowed by future uses of them. incorporated some warnings and flags in the code to pre-
Obviously, the result will be the Weyl tensor, independent vent the misuse of the functions of the package, but con-
of the particular set of indexes used to define it. ceptual errors in the inputs can produce wrong results.
In the form we have written weyl .m, we cannot use Therefore the user is assumed to know enough differential
the Mathematics function Getl$ename] since there are geometry to write mathematically correct inputs.
some symbols in it (. e, . ;) that are not part of the The scope of applications of TIC is going to be broad-
standard Mathematics inputs. So we have to use a TIC ened in the near future with the inclusion of calculus in
function called TTCGet that works the same way as Get noncoordinate bases and the symbolic treatment of tensors.
but understands the input index notation.
ACKNOWlB6MENTS
LFNAlflHHARKS One of us (X.J.) should like to acknowledge the Comision
Asesora de Investigation Cientifica y Tecnica for financial
It is clear from the previous section that we have built a support under Contract No. PB90-0482-C02-01. S.
Mathematics package that has a very friendly input formal-
ism for index tensor operations and preserves, at the same
time, the intrinsic character of tensor objects. We think that
this constitutes an essential interface of the basic package 1. S. Wolfram, Mathematics: A System for Doing Math-
TTC, in the sense that this index notation gives the user a ematics by Computer, 2nd ed. (Addison-Wesley, Read-
tool to perform a very easy translation of the expressions ing, MA, 1991).
that would be written by hand. So, anybody with a very 2. J. M. Aguirregabiria, Math. J. 1, 51 (1990).
small knowledge of the Mathematics commands is able to 3. D. G. B. Edelen, Math. J. 1, 92 (1991).
use the computer to perform tensor calculus. 4. S. M. Christensen and L. Parker, Math. J. 1, 51 (1990).
It must also be pointed out that the examples presented 5. P. Castellvi, X. Jadn, and E. LLanta, Comput. Phys. 8,
in the previous section are of intermediate level difficulty. 360 (1994).
In fact, we have tested TTC with more complicated ex- 6. C. W. Misner, K. S. Thorne, and J. A. Wheeler, Gruvi-
amples taken from our research work in gravitation. Of tation (Freeman, San Francisco, CA, 1973).
Reuse of AIP Publishing content is subject to the terms at: https://publishing.aip.org/authors/rights-and-permissions. Download to IP: 104.249.167.47 On: Wed,
340 COMPUTERS IN PHYSICS, VOL.9, NO.3,MAY/JUN 1995
09 Nov 2016 10:00:08
View publication stats