You are on page 1of 5

Curvature and the Einstein Equation

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,

1
GΛ ΜΝ = gΛΣ I¶ Μ gΣΝ + ¶Ν gΣΜ - ¶Σ g ΜΝ M,
2
H ¶Α stands for the partial derivative ¶  ¶ xΑ L, the Riemann tensor,

RΛ ΜΝΣ = ¶Ν GΛ ΜΣ - ¶Σ GΛ ΜΝ + GΗ ΜΣ GΛ ΗΝ - GΗ ΜΝ GΛ ΗΣ ,

the Ricci tensor

R ΜΝ = RΛ ΜΛΝ ,

the scalar curvature,

R = g ΜΝ R ΜΝ ,

and the Einstein tensor,

1
GΜΝ = RΜΝ - gΜΝ R.
2
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.

Ÿ Clearing the values of symbols :

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.
Clear@coord, metric, inversemetric, affine, riemann, ricci, scalar, einstein, r, Θ, Φ, tD

Ÿ Setting the dimension

The dimension n of the spacetime (or space) must be set :

n = 4

Ÿ Defining a list of coordinates :

The example given here is the Schwarzschild metric. The coordinates choice of Schwarzschild is appropriate for this spherically
symmetric spacetime.

Printed by Mathematica for Students


2 Curvature and the Einstein Equation.nb

coord = 8r, Θ, Φ, t<

8r, Θ, Φ, t<

You can change the names of the coordinates by simply editing the definition of coord, for example,
to coord = 8x, y, z, t<, when another set of coordinates names is more appropriate. In this program
indices ranges over 1 to n. Thus for spacetime they range from 1 to 4 and x4 is the same as x0 used in the text.

Ÿ Defining the metric:

Input the metric as a list of list, 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.

wormhole = 981, 0, 0, 0<, 90, b2 + r2 , 0, 0=, 90, 0, Ib2 + r2 M Sin@ΘD2 , 0=, 80, 0, 0, - 1<=;

schwarzschild =
88H1 - 2 m  rL ^ - 1, 0, 0, 0<, 80, r ^ 2, 0, 0<, 80, 0, r ^ 2 Sin@ΘD, 0<, 80, 0, 0, - H1 - 2 m  rL<<;

metric = wormhole

981, 0, 0, 0<, 90, b2 + r2 , 0, 0=, 90, 0, Ib2 + r2 M Sin@ΘD2 , 0=, 80, 0, 0, - 1<=

You can also display this in matrix form.

metric  MatrixForm

1 0 0 0
0 b2 + r 2 0 0
0 0 Ib2 + r2 M Sin@ΘD2 0
0 0 0 -1

Ÿ Note :

It is important not to use the symbols, i, j, k, l, s, 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 dimen-
sion of space. For example, if m were used as a summation or table index below, then you would get the wrong answer for the
present metric because m in the metric would be treated as an index, rather than as the mass.

Ÿ Calculating the inverse metric :

The inverse metric is obtained through matrix inversion.

inversemetric = Simplify@Inverse@metricDD

1 Csc@ΘD2
:81, 0, 0, 0<, :0, , 0, 0>, :0, 0, , 0>, 80, 0, 0, - 1<>
b2 + r2 b2 + r2

This can also be displayed in matrix form.

Printed by Mathematica for Students


Curvature and the Einstein Equation.nb 3

inversemetric  MatrixForm

1 0 0 0
1
0 0 0
b2 +r2
Csc@ΘD2
0 0 0
b2 +r2
0 0 0 -1

Ÿ 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 for taking partial derivatives, Sum for summing over repeated indices,
Table for forming a list of components, and Simplify for simplifying the result.
affine :=
affine = Simplify@Table@H1  2L * Sum@Hinversemetric@@i, sDDL * HD@metric@@s, jDD, coord@@kDDD +
D@metric@@s, kDD, coord@@jDDD - D@metric@@j, kDD, coord@@sDDDL,
8s, 1, n<D, 8i, 1, n<, 8j, 1, n<, 8k, 1, n<DD

Ÿ Displaying the Christoffel symbols :

The nonzero Christoffel symbols are displayed below. You need not follow the details of constructing the functions that we use
for that purpose. In the output the symbol G[1, 2, 3] stands for G1 23 . Because the Christoffel symbols are symmetric under
interchange of the last two indices, only the independent components are displayed.
listaffine := Table@If@UnsameQ@affine@@i, j, kDD, 0D,
8ToString@G@i, j, kDD, affine@@i, j, kDD<D, 8i, 1, n<, 8j, 1, n<, 8k, 1, j<D

TableForm@Partition@DeleteCases@Flatten@listaffineD, NullD, 2D, TableSpacing ® 82, 2<D

G@1, 2, 2D -r
G@1, 3, 3D - r Sin@ΘD2
r
G@2, 2, 1D
b2 +r2

G@2, 3, 3D - Cos@ΘD Sin@ΘD


r
G@3, 3, 1D
b2 +r2

G@3, 3, 2D Cot@ΘD

Ÿ Calculating and displaying the Riemann tensor :

The components of the Riemann tensor, RΛ ΜΝΣ , are calculated using the definition given above.

riemann :=
riemann = Simplify@Table@D@affine@@i, j, lDD, coord@@kDDD - D@affine@@i, j, kDD, coord@@lDDD +
Sum@affine@@s, j, lDD affine@@i, k, sDD - affine@@s, j, kDD affine@@i, l, sDD, 8s, 1, n<D,
8i, 1, n<, 8j, 1, n<, 8k, 1, n<, 8l, 1, n<DD

The nonzero components are displayed by the following functions. In the output, the symbol R[1, 2, 1, 3] stands for R1 213 , and
similarly for the other components. You can obtain R[1, 2, 3, 1] from R[1, 2, 1, 3] using the antisymmetry of the Riemann tensor
under exchange of the last two indices. The antisymmetry under exchange of the first two indices of RΛΜΝΣ is not evident in the
output because the components of RΛ ΜΝΣ are the displayed.

Printed by Mathematica for Students


4 Curvature and the Einstein Equation.nb

listriemann :=
Table@If@UnsameQ@riemann@@i, j, k, lDD, 0D, 8ToString@R@i, j, k, lDD, riemann@@i, j, k, lDD<D,
8i, 1, n<, 8j, 1, n<, 8k, 1, n<, 8l, 1, k - 1<D

TableForm@Partition@DeleteCases@Flatten@listriemannD, NullD, 2D, TableSpacing ® 82, 2<D


m
R@1, 2, 2, 1D
r

m Sin@ΘD2
R@1, 3, 3, 1D
r
2 m H-2 m+rL
R@1, 4, 4, 1D
r4
m
R@2, 1, 2, 1D
H2 m-rL r2

2 m Sin@ΘD2
R@2, 3, 3, 2D -
r
m H2 m-rL
R@2, 4, 4, 2D
r4
m
R@3, 1, 3, 1D
H2 m-rL r2

2m
R@3, 2, 3, 2D
r
m H2 m-rL
R@3, 4, 4, 3D
r4
2m
R@4, 1, 4, 1D -
H2 m-rL r2
m
R@4, 2, 4, 2D -
r

m Sin@ΘD2
R@4, 3, 4, 3D -
r

Ÿ 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).
ricci := ricci = Simplify@Table@Sum@riemann@@i, j, i, lDD, 8i, 1, n<D, 8j, 1, n<, 8l, 1, n<DD

Next we display the nonzero components. In the output R@1, 2D denotes R12 , and similarly for the other components.

listricci :=
Table@If@UnsameQ@ricci@@j, lDD, 0D, 8ToString@R@j, lDD, ricci@@j, lDD<D, 8j, 1, n<, 8l, 1, n<D

TableForm@Partition@DeleteCases@Flatten@listricciD, NullD, 2D, TableSpacing ® 82, 2<D

8<

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 mtric and the Ricci tensor. The result is displayed in the output line.

scalar = Simplify@Sum@inversemetric@@i, jDD ricci@@i, jDD, 8i, 1, n<, 8j, 1, n<DD

Printed by Mathematica for Students


Curvature and the Einstein Equation.nb 5

Ÿ Calculating the Einstein tensor :

1
The Einstein tensor, G ΜΝ = R ΜΝ - 2
g ΜΝ R, is found from the tensors already calculated.

einstein := einstein = Simplify@ricci - H1  2L scalar * metricD

listeinstein := Table@
If@UnsameQ@einstein@@j, lDD, 0D, 8ToString@G@j, lDD, einstein@@j, lDD<D, 8j, 1, n<, 8l, 1, j<D

TableForm@Partition@DeleteCases@Flatten@listeinsteinD, NullD, 2D, TableSpacing ® 82, 2<D

8<

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

Printed by Mathematica for Students

You might also like