0% found this document useful (0 votes)
5 views

U02_ComputerLab_CurvatureWithMathematica_Mathematica

This document describes a Mathematica notebook for calculating various components related to curvature and geodesic equations in general relativity, based on James Hartle's work. It includes the computation of metrics, Christoffel symbols, Riemann tensor, Ricci tensor, scalar curvature, and the Einstein tensor, using a specified Friedmann metric. The notebook is intended for a course at the National Technical University of Athens and requires user input for the metric tensor components.

Uploaded by

Cristin Lee
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

U02_ComputerLab_CurvatureWithMathematica_Mathematica

This document describes a Mathematica notebook for calculating various components related to curvature and geodesic equations in general relativity, based on James Hartle's work. It includes the computation of metrics, Christoffel symbols, Riemann tensor, Ricci tensor, scalar curvature, and the Einstein tensor, using a specified Friedmann metric. The notebook is intended for a course at the National Technical University of Athens and requires user input for the metric tensor components.

Uploaded by

Cristin Lee
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Curvature and the geodesic equations

The code in this notebook is based on James Hartle’s Mathematica programs written as companions to
his book “Gravity: An Introduction to Einstein’s General Relativity”, available from the Book’s site:
http://web.physics.ucsb.edu/~gravitybook/mathematica.html
The original program was written by Leonard Parker, University of Wisconsin, Milwaukee (see the
Acknowledgement section in the end of this notebook). The code in this notebook is a modification of
the original program, adapted for the needs of the course “General Relativity and Cosmology” offered
at the National Technical University of Athens, by Konstantinos Anagnostopoulos (
http://physics.ntua.gr/konstant ).The site of the course for the Spring 2023 can be found at
http://physics.ntua.gr/konstant/GR .

This is the Mathematica notebook Curvature and the Einstein Equation available from the book website.
From a given metric gαβ , it computes the components of the following: the inverse metric, gλσ , the
Christoffel symbols or affine connection,
Γλ μν = 2 gλσ ∂μ gσν + ∂ν gσμ - ∂σ gμν ,
1

( ∂α stands for the partial derivative ∂ /∂ x α ), the Riemann tensor,


Rλ μνσ = ∂ν Γλ μσ - ∂σ Γλ μν + Γλ ην Γη μσ - Γλ ησ Γη μν ,
the Ricci tensor
Rμν = Rλ μλν ,
the scalar curvature,
R = gμν Rμν ,
and the Einstein tensor,
Gμν = Rμν - 12 gμν R.

We also compute:
Rμνρσ , Rμνρσ , R2 = Rμνρσ Rμνρσ , the Weyl Tensor
ℭρσμν = Rρσμν - gρ[μ Rν] σ - gσ[μ Rν] ρ  +
2 2
n-2 (n-1) (n-2)
gρ[μ gν] σ R,
and the geodesic equations.
You must input the covariant components of the metric tensor gμν by editing the relevant input line in
this Mathematica notebook. You may also wish to change the names of the coordinates. Only the
nonzero components of the above quantities are displayed as the output. All the components
computed are in the coordinate basis in which the metric was specified.

Initialization:
First clear any values that may already have been assigned to the names of the various objects to be
calculated. The names of the coordinates that you will use are also cleared. The name of the
2

coordinates must be defined (the list coord), and then the dimension of the manifold n is set.

Note:
It is important not to use the symbols, i, j, k, l, s, R, G, ℭ, τ , Γ, or n as constants or coordinates in the
metric that you specify above. The reason is that the first five of those symbols are used as summation
or table indices in the calculations done below, and n is the dimension of the space. The rest are also
used for displaying results in the program.

Clear[coord, metric, inversemetric, affine, riemann, lriemann, uriemann,


ricci, scalar, einstein, weyl, geodesic, R, G, τ , i, j, k, l, s];
Clear[r, θ, ϕ, t, χ , a, m];

(*----------------------------------------------------------------------------*)
(* This is what you need to set + the metric below: *)
coord = {t, χ , θ, ϕ};
n = Length[coord];
(*----------------------------------------------------------------------------*)
Print["The Manifold has dimension n= ",
n, "\nCoordinate system: ", coord]

The Manifold has dimension n= 4


Coordinate system: {t, χ , θ, ϕ}

Defining the metric: The Friedmann metric


Input the metric as a list of lists, i.e., as a matrix. You can input the components of any metric here, but
you must specify them as explicit functions of the coordinates.

Compute for the metric:


ds2 = -dt2 + a(t)2 dχ2 + sin2(χ) dθ2 + sin2(θ) dϕ2 
3

In[  ]:=

(*----------------------------------------------------------------------------*)
metric = 
{- 1, 0 ,0 , 0},
0, a[t] , 0 2
, 0,
0, 0 2
, a[t] Sin[χ] , 2
0,
0, 0 ,0 , a[t] Sin[χ] Sin[θ] ;
2 2 2

(*----------------------------------------------------------------------------*)
metric // MatrixForm
Out[  ]//MatrixForm=

-1 0 0 0
2
0 a[t] 0 0
2 2
0 0 a[t] Sin[χ] 0
0 0 0 a[t]2 Sin[θ]2 Sin[χ]2

Calculating the inverse metric:


The inverse metric is obtained through matrix inversion.

In[  ]:= inversemetric = FullSimplify[Inverse[metric]];


inversemetric // MatrixForm
Out[  ]//MatrixForm=

-1 0 0 0
1
0 0 0
a[t]2
Csc[χ]2
0 0 0
a[t]2
Cscθ Csc[χ]2
2
0 0 0
a[t]2

Let’s see how we can compute the derivatives:

In[  ]:= metric〚2, 2〛

Out[  ]= a[t]2

In[  ]:= coord〚1〛

Out[  ]= t

In[  ]:= D[metric〚2, 2〛, t]

Out[  ]= 2 a[t] a′ [t]

Use the list of coordinates to specify the variable w.r.t. which we differentiate:
4

In[  ]:= D[metric〚2, 2〛, coord〚1〛]

Out[  ]= 2 a[t] a′ [t]

In[  ]:= Table[D[metric〚i, i〛, coord〚1〛], {i, n}]

Out[  ]= 0, 2 a[t] a′ [t], 2 a[t] Sin[χ]2 a′ [t], 2 a[t] Sin[θ]2 Sin[χ]2 a′ [t]

In[  ]:= Table[D[metric〚i, i〛, coord〚j〛], {i, n}, {j, n}]

Out[  ]= {0, 0, 0, 0}, {2 a[t] a′ [t], 0, 0, 0}, 2 a[t] Sin[χ]2 a′ [t], 2 a[t]2 Cos[χ] Sin[χ], 0, 0,
2 a[t] Sin[θ]2 Sin[χ]2 a′ [t], 2 a[t]2 Cos[χ] Sin[θ]2 Sin[χ], 2 a[t]2 Cos[θ] Sin[θ] Sin[χ]2, 0

In[  ]:= ∂t metric〚2, 2〛

Out[  ]= 2 a[t] a′ [t]

In[  ]:= ∂coord〚1〛 metric〚2, 2〛

Out[  ]= 2 a[t] a′ [t]

Calculating the Christoffel symbols:


The calculation of the components of the Christoffel symbols is done by transcribing the definition
given earlier into the notation of Mathematica and using the Mathematica functions D for taking partial
derivatives, Sum for summing over repeated indices, Table for forming a list of components, and
Simplify for simplifying the result.

The delayed definition performs a calculation on demand and caches the result:
E.g.: pi2:=pi2=N[Pi^2,50];
fib[1]=fib[2]=1;
fib[n_]:=fib[n]=fib[n-1]+fib[n-2]
fib[6] → 8
Definition[fib]
fib[1] = 1
fib[2] = 1
fib[3] = 2
fib[4] = 3
fib[5] = 5
fib[6] = 8
fib[n_] := fib[n] = fib[n - 1] + fib[n - 2]
5

In[  ]:= affine := affine = FullSimplifyTable


(1 / 2) * Sum
(* gis  ∂kgsj +
∂jgsk - ∂sgjk *)
(inversemetric〚i, s〛) * (D[metric〚s, j〛, coord〚k〛 ] +
D[metric〚s, k〛, coord〚j〛 ] - D[metric〚j, k〛, coord〚s〛 ]),
{s, 1, n},
{i, 1, n}, {j, 1, n}, {k, 1, n} ;

Now let’s see how to display the nontrivial results. First let’s look what affine consists of:

In[  ]:= affine

Out[  ]= {0, 0, 0, 0}, {0, a[t] a′ [t], 0, 0}, 0, 0, a[t] Sin[χ]2 a′ [t], 0,

a′ [t] a′ [t]
0, 0, 0, a[t] Sin[θ]2 Sin[χ]2 a′ [t], 0, , 0, 0,  , 0, 0, 0,
a[t] a[t]
{0, 0, - Cos[χ] Sin[χ], 0}, 0, 0, 0, - Cos[χ] Sin[θ]2 Sin[χ],

a′ [t] a′ [t]
0, 0, , 0, {0, 0, Cot[χ], 0},  , Cot[χ], 0, 0, {0, 0, 0, - Cos[θ] Sin[θ]},
a[t] a[t]
a′ [t] a′ [t]
0, 0, 0, , {0, 0, 0, Cot[χ]}, {0, 0, 0, Cot[θ]},  , Cot[χ], Cot[θ], 0
a[t] a[t]

We can look at Γμ νρ as matrices (Γμ )νρ :

In[  ]:= Table[affine〚i〛 // MatrixForm, {i, 1, n}]

0 0 0 0
0 a[t] a′ [t] 0 0
Out[  ]=  ,
0 0 a[t] Sin[χ]2 a′ [t] 0
0 0 0 a[t] Sin[θ]2 Sin[χ]2 a′ [t]

a′ [t]
0 a[t]
0 0

a [t]
a[t]
0 0 0 ,
0 0 - Cos[χ] Sin[χ] 0
0 0 0 - Cos[χ] Sin[θ]2 Sin[χ]

a′ [t] a′ [t]
0 0 a[t]
0 0 0 0 a[t]
0 0 Cot[χ] 0 0 0 0 Cot[χ]
a′ [t]
, 
Cot[χ] 0 0 0 0 0 Cot[θ]
a[t] a′ [t]
0 0 0 - Cos[θ] Sin[θ] a[t]
Cot[χ] Cot[θ] 0
6

Many zeroes... We also need to associate the nonzero values with the indices μ , ν , ρ . Let’s make pairs of
values and Γμ νρ symbols:
We use the functions Superscript[Γ, i] → Γi , and Subscript[A, j, k] → Aj,k . The function
UnsameQ[<expression>,0] evaluates to True, when <expression> is not the same as 0.
If[<condition>,<value>] returns <value> when <condition> is True and Null when it is False:

In[  ]:= listaffine := Table[


If[
UnsameQ[affine〚i, j, k〛, 0],
{Subscript[Superscript[Γ, i], j, k], affine〚i, j, k〛}
],
{i, 1, n}, {j, 1, n}, {k, 1, j}];

Now let’s see what listaffine consists of:

In[  ]:= listaffine

Out[  ]= {Null}, Null, Γ12,2, a[t] a′ [t], Null, Null, Γ13,3, a[t] Sin[χ]2 a′ [t],

a′ [t]
Null, Null, Null, Γ14,4, a[t] Sin[θ]2 Sin[χ]2 a′ [t], {Null}, Γ22,1, , Null,
a[t]
Null, Null, Γ23,3, - Cos[χ] Sin[χ], Null, Null, Null, Γ24,4, - Cos[χ] Sin[θ]2 Sin[χ],

a′ [t]
{Null}, {Null, Null}, Γ33,1, , Γ33,2, Cot[χ], Null,
a[t]
Null, Null, Null, Γ34,4, - Cos[θ] Sin[θ], {Null}, {Null, Null},

a′ [t]
{Null, Null, Null}, Γ44,1, , Γ44,2, Cot[χ], Γ44,3, Cot[θ], Null
a[t]

Now we want to get rid of the Nulls: First Flatten the list:

In[  ]:= Flatten[listaffine]

Out[  ]= Null, Null, Γ12,2, a[t] a′ [t], Null, Null, Γ13,3, a[t] Sin[χ]2 a′ [t], Null, Null,

a′ [t]
Null, Γ14,4, a[t] Sin[θ]2 Sin[χ]2 a′ [t], Null, Γ22,1, , Null, Null, Null, Γ23,3,
a[t]
- Cos[χ] Sin[χ], Null, Null, Null, Γ24,4, - Cos[χ] Sin[θ]2 Sin[χ], Null, Null, Null,
a′ [t]
Γ33,1, , Γ33,2, Cot[χ], Null, Null, Null, Null, Γ34,4, - Cos[θ] Sin[θ], Null,
a[t]
a′ [t]
Null, Null, Null, Null, Null, Γ44,1, , Γ44,2, Cot[χ], Γ44,3, Cot[θ], Null
a[t]

Then get rid of the Nulls, using the DelteCases function:


7

In[  ]:= DeleteCases[Flatten[listaffine], Null]

Out[  ]= Γ12,2, a[t] a′ [t], Γ13,3, a[t] Sin[χ]2 a′ [t], Γ14,4, a[t] Sin[θ]2 Sin[χ]2 a′ [t],

a′ [t] a′ [t]
Γ22,1, , Γ23,3, - Cos[χ] Sin[χ], Γ24,4, - Cos[χ] Sin[θ]2 Sin[χ], Γ33,1, ,
a[t] a[t]
a′ [t]
Γ33,2, Cot[χ], Γ34,4, - Cos[θ] Sin[θ], Γ44,1, , Γ44,2, Cot[χ], Γ44,3, Cot[θ]
a[t]

Then, reconstruct pairs of {Symbol,Values} using the Partition function:

In[  ]:= Partition[DeleteCases[Flatten[listaffine], Null], 2]

Out[  ]= Γ12,2, a[t] a′ [t], Γ13,3, a[t] Sin[χ]2 a′ [t], Γ14,4, a[t] Sin[θ]2 Sin[χ]2 a′ [t],

a′ [t] a′ [t]
Γ22,1, , Γ23,3, - Cos[χ] Sin[χ], Γ24,4, - Cos[χ] Sin[θ]2 Sin[χ], Γ33,1, ,
a[t] a[t]
a′ [t]
Γ33,2, Cot[χ], Γ34,4, - Cos[θ] Sin[θ], Γ44,1, , Γ44,2, Cot[χ], Γ44,3, Cot[θ]
a[t]

Yeah, we are ready, now let’s make a pretty display:

In[  ]:= Partition[DeleteCases[Flatten[listaffine], Null], 2] // TableForm


Out[  ]//TableForm=

Γ12,2 a[t] a′ [t]


Γ13,3 a[t] Sin[χ]2 a′ [t]
Γ14,4 a[t] Sin[θ]2 Sin[χ]2 a′ [t]
a′ [t]
Γ22,1
a[t]

Γ23,3 - Cos[χ] Sin[χ]


Γ 2
4,4 - Cos[χ] Sin[θ]2 Sin[χ]
a′ [t]
Γ33,1
a[t]

Γ33,2 Cot[χ]
Γ34,4 - Cos[θ] Sin[θ]
a′ [t]
Γ44,1
a[t]
Γ44,2 Cot[χ]
Γ 4
4,3 Cot[θ]

Or use more spacing for more comfortable reading: TableSpacing → {yspaces, xspaces} adds spaces in
rows+columns
8

In[  ]:= TableForm[Partition[DeleteCases[Flatten[listaffine], Null], 2], TableSpacing → {4, 8}]


Out[  ]//TableForm=

Γ12,2 a[t] a′ [t]

Γ13,3 a[t] Sin[χ]2 a′ [t]

Γ14,4 a[t] Sin[θ]2 Sin[χ]2 a′ [t]

a′ [t]
Γ22,1
a[t]

Γ23,3 - Cos[χ] Sin[χ]

Γ24,4 - Cos[χ] Sin[θ]2 Sin[χ]

a′ [t]
Γ33,1
a[t]

Γ33,2 Cot[χ]

Γ34,4 - Cos[θ] Sin[θ]

a′ [t]
Γ44,1
a[t]

Γ44,2 Cot[χ]

Γ44,3 Cot[θ]

Calculating and displaying the Riemann tensor:


The components of the Riemann tensor, Rλ μνσ , are calculated using the definition given
above.
Ri jkl = ∂k Γi lj - ∂l Γi kj + Γi km Γmlj - Γi lm Γmkj = Γi lj ; k - Γi kj ; l + Γi ks Γslj - Γi ls Γskj
9

In[  ]:= riemann := riemann = FullSimplifyTable


(* Rijkl= ∂kΓilj - ∂lΓikj*)
D[ affine〚i, l, j〛, coord〚k〛 ] - D[affine〚i, k, j〛, coord〚l〛 ]+
(* Γiks Γslj - Γils Γskj *)
Sum[affine〚i, k, s〛 affine〚s, l, j〛 - affine〚i, l, s〛 affine〚s, k, j〛 ,
{s, 1, n}],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n} ;
listriemann := Table[
If[
UnsameQ[riemann〚i, j, k, l〛, 0],
{Subscript[Superscript[R, i], j, k, l], riemann〚i, j, k, l〛}
],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, k - 1}];
TableForm[Partition[DeleteCases[Flatten[listriemann], Null], 2],
TableSpacing → {2, 2}]
Out[  ]//TableForm=

R12,2,1 - a[t] a′′ [t]

R13,3,1 - a[t] Sin[χ]2 a′′ [t]

R14,4,1 - a[t] Sin[θ]2 Sin[χ]2 a′′ [t]


a′′ [t]
R21,2,1 -
a[t]

R23,3,2 - Sin[χ]2 1 + a′ [t]2

R24,4,2 - Sin[θ]2 Sin[χ]2 1 + a′ [t]2


a′′ [t]
R31,3,1 -
a[t]

R32,3,2 1 + a′ [t]2

R34,4,3 - Sin[θ]2 Sin[χ]2 1 + a′ [t]2


a′′ [t]
R41,4,1 -
a[t]

R42,4,2 1 + a′ [t]2

R43,4,3 Sin[χ]2 1 + a′ [t]2


10

In[  ]:= Table[riemann〚i, j〛 // MatrixForm, {i, n}, {j, n}]

0 0 0 0 0 a[t] a′′ [t] 0 0 0 0 a[t] Sin[χ]2 a′′ [t] 0


′′
0 0 0 0 - a[t] a [t] 0 0 0 0 0 0 0
Out[  ]=  , , ,
0 0 0 0 0 0 0 0 - a[t] Sin[χ]2 a′′ [t] 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 a[t] Sin[θ]2 Sin[χ]2 a′′ [t]


0 0 0 0
,
0 0 0 0
- a[t] Sin[θ]2 Sin[χ]2 a′′ [t] 0 0 0

a′′ [t]
0 a[t]
0 0 0 0 0 0 0 0 0 0
′′
a [t]
0 0 , 0 0 0 0 0 0 Sin[χ] 1 + a′ [t]2
2
0
 - a[t]
0 , ,
0 0 0 0 0 - Sin[χ]2 1 + a′ [t]2 0 0
0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0

0 0 0 0
0 0 0 Sin[θ] Sin[χ]2 1 + a′ [t]2
2
,
0 0 0 0
0 - Sin[θ]2 Sin[χ]2 1 + a′ [t]2 0 0

a′′ [t]
0 0 a[t]
0 0 0 0 0 0 0 0 0
′ 2
0 0 0 0 0 0 - 1 - a [t] 0 0 0 0 0
 a′′ [t]
, , ,
- 0 0 0 0 1 + a′ [t]2 0 0 0 0 0 0
a[t]
0 0 0 0 0 0 0 0
0 0 0 0

a′′ [t]
0 0 0 0 0 0 0 a[t]
0 0 0 0 0 0 0 0
,  ,
0 0 0 Sin[θ]2 Sin[χ]2 1 + a′ [t]2 0 0 0 0
′′
0 0 - Sin[θ]2 Sin[χ]2 1 + a′ [t]2 0 -
a [t]
0 0 0
a[t]

0 0 0 0 0 0 0 0 0 0 0 0
′ 2 0 0 0 0
0 0 0 - 1 - a [t] 0 0 0 0
, , 
0 0 0 0 0 0 0 - Sin[χ]2 1 + a′ [t]2 0 0 0 0
0 1 + a′ [t]2 0 0 0 0 Sin[χ] 1 + a [t] 
2 ′ 2
0 0 0 0 0

Check that: Rμ ν ρσ = -Rμ ν σρ


11

In[  ]:= Table[riemann〚i, j〛 // MatrixForm, {i, n}, {j, n}] // MatrixForm


Out[  ]//MatrixForm=

0 0 0 0 0 a[t] a′′ [t] 0 0 0 0 a[t] Sin[χ]2 a′′ [t] 0


′′
0 0 0 0 - a[t] a [t] 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 - a[t] Sin[χ]2 a′′ [t] 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 -
a′′ [t]
0 a[t]
0 0 0 0 0 0 0 0 0 0 0
-
′′
a [t]
0 0 0 0 0 0 0 0 0 Sin[χ] 1 + a [t]  0
2 ′ 2
0
a[t]
0 0 0 0 0 - Sin[χ] 1 + a [t] 
2 ′ 2
0 0 0
0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0
′′
a [t]
0 0 a[t]
0 0 0 0 0 0 0 0 0 0
′ 2 0
0 0 0 0 0 0 - 1 - a [t] 0 0 0 0 0
a′′ [t]
- 0 0 0 0 1 + a′ [t]2 0 0 0 0 0 0 0
a[t]
0 0 0 0 0 0 0 0 0
0 0 0 0
a′′ [t]
0 0 0 a[t] 0 0 0 0 0 0 0 0
′ 2 0 0 0 0
0 0 0 0 0 0 0 - 1 - a [t]
0 0 0 0 0 0 0 0 0 0 0 - Sin[χ]2 1 + a′ [t]2
′′

-
a [t]
0 0 0 0 1 + a′ [t]2 0 0 0 0 Sin[χ]2 1 + a′ [t]2 0
a[t]

riemann[[i,j]] gives the matrix Ri j kl


e.g. {{a,b,c},{d,e,f},{g,h,i}}[[2,3]] → f (2→row 3→column)

In[  ]:= riemann〚1, 2, 2, 1〛

Out[  ]= - a[t] a′′ [t]

Now we calculate the Rμνρλ = gμσ Rσ νρλ


12

In[  ]:= lriemann := lriemann = FullSimplify[Table[


Sum[metric〚i, ii〛 riemann〚ii, j, k, l〛, {ii, 1, n}],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n}]];
listlriemann := Table[
If[
UnsameQ[lriemann〚i, j, k, l〛, 0],
{Subscript[R, i, j, k, l], lriemann〚i, j, k, l〛}
] , {i, 1, n}, {j, 1, i - 1}, {k, 1, n}, {l, 1, k - 1}];
TableForm[Partition[DeleteCases[Flatten[listlriemann], Null], 2],
TableSpacing → {2, 2}]

Out[  ]//TableForm=

R2,1,2,1 - a[t] a′′ [t]

R3,1,3,1 - a[t] Sin[χ]2 a′′ [t]

R3,2,3,2 a[t]2 Sin[χ]2 1 + a′ [t]2

R4,1,4,1 - a[t] Sin[θ]2 Sin[χ]2 a′′ [t]

R4,2,4,2 a[t]2 Sin[θ]2 Sin[χ]2 1 + a′ [t]2

R4,3,4,3 a[t]2 Sin[θ]2 Sin[χ]4 1 + a′ [t]2

Check the following antisymmetry properties: Rμν ρσ = -Rμν σρ = -R⋁μ ρσ

In[  ]:= Table[lriemann〚i, j〛 // MatrixForm, {i, n}, {j, n}] // MatrixForm


Out[  ]//MatrixForm=

0 0 0 0 0 - a[t] a′′
′′
0 0 0 0 a[t] a [t] 0
0 0 0 0 0 0
0 0 0 0 0 0
0 a[t] a′′ [t] 0 0 0 0 0 0
- a[t] a′′ [t] 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

0 0 a[t] Sin[χ]2 a′′ [t] 0 0 0


0 0 0 0 0 0 - a[t]
2
- a[t] Sin[χ] a [t] 0′′
0 0 0 a[t] Sin[χ] 1 + a [t] 
2 2 ′ 2

0 0 0 0 0 0
0 0 0 a[t] Sin[θ]2 Sin[χ]2 a′′ [t] 0 0 0
0 0 0 0 0 0 0 -a
0 0 0 0 0 0 0
- a[t] Sin[θ]2 Sin[χ]2 a′′ [t] 0 0 0 0 a[t]2 Sin[θ]2 Sin[χ]2 1 + a′ [t]2 0

Now calculate contravariant Riemann: Rμνρλ = g⋁α gρβ gλγ Rμ αβγ


13

In[  ]:= uriemann := uriemann = FullSimplify[Table[


Sum[
inversemetric〚j, jj〛 inversemetric〚k, kk〛 inversemetric〚l, ll〛
riemann〚i, jj, kk, ll〛, {jj, 1, n}, {kk, 1, n}, {ll, 1, n}
],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n}]];
listuriemann := Table[
If[
UnsameQ[uriemann〚i, j, k, l〛, 0], {Superscript[
Superscript[Superscript[Superscript[R, i], j], k], l], uriemann〚i, j, k, l〛}
] , {i, 1, n}, {j, 1, i - 1}, {k, 1, n}, {l, 1, k - 1}];
TableForm[Partition[DeleteCases[Flatten[listuriemann], Null], 2],
TableSpacing → {2, 2}]
Out[  ]//TableForm=

121 a′′ [t]


R2 -
a[t]3

131 Csc[χ]2 a′′ [t]


R3 -
a[t]3

2
23 Csc[χ]2 1+a′ [t]2 
R3
a[t]6

41 Cscθ2 Csc[χ]2 a′′ [t]


R41 -
a[t]3

42 Cscθ Csc[χ]2 1+a′ [t]2 


2
R42
a[t]6

43 Cscθ2 Csc[χ]4 1+a′ [t]2 


R43
a[t]6

Calculating and displaying the R2 scalar:


Now calculate R2 = Rμνλρ Rμνλρ

In[  ]:= r2 = FullSimplify[


Sum[lriemann〚i, j, k, l〛 uriemann〚i, j, k, l〛, {i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n}]]

12 1 + a′ [t]2 + a[t]2 a′′ [t]2


2

Out[  ]=
a[t]4

Calculating and displaying the Ricci tensor:


The Ricci tensor Rμν was defined by summing the first and third indices of the Riemann tensor (which
has the first index already raised).
14

ricci := ricci = FullSimplify[Table[


Sum[
riemann〚i, j, i, l〛,
{i, 1, n}
], {j, 1, n}, {l, 1, n}] ];
listricci := Table[
If[
UnsameQ[ricci〚j, l〛, 0],
{Subscript[R, j, l], ricci〚j, l〛}
] , {j, 1, n}, {l, 1, j}];
TableForm[Partition[DeleteCases[Flatten[listricci], Null], 2], TableSpacing → {2, 2}]
Out[  ]//TableForm=

3 a′′ [t]
R1,1 -
a[t]

R2,2 2 + 2 a′ [t]2 + a[t] a′′ [t]

R3,3 Sin[χ]2 2 + 2 a′ [t]2 + a[t] a′′ [t]

R4,4 Sin[θ]2 Sin[χ]2 2 + 2 a′ [t]2 + a[t] a′′ [t]

In[  ]:= ricci // MatrixForm


Out[  ]//MatrixForm=

3 a′′ [t]
- 0 0 0
a[t]

0 2 + 2 a′ [t]2 + a[t] a′′ [t] 0 0


0 0 Sin[χ]2 2 + 2 a′ [t]2 + a[t] a′′ [t] 0
0 0 0 Sin[θ] Sin[χ] 2 + 2 a′ [t]2 + a[t] a′′ [t]
2 2

A vanishing table (as with the Schwarzschild metric example) means that the vacuum Einstein
equation is satisfied.

Calculating the scalar curvature:


The scalar curvature R is calculated using the inverse metric and the Ricci tensor. The result is
displayed in the output line.

In[  ]:= scalar = FullSimplify[Sum[inversemetric〚i, j〛 ricci〚i, j〛, {i, 1, n}, {j, 1, n}] ]

6 1 + a′ [t]2 + a[t] a′′ [t]


Out[  ]=
a[t]2

Calculating the Einstein tensor:


The Einstein tensor, Gμν = Rμν - 12 gμν R, is found from the tensors already calculated.
15

In[  ]:= einstein := einstein = FullSimplify[ricci - (1 / 2) scalar * metric];


listeinstein := Table[
If[
UnsameQ[einstein〚j, l〛, 0],
{Subscript[G, j, l], einstein〚j, l〛}
] , {j, 1, n}, {l, 1, j}];
TableForm[Partition[DeleteCases[Flatten[listeinstein], Null], 2],
TableSpacing → {2, 2}]
Out[  ]//TableForm=

3 1+a′ [t]2 
G1,1
a[t]2

G2,2 - 1 - a′ [t]2 - 2 a[t] a′′ [t]

G3,3 - Sin[χ]2 1 + a′ [t]2 + 2 a[t] a′′ [t]

G4,4 - Sin[θ]2 Sin[χ]2 1 + a′ [t]2 + 2 a[t] a′′ [t]

In[  ]:= einstein // MatrixForm


Out[  ]//MatrixForm=

3 1+a′ [t]2 
0 0 0
a[t]2

0 - 1 - a′ [t]2 - 2 a[t] a′′ [t] 0 0


0 0 - Sin[χ]2 1 + a′ [t]2 + 2 a[t] a′′ [t] 0
0 0 0 - Sin[θ]2 Sin[χ]2 1 + a′ [t]2 + 2 a[t] a

A vanishing table means that the vacuum Einstein equation is satisfied!

Calculating the Weyl tensor:


The Weyl tensor:
ℭρσμν = Rρσμν - n-2 gρ[μ Rν] σ - gσ[μ Rν] ρ 
2 2
+ (n-1) (n-2)
gρ[μ gν] σ R
ℭijkl = Rijkl - gik Rlj - gil Rkj - gjk Rli + gjl Rki + gik glj - gil gkj R
1 1
n-2 (n-1) (n-2)
16

In[  ]:= weyl := weyl = FullSimplifyTable

Ifn > 3,
lriemann〚i, j, k, l〛
1
- (metric〚i, k〛 ricci〚l, j〛 - metric〚i, l〛 ricci〚k, j〛 -
n-2
metric〚j, k〛 ricci〚l, i〛 + metric〚j, l〛 ricci〚k, i〛)
1
+ (metric〚i, k〛 metric〚l, j〛 - metric〚i, l〛 metric〚k, j〛) scalar
(n - 1) (n - 2)
(*else, if n≤ 3 return 0:*), 0,

{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n};

listweyl := Table[
If[
UnsameQ[weyl〚i, j, k, l〛, 0],
{Subscript[ℭ, i, j, k, l], weyl〚i, j, k, l〛}
] , {i, 1, n}, {j, 1, i - 1}, {k, 1, n}, {l, 1, k - 1}];
TableForm[Partition[DeleteCases[Flatten[listweyl], Null], 2], TableSpacing → {2, 2}]
Out[  ]//TableForm=

{}

Calculating the geodesic equations:


The geodesic equations are calculated by asking Mathematica to carry out the sum -Γα βγ uβ uγ , where
uα are the components of the four-velocity. (This gives the derivative of uα with respect to proper time
τ. (This is replaced by s if the geodesics are spacelike.)

In[  ]:= geodesic := geodesic = Simplify[Table[


- Sum[affine〚i, j, k〛 u[j] u[k], {j, 1, n},
{k, 1, n}], {i, 1, n}]];
listgeodesic := Table[{"d/dτ " ToString[u[i]], "=", geodesic〚i〛}, {i, 1, n}];
TableForm[listgeodesic, TableSpacing → {2}]
Out[  ]//TableForm=

d/dτ u[1] = - a[t] u[2]2 + Sin[χ]2 u[3]2 + Sin[θ]2 u[4]2 a′ [t]


2 u[1] u2 a′ [t]
d/dτ u[2] = Cos[χ] Sin[χ] u[3]2 + Sin[θ]2 u[4]2 - a[t]

2 u[1] u3 a′ [t]


d/dτ u[3] = - 2 Cot[χ] u[2] u[3] + Cos[θ] Sin[θ] u[4]2 -
a[t]

2 u[4] a[t] Cot[χ] u2+Cotθ u3+u[1] a′ [t]


d/dτ u[4] = -
a[t]

And here they are displayed as differential equations for the coordinates. τ is the affine parameter.
17

In[  ]:= geodesic := geodesic =


Simplify[Table[- Sum[affine〚i, j, k〛 u[j] u[k], {j, 1, n}, {k, 1, n}], {i, 1, n}]];
subst = Table[u[i] → Subscript[coord〚i〛, τ], {i, 1, n}];
nlistgeodesic :=
Table[{Subscript[coord〚i〛, ττ], "+", - geodesic〚i〛 /. subst, "= 0"}, {i, 1, n}];
TableForm[nlistgeodesic, TableSpacing → {2}]
Out[  ]//TableForm=

tττ + a[t] Sin[χ]2 θτ2 + Sin[θ]2 ϕτ2 + χτ2 a′ [t] = 0


2 tτ χτ a [t]

χττ + - Cos[χ] Sin[χ] θτ2 + Sin[θ]2 ϕτ2 + = 0


a[t]

2 tτ θτ a′ [t]
θττ + - Cos[θ] Sin[θ] ϕτ2 + 2 Cot[χ] θτ χτ + = 0
a[t]

2 ϕτ a[t] Cotθ θτ +Cot[χ] χτ +tτ a′ [t]


ϕττ + = 0
a[t]

The Sphere S2
We use coordinates (θ, ϕ), and the metric:

ds2 = dθ2 + sin2(θ) dϕ2

Clear[coord, metric, inversemetric, affine, riemann, lriemann, uriemann,


ricci, scalar, einstein, weyl, geodesic, R, G, τ , i, j, k, l, s, m];
Clear[r, θ, ϕ, t, χ , a];

(*----------------------------------------------------------------------------*)
(* This is what you need to set: *)
coord = {θ, ϕ};
n = Length[coord];
metric = 
{1, 0 },
0, Sin[θ] 
2

;
(*----------------------------------------------------------------------------*)

inversemetric = FullSimplify[Inverse[metric]];
Print["----------------------------------------------------------------------- "];
Print["The Manifold has dimension n= ",
n, "\nCoordinate system: ", coord];
Print["----------------------------------------------------------------------- "];
Print["gμν =", metric // MatrixForm];
Print["gμν =", inversemetric // MatrixForm];
affine := affine = FullSimplifyTable
18

(1 / 2) * Sum
(* gis ∂kgsj+∂jgsk-∂sgjk *)
(inversemetric〚i, s〛) *
(D[metric〚s, j〛, coord〚k〛 ] +
D[metric〚s, k〛, coord〚j〛 ] - D[metric〚j, k〛, coord〚s〛 ]),
{s, 1, n},
{i, 1, n}, {j, 1, n}, {k, 1, n} ;
(*The non zero Christoffel symbols are computed and selected below: *)
listaffine := Table[
If[
UnsameQ[affine〚i, j, k〛, 0],
{Subscript[Superscript[Γ, i], j, k], affine〚i, j, k〛}
],
{i, 1, n}, {j, 1, n}, {k, 1, j}];
Print["----------------------------------------------------------------------- "];
Print["Christoffel Symbols:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listaffine], Null], 2], TableSpacing → {2, 2}]];
riemann := riemann = FullSimplifyTable
(* Rijkl= ∂kΓilj - ∂lΓikj*)
D[ affine〚i, l, j〛, coord〚k〛 ] - D[affine〚i, k, j〛, coord〚l〛 ]+
(* Γ i
ks Γs
lj - Γ i
ls Γ
s
kj *)
Sum[affine〚i, k, s〛 affine〚s, l, j〛 - affine〚i, l, s〛 affine〚s, k, j〛 ,
{s, 1, n}],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n} ;
listriemann := Table[
If[
UnsameQ[riemann〚i, j, k, l〛, 0],
{Subscript[Superscript[R, i], j, k, l], riemann〚i, j, k, l〛}
],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, k - 1}];
Print["----------------------------------------------------------------------- "];
Print["Riemann Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listriemann], Null], 2], TableSpacing → {2, 2}]];
lriemann := lriemann = FullSimplify[Table[
Sum[metric〚i, ii〛 riemann〚ii, j, k, l〛, {ii, 1, n}],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n}]];
listlriemann := Table[
If[
UnsameQ[lriemann〚i, j, k, l〛, 0],
{Subscript[R, i, j, k, l], lriemann〚i, j, k, l〛}
19

] , {i, 1, n}, {j, 1, i - 1}, {k, 1, n}, {l, 1, k - 1}];


Print["----------------------------------------------------------------------- "];
Print["Contravariant Riemann Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listlriemann], Null], 2], TableSpacing → {2, 2}]];
uriemann := uriemann = FullSimplify[Table[
Sum[
inversemetric〚j, jj〛 inversemetric〚k, kk〛 inversemetric〚l, ll〛
riemann〚i, jj, kk, ll〛, {jj, 1, n}, {kk, 1, n}, {ll, 1, n}
],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n}]];
listuriemann := Table[
If[
UnsameQ[uriemann〚i, j, k, l〛, 0], {Superscript[
Superscript[Superscript[Superscript[R, i], j], k], l], uriemann〚i, j, k, l〛}
] , {i, 1, n}, {j, 1, i - 1}, {k, 1, n}, {l, 1, k - 1}];
Print["----------------------------------------------------------------------- "];
Print["Covariant Riemann Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listuriemann], Null], 2], TableSpacing → {2, 2}]];
r2 = FullSimplify[Sum[lriemann〚i, j, k, l〛 uriemann〚i, j, k, l〛,
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n}]];
Print["----------------------------------------------------------------------- "];
Print"R2= ", r2;
ricci := ricci = FullSimplify[Table[
Sum[
riemann〚i, j, i, l〛,
{i, 1, n}
], {j, 1, n}, {l, 1, n}] ];
listricci := Table[
If[
UnsameQ[ricci〚j, l〛, 0],
{Subscript[R, j, l], ricci〚j, l〛}
] , {j, 1, n}, {l, 1, j}];
Print["----------------------------------------------------------------------- "];
Print["Ricci Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listricci], Null], 2], TableSpacing → {2, 2}]];
scalar = FullSimplify[Sum[inversemetric〚i, j〛 ricci〚i, j〛, {i, 1, n}, {j, 1, n}] ];
Print["----------------------------------------------------------------------- "];
Print["Curvature Scalar:"];
Print["R= ", scalar];
einstein := einstein = FullSimplify[ricci - (1 / 2) scalar * metric];
20

listeinstein := Table[
If[
UnsameQ[einstein〚j, l〛, 0],
{Subscript[G, j, l], einstein〚j, l〛}
] , {j, 1, n}, {l, 1, j}];
Print["----------------------------------------------------------------------- "];
Print["Einstein Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listeinstein], Null], 2], TableSpacing → {2, 2}]];
weyl := weyl = FullSimplifyTable

Ifn > 3,
lriemann〚i, j, k, l〛
1
- (metric〚i, k〛 ricci〚l, j〛 - metric〚i, l〛 ricci〚k, j〛 -
n-2
metric〚j, k〛 ricci〚l, i〛 + metric〚j, l〛 ricci〚k, i〛)
1
+ (metric〚i, k〛 metric〚l, j〛 - metric〚i, l〛 metric〚k, j〛) scalar
(n - 1) (n - 2)
(*else, if n≤ 3 return 0:*), 0,

{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n};

listweyl := Table[
If[
UnsameQ[weyl〚i, j, k, l〛, 0],
{Subscript[ℭ, i, j, k, l], weyl〚i, j, k, l〛}
] , {i, 1, n}, {j, 1, i - 1}, {k, 1, n}, {l, 1, k - 1}];
Print["----------------------------------------------------------------------- "];
Print["Weyl Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listweyl], Null], 2], TableSpacing → {2, 2}]];
geodesic := geodesic =
Simplify[Table[- Sum[affine〚i, j, k〛 u[j] u[k], {j, 1, n}, {k, 1, n}], {i, 1, n}]];
subst = Table[u[i] → Subscript[coord〚i〛, τ], {i, 1, n}];
nlistgeodesic :=
Table[{Subscript[coord〚i〛, ττ], "+", - geodesic〚i〛 /. subst, "= 0"}, {i, 1, n}];
Print["----------------------------------------------------------------------- "];
Print["Geodesic Equations:"];
Print[TableForm[nlistgeodesic, TableSpacing → {2}]];

-----------------------------------------------------------------------

The Manifold has dimension n= 2


Coordinate system: {θ, ϕ}

-----------------------------------------------------------------------
21

1 0
gμν =
0 Sin[θ]2
1 0
gμν =
0 Csc[θ]2

-----------------------------------------------------------------------

Christoffel Symbols:

Γ12,2 - Cos[θ] Sin[θ]

Γ 2
2,1 Cot[θ]

-----------------------------------------------------------------------

Riemann Tensor:

R12,2,1 - Sin[θ]2

R21,2,1 1

-----------------------------------------------------------------------

Contravariant Riemann Tensor:

R2,1,2,1 Sin[θ]2

-----------------------------------------------------------------------

Covariant Riemann Tensor:


121
R2 Csc[θ]2

-----------------------------------------------------------------------

R2= 4

-----------------------------------------------------------------------

Ricci Tensor:
R1,1 1

R2,2 Sin[θ]2

-----------------------------------------------------------------------

Curvature Scalar:

R= 2

-----------------------------------------------------------------------

Einstein Tensor:

{}

-----------------------------------------------------------------------

Weyl Tensor:

{}

-----------------------------------------------------------------------

Geodesic Equations:
22

θττ + - Cos[θ] Sin[θ] ϕτ2 = 0


ϕττ + 2 Cot[θ] θτ ϕτ = 0

The Schwarzschild Metric


We consider the Schwarzschild metric outside the horizon. We use (t, r, θ, ϕ) coordinates, and the line
element:

 dt2 + 1 - r  dr2 + r 2dθ2 + sin2(θ) dϕ2


2m 2 m -1
ds2 = -1 - r

Clear[coord, metric, inversemetric, affine, riemann, lriemann, uriemann,


ricci, scalar, einstein, weyl, geodesic, R, G, τ , i, j, k, l, s, m];
Clear[r, θ, ϕ, t, χ , a];

(*----------------------------------------------------------------------------*)
(* This is what you need to set: *)
coord = {t, r, θ, ϕ};
n = Length[coord];

metric = 
2m
- 1 - ,0 ,0 , 0,
r
1
0 , ,0 , 0,
2m
1-
r

0 ,0 , r2 , 0,
0 ,0 ,0 , r Sin[θ] ;
2 2

(*----------------------------------------------------------------------------*)

inversemetric = FullSimplify[Inverse[metric]];
Print["----------------------------------------------------------------------- "];
Print["The Manifold has dimension n= ",
n, "\nCoordinate system: ", coord];
Print["----------------------------------------------------------------------- "];
Print["gμν =", metric // MatrixForm];
Print["gμν =", inversemetric // MatrixForm];
affine := affine = FullSimplifyTable
(1 / 2) * Sum
(* gis ∂kgsj+∂jgsk-∂sgjk *)
(inversemetric〚i, s〛) *
(D[metric〚s, j〛, coord〚k〛 ] +
D[metric〚s, k〛, coord〚j〛 ] - D[metric〚j, k〛, coord〚s〛 ]),
23

{s, 1, n},
{i, 1, n}, {j, 1, n}, {k, 1, n} ;
(*The non zero Christoffel symbols are computed and selected below: *)
listaffine := Table[
If[
UnsameQ[affine〚i, j, k〛, 0],
{Subscript[Superscript[Γ, i], j, k], affine〚i, j, k〛}
],
{i, 1, n}, {j, 1, n}, {k, 1, j}];
Print["----------------------------------------------------------------------- "];
Print["Christoffel Symbols:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listaffine], Null], 2], TableSpacing → {2, 2}]];
riemann := riemann = FullSimplifyTable
(* Rijkl= ∂kΓilj - ∂lΓikj*)
D[ affine〚i, l, j〛, coord〚k〛 ] - D[affine〚i, k, j〛, coord〚l〛 ]+
(* Γiks Γslj - Γils Γskj *)
Sum[affine〚i, k, s〛 affine〚s, l, j〛 - affine〚i, l, s〛 affine〚s, k, j〛 ,
{s, 1, n}],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n} ;
listriemann := Table[
If[
UnsameQ[riemann〚i, j, k, l〛, 0],
{Subscript[Superscript[R, i], j, k, l], riemann〚i, j, k, l〛}
],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, k - 1}];
Print["----------------------------------------------------------------------- "];
Print["Riemann Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listriemann], Null], 2], TableSpacing → {2, 2}]];
lriemann := lriemann = FullSimplify[Table[
Sum[metric〚i, ii〛 riemann〚ii, j, k, l〛, {ii, 1, n}],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n}]];
listlriemann := Table[
If[
UnsameQ[lriemann〚i, j, k, l〛, 0],
{Subscript[R, i, j, k, l], lriemann〚i, j, k, l〛}
] , {i, 1, n}, {j, 1, i - 1}, {k, 1, n}, {l, 1, k - 1}];
Print["----------------------------------------------------------------------- "];
Print["Contravariant Riemann Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listlriemann], Null], 2], TableSpacing → {2, 2}]];
24

uriemann := uriemann = FullSimplify[Table[


Sum[
inversemetric〚j, jj〛 inversemetric〚k, kk〛 inversemetric〚l, ll〛
riemann〚i, jj, kk, ll〛, {jj, 1, n}, {kk, 1, n}, {ll, 1, n}
],
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n}]];
listuriemann := Table[
If[
UnsameQ[uriemann〚i, j, k, l〛, 0], {Superscript[
Superscript[Superscript[Superscript[R, i], j], k], l], uriemann〚i, j, k, l〛}
] , {i, 1, n}, {j, 1, i - 1}, {k, 1, n}, {l, 1, k - 1}];
Print["----------------------------------------------------------------------- "];
Print["Covariant Riemann Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listuriemann], Null], 2], TableSpacing → {2, 2}]];
r2 = FullSimplify[Sum[lriemann〚i, j, k, l〛 uriemann〚i, j, k, l〛,
{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n}]];
Print["----------------------------------------------------------------------- "];
Print"R2= ", r2;
ricci := ricci = FullSimplify[Table[
Sum[
riemann〚i, j, i, l〛,
{i, 1, n}
], {j, 1, n}, {l, 1, n}] ];
listricci := Table[
If[
UnsameQ[ricci〚j, l〛, 0],
{Subscript[R, j, l], ricci〚j, l〛}
] , {j, 1, n}, {l, 1, j}];
Print["----------------------------------------------------------------------- "];
Print["Ricci Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listricci], Null], 2], TableSpacing → {2, 2}]];
scalar = FullSimplify[Sum[inversemetric〚i, j〛 ricci〚i, j〛, {i, 1, n}, {j, 1, n}] ];
Print["----------------------------------------------------------------------- "];
Print["Curvature Scalar:"];
Print["R= ", scalar];
einstein := einstein = FullSimplify[ricci - (1 / 2) scalar * metric];
listeinstein := Table[
If[
UnsameQ[einstein〚j, l〛, 0],
{Subscript[G, j, l], einstein〚j, l〛}
] , {j, 1, n}, {l, 1, j}];
25

Print["----------------------------------------------------------------------- "];
Print["Einstein Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listeinstein], Null], 2], TableSpacing → {2, 2}]];
weyl := weyl = FullSimplifyTable

Ifn > 3,
lriemann〚i, j, k, l〛
1
- (metric〚i, k〛 ricci〚l, j〛 - metric〚i, l〛 ricci〚k, j〛 -
n-2
metric〚j, k〛 ricci〚l, i〛 + metric〚j, l〛 ricci〚k, i〛)
1
+ (metric〚i, k〛 metric〚l, j〛 - metric〚i, l〛 metric〚k, j〛) scalar
(n - 1) (n - 2)
(*else, if n≤ 3 return 0:*), 0,

{i, 1, n}, {j, 1, n}, {k, 1, n}, {l, 1, n};

listweyl := Table[
If[
UnsameQ[weyl〚i, j, k, l〛, 0],
{Subscript[ℭ, i, j, k, l], weyl〚i, j, k, l〛}
] , {i, 1, n}, {j, 1, i - 1}, {k, 1, n}, {l, 1, k - 1}];
Print["----------------------------------------------------------------------- "];
Print["Weyl Tensor:"];
Print[TableForm[
Partition[DeleteCases[Flatten[listweyl], Null], 2], TableSpacing → {2, 2}]];
geodesic := geodesic =
Simplify[Table[- Sum[affine〚i, j, k〛 u[j] u[k], {j, 1, n}, {k, 1, n}], {i, 1, n}]];
subst = Table[u[i] → Subscript[coord〚i〛, τ], {i, 1, n}];
nlistgeodesic :=
Table[{Subscript[coord〚i〛, ττ], "+", - geodesic〚i〛 /. subst, "= 0"}, {i, 1, n}];
Print["----------------------------------------------------------------------- "];
Print["Geodesic Equations:"];
Print[TableForm[nlistgeodesic, TableSpacing → {2}]];

-----------------------------------------------------------------------

The Manifold has dimension n= 4


Coordinate system: {t, r, θ, ϕ}

-----------------------------------------------------------------------
2m
-1 + 0 0 0
r
1
0 2m
0 0
gμν = 1-
r

0 0 r2 0
0 0 0 r2 Sin[θ]2
26

r
0 0 0
2 m-r
2m
0 1- 0 0
gμν =
r
1
0 0 0
r2
Csc[θ]2
0 0 0
r2

-----------------------------------------------------------------------

Christoffel Symbols:

Γ12,1
m
r (-2 m+r)

Γ21,1
m (-2 m+r)
r3

Γ 2 m
2,2
2 m r-r2

Γ 2
3,3 2m-r

Γ24,4 (2 m - r) Sin[θ]2

Γ33,2
1
r

Γ34,4 - Cos[θ] Sin[θ]

Γ44,2
1
r

Γ44,3 Cot[θ]

-----------------------------------------------------------------------

Riemann Tensor:
2m
R12,2,1 -
r2 (-2 m+r)
m
R13,3,1
r

m Sin[θ]2
R14,4,1
r
2 m (2 m-r)
R21,2,1
r4
2 m
R 3,3,2 r

m Sin[θ]2
R24,4,2
r
m (-2 m+r)
R31,3,1
r4
m
R32,3,2
(2 m-r) r2

2 m Sin[θ]2
R34,4,3 -
r
m (-2 m+r)
R41,4,1
r4
m
R42,4,2
(2 m-r) r2

2m
R43,4,3
r

-----------------------------------------------------------------------

Contravariant Riemann Tensor:


27

2m
R2,1,2,1 -
r3
m (-2 m+r)
R3,1,3,1
r2
m
R3,2,3,2
2 m-r

m (-2 m+r) Sin[θ]2


R4,1,4,1
r2
m Sin[θ]2
R4,2,4,2
2 m-r

R4,3,4,3 2 m r Sin[θ]2

-----------------------------------------------------------------------

Covariant Riemann Tensor:


121 2m
R2 -
r3
1
313 m
R
r4 (-2 m+r)

232 m (2 m-r)
R3
r6

141 m Csc[θ]2
R4 -
(2 m-r) r4

242 m (2 m-r) Csc[θ]2


R4
r6

343 2 m Csc[θ]2
R4
r7

-----------------------------------------------------------------------

48 m2
R2=
r6
-----------------------------------------------------------------------

Ricci Tensor:

{}

-----------------------------------------------------------------------

Curvature Scalar:

R= 0

-----------------------------------------------------------------------

Einstein Tensor:

{}

-----------------------------------------------------------------------

Weyl Tensor:
28

ℭ2,1,2,1
2m
-
r3

ℭ3,1,3,1
m (-2 m+r)
r2

ℭ3,2,3,2
m
2 m-r

ℭ4,1,4,1
m (-2 m+r) Sin[θ]2
r2

ℭ4,2,4,2
m Sin[θ]2
2 m-r

ℭ4,3,4,3 2 m r Sin[θ]2

-----------------------------------------------------------------------

Geodesic Equations:
2 m rτ tτ
tττ + - = 0
2 m r-r2
2 2
+ (2 m - r) θτ2 + (2 m - r) Sin[θ]2 ϕτ2
m rτ m (2 m-r) tτ
rττ + - = 0
2 m r-r2 r3
2 rτ θτ
θττ + - Cos[θ] Sin[θ] ϕτ2 = 0
r
2 (rτ +r Cot[θ] θτ ) ϕτ
ϕττ + = 0
r

We can see the following symmetries of the Weyl tensor in this display: Cμν ρσ = -Cμν σρ = -Cνμ ρσ

In[  ]:= Table[weyl〚i, j〛 // MatrixForm, {i, n}, {j, n}] // MatrixForm


Out[  ]//MatrixForm=

2m m -2 m+r
0 0 0 0 0 - 0 0 0 0 0
r3 r2
0 0 0 0 2m
0 0 0 0 0 0 0
r3 m 2 m-r
0 0 0 0 0 0 0
0 0 0 0 r2
0 0 0 0
0 0 0 0 0 0 0 0
2m 0 0 0 0
0 0 0 0 0 0 0
r3 m
2m 0 0 0 0 0 0 0
- 0 0 0 2 m-r
r3 m
0 0 0 0 0 0 0
0 0 0 0 -2 m+r
0 0 0 0
0 0 0 0 0 0 0 0
m 2 m-r
0 0 0 0 0 0 0 0
r2 0 0 0 0
m
0 0 0 0 0 0 -2 m+r
0 0 0 0 0 0
m -2 m+r m 0 0 0 0 0
0 0 0 0 2 m-r
0 0
r2
0 0 0 0 0
0 0 0 0 0 0 0 0
m 2 m-r Sinθ2 0 0 0 0
0 0 0 0 0 0 0
r2 m Sinθ2
0 0 0 0 0 0 0 -2 m+r
0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 - 2 m r Sin[θ]2
m -2 m+r Sinθ 2
m Sinθ 2
0 0 2 m r Sin[θ]2 0
0 0 0 0 0 0
r2 2 m-r

Acknowledgment
The original program was kindly written by Leonard Parker, University of Wisconsin, Milwaukee
especially for this text.
29

Several additions by Konstantinos Anagnostopoulos, National Tech U. Athens,


http://physics.ntua.gr/konstant, [email protected], 2023

You might also like