Christoffel Symbols and Geodesic  Equation

This is a Mathematica program to compute the Christoffel  and the geodesic equations, starting from a given metric  (Subscript[g, αβ]). The Christoffel symbols are calculated from the formula

\(TraditionalForm\`\(Γ\^λ\)\_μν = \(1\/2\) \(\(g\^λσ\)(∂\_μ\ 
                g\_σν + ∂\_ν\ 
                g\_σμ - ∂\_σ\ 
                g\_μν)\)\)

where (g^λ)σ is the matrix inverse of (Subscript[g, λσ ])called the inverse metric. This is the  solution of the relation (8.19) and the notation for the inverse metric is standard [cf (20.17)]. The components of the geodesic equation are 

d(u^α)/dτ = - (Subscript[((Γ^α)), β])γ (u^β)(u^γ) .

You must input the covariant components of the metric tensor (Subscript[g, μ])ν by editing the relevant input line in this Mathematica notebook. You may also wish to change the names of the coordinates. The nonzero components of the above quantities are displayed as the output.

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,   r,  θ,  ϕ,  t]

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 wormhole metric (7.40). Note that for convenience t is denoted by (x^4) rather than (x^0) and summations run from 1 to 4 rather than 0 to 3.

coord  =  {r, θ, ϕ, t}

You can change the names of the coordinates by simply editing the definition of coord, for example, to coord = {x, y, z, t}, when another set of coordinate names is more appropriate.

Defining the 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.

metric = {{1, 0, 0, 0}, {0, r^2 + b^2, 0, 0}, {0, 
          0, (r^2 + b^2) Sin[θ]^2, 0}, {0, 0, 
          0, -1}}

You can also display this in matrix form:

metric // MatrixForm

Note:

It is important not to use the symbols, i, j, k, l, n, or s  as constants or coordinates in the metric that you specify above. The reason is that  the first four of those symbols are used as summation or table indices in the calculations done below. The last is the dimension of the space.

Calculating the inverse metric:

The inverse metric is obtained through matrix inversion.

inversemetric = Simplify[Inverse[metric]]

The inverse metric can also be displayed in matrix form:

inversemetric // MatrixForm

Calculating the affine connection:

The calculation of the components of the affine connection 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.

affine := affine = 
        Simplify[
          Table[(1/2)*
              Sum[(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}] ]

Displaying the affine connection:

The nonzero components of the affine connections are displayed below. You need not follow the details of constructing the functions that we use for that purpose. Because the affine connection is symmetric under interchange of the last two indices, only the independent components are displayed.

listaffine := 
      Table[If[UnsameQ[affine[[i, j, k]], 
            0], {ToString[Γ[i, j, k]], 
            affine[[i, j, k]]}] , {i, 1, n}, {j, 1, n}, {k, 1, 
          j}]

TableForm[Partition[DeleteCases[Flatten[listaffine], Null], 2], 
      TableSpacing -> {2, 2}]

Calculating the geodesic equations:

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

geodesic := geodesic = 
        Simplify[
          Table[-Sum[
                affine[[i, j, k]] u[j] u[k], {j, 1, 
                  n}, 
{k, 1, n}], {i, 1, 
              n}]]

Displaying the geodesic equations:

listgeodesic := 
      Table[{"d/dτ" ToString[u[i]], "=", geodesic[[i]]}, {i, 
          1, n}]

TableForm[listgeodesic, TableSpacing -> {2}]

Acknowledgment

This program was adapted from the notebook Curvature and the Einstein equation kindly written by Leonard Parker  especially for this text.