You are on page 1of 29

General Relativistic Calculations in

Mathematica
By George E. Hrabovsky

GRCalcs.nb

What I Will Cover


00
00

What is xAct?

00
00

What Do We Do Next?

00
00

Contraction

00
00

Covariant Derivatives

00
00

The Second Bianchi Identity

00
00

Perturbative GR

GRCalcs.nb

What is xAct?
This is a very complete system for doing tensor analysis in the Mathematica system.
All you need do is open the system:
<< xAct`xTensor`
-----------------------------------------------------------Package xAct`xPerm`

version 1.2.2, {2014, 9, 28}

CopyRight (C) 2003-2014, Jose M. Martin-Garcia, under the General Public License.
Connecting to external MinGW executable...
Connection established.
-----------------------------------------------------------Package xAct`xTensor`

version 1.1.1, {2014, 9, 28}

CopyRight (C) 2002-2014, Jose M. Martin-Garcia, under the General Public License.
-----------------------------------------------------------These packages come with ABSOLUTELY NO WARRANTY; for details type
Disclaimer[]. This is free software, and you are welcome to redistribute
it under certain conditions. See the General Public License for details.
------------------------------------------------------------

GRCalcs.nb

What Do We Do Next?
Now that we have started things up, there are some things we need to do.
1. We need to define the underlying manifold we are working in. We do this with the
DefManifold command: DefManifold[M, dim, {a, b, c,...}] defines M to be an ndimensional
differentiable manifold with dimension dim (a positive integer or a constant symbol) and
tensor abstract indices a, b, c, ... . DefManifold[M, {M1, ..., Mm}, {a, b, c,...}] defines M to be the
product manifold of previously defined manifolds M1 ... Mm. For backward compatibility dim
can be a list of positive integers, whose length is interpreted as the dimension of the defined
manifold. Here we define a fourdimensional manifold having the indices
a, b, c, d, e, f , g, h, i, j, k, l:
DefManifold[M, 4, {a, b, c, d, e, f, g, h, i, j, k, l}]
** DefManifold: Defining manifold M.
** DefVBundle: Defining vbundle TangentM.

In defining the manifold, we have also defined the vector bundle called TangentM,
: TM M. This is where our tensors will be.

GRCalcs.nb

2. We need to define the metric using the DefMetric command: DefMetric[signdet, metric[a,b],
covd, covdsymbol] defines metric[a, b] with signdet 1 or 1 and associates the covariant
derivative covd[a] to it. Note that we have the convention [a] has a as the subscript, and [a]
has it as the superscript.
DefMetric[- 1, metric[- i, - j], cd, {";", ""}, PrintAs "g"]
** DefTensor: Defining symmetric metric tensor metric[-i, -j].
** DefTensor: Defining antisymmetric tensor epsilonmetric[-a, -b, -c, -d].
** DefTensor: Defining tetrametric Tetrametric[-a, -b, -c, -d].
** DefTensor: Defining tetrametric Tetrametric[-a, -b, -c, -d].
** DefCovD: Defining covariant derivative cd[-i].
** DefTensor: Defining vanishing torsion tensor Torsioncd[a, -b, -c].
** DefTensor: Defining symmetric Christoffel tensor Christoffelcd[a, -b, -c].
** DefTensor: Defining Riemann tensor Riemanncd[-a, -b, -c, -d].
** DefTensor: Defining symmetric Ricci tensor Riccicd[-a, -b].
** DefCovD:

Contractions of Riemann automatically replaced by Ricci.

** DefTensor: Defining Ricci scalar RicciScalarcd[].


** DefCovD:

Contractions of Ricci automatically replaced by RicciScalar.

** DefTensor: Defining symmetric Einstein tensor Einsteincd[-a, -b].


** DefTensor: Defining Weyl tensor Weylcd[-a, -b, -c, -d].
** DefTensor: Defining symmetric TFRicci tensor TFRiccicd[-a, -b].
** DefTensor: Defining Kretschmann scalar Kretschmanncd[].
** DefCovD:

Computing RiemannToWeylRules for dim 4

** DefCovD:

Computing RicciToTFRicci for dim 4

** DefCovD:

Computing RicciToEinsteinRules for dim 4

** DefTensor: Defining weight +2 density Detmetric[]. Determinant.

GRCalcs.nb

3. We can define tensors using the DefTensor command: DefTensor[T[a, b, c, ...], {M1, ...}]
defines T to be a tensor field on manifolds and parameters M1,... and the base manifolds
associated to the vector bundles of its indices. DefTensor[T[a, b, c, ...], {M1, ...}, symmetry]
defines a tensor with symmetry given by a generating set or strong generating set of the
associated permutation group. In fact we can define any order of tensor just by specifying the
indices. A scalar has no indices so we can define the scalar
DefTensor[s[], M]
** DefTensor: Defining tensor s[].

s
s

a tangent vector
DefTensor[tv[i], M]
** DefTensor: Defining tensor tv[i].

tv[i]
tv i

GRCalcs.nb

a covector
DefTensor[cv[- i], M]
** DefTensor: Defining tensor cv[-i].

cv[- i]
cv i

and so on.

GRCalcs.nb

We can define tensors by their symmetries or antisymmetries, too. Here we define the tensor
Tij that is antisymmetric:
DefTensor[T[- i, - j], M, Antisymmetric[{- i, - j}]];
** DefTensor: Defining tensor T[-i, -j].

T[- i, - j]

Tij
T[- j, - i]
Tji

To make this work, since Mathematica does not enforce our symmetry rules, we need to make
it do so by using the ToCanonical command. Lets try it again
T[- j, - i] // ToCanonical
- Tij

We can add two such tensors in a way that gives us a 0 result,


T[- i, - j] + T[- j, - i]
Tij + Tji
T[- i, - j] + T[- j, - i] // ToCanonical
0

GRCalcs.nb

Contraction
We can do some operations. Lets say we have the Riemann tensor Rijkl and we want to
contract it using the metric gik. we use the ContractMetric command,
metric[i, k] Riemanncd[- i, - j, - k, - l] // ContractMetric
R[] j l

Mathematica also understands that this is the Ricci tensor, Rjl,


metric[i, k] Riemanncd[- i, - j, - k, - l] // ContractMetric // InputForm
Riccicd[-j, -l]

Contracting it again gives us the Ricci scalar,


metric[j, l] Riccicd[- j, - l] // ContractMetric // InputForm
RicciScalarcd[]

10

GRCalcs.nb

Covariant Derivatives
The covariant derivative of our tensor, i Tjl, is input
cd[- i][T[- j, - l]]
i T j l

If we have multiple covariant derivatives, we would enter them as follows, where @ is the
Map command:
cd[- a] @ cd[- b] @ cd[- c] @ T[- d, - e] // ToCanonical
abc T d e

To evaluate this we use the command SortCovDs


cd[- a] @ cd[- b] @ cd[- c] @ T[- d, - e] // ToCanonical // SortCovDs
- R[] c b e l$1032 a T d l$1032 - R[] c b d l$1032 a T l$1032 e l$1030
- T d l$1030 b R[] c a e l$1030 - R[] c a e l$1030 b T d l$1030 T l$1030 e b R[] c a d

R[] c a d l$1030 b T l$1030 e - R[] b a e l$1028 c T d l$1028 - R[] b a d l$1028 c T l$1028 e +


cba T d e - R[] b a c l$1028 l$1028 T d e - R[] c b a l$1032 l$1032 T d e

GRCalcs.nb

11

This is correct, but too difficult to interpret, we add the command ScreenDollarIndices to
put it into a lnaguage we can read instead of just the computer reading it
cd[- a] @ cd[- b] @ cd[- c] @ T[- d, - e] // ToCanonical // SortCovDs // ScreenDollarIndices
- R[] c b e f a T d f - R[] c b d f a T f e - T f e b R[] c a d f f
f
f
f
T d f b R[] c a e - R[] c a e b T d f - R[] c a d b T f e - R[] b a e c T d f -

R[] b a d f c T f e + cba T d e - R[] b a c f f T d e - R[] c b a f f T d e

Instead of having to write all of this all of the time we make a sessionwide command
$PrePrint = ScreenDollarIndices;
cd[- a] @ cd[- b] @ cd[- c] @ T[- d, - e] // ToCanonical // SortCovDs
- R[] c b e f a T d f - R[] c b d f a T f e - T f e b R[] c a d f f
f
f
f
T d f b R[] c a e - R[] c a e b T d f - R[] c a d b T f e - R[] b a e c T d f -

R[] b a d f c T f e + cba T d e - R[] b a c f f T d e - R[] c b a f f T d e

12

GRCalcs.nb

The Second Bianchi Identity


Here we seek to reproduce the Second Bianchi identity. We redefine our covariant
derivative
DefCovD[CD[- a], {";", ""}]
** DefCovD: Defining covariant derivative CD[-a].
** DefTensor: Defining vanishing torsion tensor TorsionCD[a, -b, -c].
** DefTensor: Defining symmetric Christoffel tensor ChristoffelCD[a, -b, -c].
** DefTensor: Defining Riemann tensor
RiemannCD[-a, -b, -c, d]. Antisymmetric only in the first pair.
** DefTensor: Defining non-symmetric Ricci tensor RicciCD[-a, -b].
** DefCovD:

Contractions of Riemann automatically replaced by Ricci.

We begin by establishing a term


term1 = Antisymmetrize[CD[- e][ RiemannCD[- c, - d, - b, a] ], {- c, - d, - e} ]
1
6

c R[] d e b a - c R[] e d b a - d R[] c e b a + d R[] e c b a + e R[] c d b a - e R[] d c b a

We sum these,
bianchi2 = 3 term1 // ToCanonical
c R[] d e b a - d R[] c e b a + e R[] c d b a

GRCalcs.nb

We expand the covariant derivatives in Christoffel symbols:


exp1 = bianchi2 // CovDToChristoffel
[] a e f R[] c d b f - [] f e b R[] c d f a - [] a d f R[] c e b f +
[] f d b R[] c e f a + [] f d e R[] c f b a - [] f e d R[] c f b a +
[] a c f R[] d e b f - [] f c b R[] d e f a - [] f c e R[] d f b a - [] f e c R[] f d b a [] f c d R[] f e b a + [] f d c R[] f e b a + c R[] d e b a - d R[] c e b a + e R[] c d b a

13

14

GRCalcs.nb

We expand the Riemann tensors in Christoffel symbols


exp2 = exp1 // RiemannToChristoffel
- [] f e b c [] a d f + [] f d b c [] a e f + [] a e f c [] f d b [] a d f c [] f e b - cd [] a e b + ce [] a d b + [] f e b d [] a c f [] f e b [] a d g []

g
cf

- [] a c g []

g
df

- c [] a d f + d [] a c f -

db

- c [] f d b + d [] f c b +

[] f c b d [] a e f - [] a e f d [] f c b +
[] a e f [] f d g []

g
cb

- [] f c g []

[] a c f d [] f e b + dc [] a e b - de [] a c b - [] f d b e [] a c f +
[] f d b [] a e g []

g
cf

- [] a c g []

g
ef

- c [] a e f + e [] a c f +

[] f c b e [] a d f - [] f c b
[] a e g []

g
df

- [] a d g []

[] a d f [] f e g []

g
ef

- d [] a e f + e [] a d f + [] a d f e [] f c b -

- [] f c g []

cb

- [] f d g []

db

eb

- c [] f e b + e [] f c b -

eb

- d [] f e b + e [] f d b - ec [] a d b +

[] a c f e [] f d b +
[] a c f [] f e g []

ed [] a c b + [] f d e [] a f g []
[] f e d [] a f g []

a
c b - [] c g
g
[] f e c - [] a f g [] d b + [] a d g
g
[] f c e [] a f g [] d b - [] a d g
g
[] f c d - [] a f g [] e b + [] a e g
g
[] f d c - [] a f g [] e b + [] a e g

cb

- [] a c g []

g
fb

- c [] a f b + f [] a c b -

a
a
f b - c [] f b + f [] c b g
[] f b + d [] a f b - f [] a d b g
[] f b - d [] a f b + f [] a d b g
[] f b + e [] a f b - f [] a e b +

[]

[]

g
fb

+ e [] a f b - f [] a e b

GRCalcs.nb

We canonicalize this to enforce symmetries and antisymmetries,


exp3 = exp2 // ToCanonical
0

Which is what we expected.


cR[] a b de + dR[] a bec + eR[] a bcd = 0

15

16

GRCalcs.nb

Perturbative GR
We begin this by opening the perturbative package:
<< xAct`xPert
Get::noopen : Cannot open xAct`xPert.

$Failed

GRCalcs.nb

17

We must first establish our metric perturbation, this is because the metric is a vacuum
metric; thus all small perturbations are gravitational waves. We define the metric perturba
tion using the DefMetricPerturbation[the existing metric, name of the perturbation, pertur
bation parameter]
DefMetricPerturbation[metric, pert, ]
** DefParameter: Defining parameter .
** DefTensor: Defining tensor pert[LI[order], -a, -b].

We can tell Mathematica to write the perturbation using the traditional notation h,
PrintAs[pert] ^= "h";

A secondorder perturbation in the metric is then written


pert[LI[2], - a, - b]
h

ab

So the firstorder perturbation of the metric gab is


Perturbation[metric[- a, - b], 1]
h

ab

18

GRCalcs.nb

for gab we have,


Perturbation[metric[a, b], 1]
g a b

What? What is ? It turns out that Mathematica does not know how to perform a perturba
tion on the inverse metric. We need to use the ExpandPerturbation command,
Perturbation[metric[a, b], 1] // ExpandPerturbation
- h1ab

This is not too impressive, lets try a fourthorder perturbation


Perturbation[metric[a, b], 4] // ExpandPerturbation
24 h 1 a c h 1 c d h 1 d e h 1 e b - 12 h 1 c d h 1 d b h 2 a c + 6 h 2 a c h 2 c b 12 h 1 a c h 1 d b h 2 c d - 12 h 1 a c h 1 c d h 2 d b + 4 h 1 c b h 3 a c + 4 h 1 a c h 3 c b - h 4 a b

Lets examine the thirdorder perturbed metric


Perturbed[metric[- a, - b], 3]
gab + h1ab +

1
2

2 h 2 a b +

1
6

3 h 3 a b

GRCalcs.nb

19

and the inverse metric


Perturbed[metric[a, b], 3] // ExpandPerturbation
gab - h1ab +
1
6

1
2

2 2 h 1 a c h 1 c b - h 2 a b +

3 - 6 h 1 a c h 1 c d h 1 d b + 3 h 1 f b h 2 a f + 3 h 1 a e h 2 e b - h 3 a b

Jolyon Bloomfield [5] produced a method of extracting only the firstorder terms of the
expansion, since is assumed to be small, where we can write the metric as the sum of a
linearized metric and a perturbed metric, gab = g0ab + hab we adapt it for our use
firstorderonly = pert[LI[n_], __] 0 /; n > 1;
Perturbed[metric[- a, - b], 3] /. firstorderonly
gab + h1ab

Given an action we can derive an equation of motion. First we need to establish our scalar
field,
DefTensor[sf[], M, PrintAs ""]
** DefTensor: Defining tensor sf[].

20

GRCalcs.nb

We now define the perturbations of the scalar field,


DefTensorPerturbation[pertsf[LI[order]], sf[], M, PrintAs ""]
** DefTensor: Defining tensor pertsf[LI[order]].

We now define the potential and the Planck mass,


DefScalarFunction[V]
DefConstantSymbolmassP, PrintAs "mp"
** DefScalarFunction : Defining scalar function V.
** DefConstantSymbol : Defining constant symbol massP.

Now we need to construct the Lagrangian


L = Sqrt[- Detmetric[]] massP2 2 RicciScalarcd[] - 1 / 2 cd[- b][sf[]] cd[b][sf[]] - V[sf[]]

-g

mp2 R[]
2

- V[] -

1
2

b b

GRCalcs.nb

We vary the fields


varL = L // Perturbation
-

mp2 R[]

]
[g

-g

2
1
2

- V[] -

mp2 [R[]] +

1
2

1
2

b b

-g

- b b - 1 ;b b - 1 V[]

We expand this
varL = L // Perturbation // ExpandPerturbation
-

1 a

g h a
gac
1
2

mp2 R[]
2
1
2

- V[] -

1
2

b b

- h 1 d d ;c ;a - h 1 d c ;d ;a + h

2
1

-g
;d

cd

;a

1
2

-g

1
2

mp2 - h 1 a c R[] a c +

h 1 d c ;a ;d + h 1 d a ;c ;d - h

- 1 ;b b - b g b e 1 ;e - h 1 b e e - 1 V[]

;d
ca

;d

21

22

GRCalcs.nb

We perform the metric contractions


varL = L // Perturbation // ExpandPerturbation // ContractMetric
1

-g
h 1 a b R[] a b + mp2
2
4
1
1

1
b
;a

mp 2 - g
h b ;a - mp2 - g
4
4
1
1

-g
h 1 b a a b + mp2 - g
2
2
1
1

1
- g b 1 ;b -g
;b
2
2
? RicciTo*

mp 2

-g
-g
h 1 a a R[] h 1 a a V[] 2
1

1 a ;b
1ba

mp 2 - g
h
h b ;a +
;b ;a +
4
1

1 a ;b
1ba

mp 2 - g
h
h a ;b ;a ;b 4
1

b - g h 1 a a b b - - g
1 V[]
4

xAct`xTensor`

RicciToEinstein

RicciToTFRicci

RicciToEinstein[expr, covd] expands expr expressing all Ricci tensors of covd in terms of the Einstein and RicciScalar tensors
of covd. If the second argument is a list of covariant derivatives the command is applied sequentially on expr. RicciToEinstein[expr] expands all Ricci tensors.

Then we enforce the symmetries


varL = L // Perturbation // ExpandPerturbation // ContractMetric // ToCanonical
-

1b
-g
h 1 b a R[] b a + mp2 - g h b R[] 2
4
1
1
1

1 b ;a
1ba

1b
-g
h b V[] - mp2 - g h b ;a + mp2 - g h
;b ;a 2
2
2
1

1 ;b + 1 - g

1
-g
-g
h b a a b h 1 a a b b - - g 1 V[]
b
2
4
mp 2

GRCalcs.nb

The scalar equation of motion is then found by taking the variational derivatives of the
scalar field and set them equal to 0
0 == VarD[pertsf[LI[1]], cd][varL] / Sqrt[- Detmetric[]]
0

-g

a 1
-g
1
a

V[]
-g

we enforce the Kronecker delta


0 == VarD[pertsf[LI[1]], cd][varL] / Sqrt[- Detmetric[]] /. delta[- LI[1], LI[1]] 1
0

a -g
a

V[]
-g

-g

We canonicalize it
0 == VarD[pertsf[LI[1]], cd][varL] / Sqrt[- Detmetric[]] /.
delta[- LI[1], LI[1]] 1 // ToCanonical
0 aa - V[]

There we have it.

23

24

GRCalcs.nb

We can get the tensor equation of motion,


vartf = 2 (- VarD[pert[LI[1], a, b], cd][varL] / Sqrt[- Detmetric[]])
1

-g

1
2

1
2

mp 2 1 1

R[]
-g
mp 2 1 1
ab 4

g
1
-g
1
a b V[] +
4

g
-g
a b R[] +

g
1
c
-g
1
a b c 2

g
c
d
-g
ac gbd

This is a mess, so we begin enforcing the Kronecker deltas


vartf =
2 (- VarD[pert[LI[1], a, b], cd][varL] / Sqrt[- Detmetric[]] /. delta[- LI[1], LI[1]] 1)
1

-g

2
1
2

1
2

mp 2

R[]
-g
mp 2
ab 4

g
-g
a b V[] +
4

g
-g
a b R[] +

g
c
-g
a b c 2

g
c
d
-g
ac gbd

GRCalcs.nb

25

We now expand by expressing all Ricci tensors of covariant derivatives in terms of Einstein
tensors and Ricci scalars
vartf =
2 (- VarD[pert[LI[1], a, b], cd][varL] / Sqrt[- Detmetric[]] /. delta[- LI[1], LI[1]] 1 //
SeparateMetric[metric] // RicciToEinstein)
1

-g

2 1
2

1
4

mp 2

g
-g
mp 2
a b R[] +
2

g
-g
a b V[] 2

-g

+ 1
-g
a
b
4

G[] a b +

1
2

g b a R[] +

g
g c d c d
-g
ab

We expand this
vartf =
2 (- VarD[pert[LI[1], a, b], cd][varL] / Sqrt[- Detmetric[]] /. delta[- LI[1], LI[1]] 1 //
SeparateMetric[metric] // RicciToEinstein) // Expand
mp2 G[] a b -

1
2

mp2 g a b R[] +

1
2

mp2 g b a R[] + g a b V[] - a b +

1
2

g a b g c d c d

26

GRCalcs.nb

Then we enforce the symmetries,


vartf =
2 (- VarD[pert[LI[1], a, b], cd][varL] / Sqrt[- Detmetric[]] /. delta[- LI[1], LI[1]] 1 //
SeparateMetric[metric] // RicciToEinstein) //
Expand // ContractMetric // ToCanonical
mp2 G[] a b + g a b V[] - a b +

1
2

g a b c c

We set this equal to 0,


0 vartf
0 mp2 G[] a b + g a b V[] - a b +

1
2

g a b c c

Here we get the conservation of energy


eterm = IndexCollect[cd[a] @ vartf // ToCanonical, CD[- b][sf[]]] // Simplify
b (- aa + V[])

GRCalcs.nb

then
0 eterm
0 b (- aa + V[])

this is degenerate with the scalar equation of motion


0 aa - V[]

27

28

GRCalcs.nb

Bibliography
[1] M. Nakahara, (2003), Geometry, Topology, and Physics, 2nd Edition, Taylor and Francis
Group.
[2] Theodore Frankel, (2012), The Geometry of Physics, 3rd Edition, Cambridge University
Press
[3] Jose M. MartinGarcia, (2009), xAct Intro
[4] B. F. Schutz, (1984), The Use of Perturbation and Approximation Methods in General
Relativity. In: Relativistic Astrophysics and Cosmology: Proceedings of the GIFT Interna
tional Seminar on Theoretical Physics, (Eds.) Fustero, Xavier; Verdaguer, Enric; Singapore:
World Scientific 3598 (1984)
[5] Jolyon Bloomfield, (2013), xAct Tutorial
xAct can be found at the website: http://www.xact.es/index.html

GRCalcs.nb

Thank You for Attending!

29

You might also like