# Covariant derivative given Christoffel symbols

I've been trying to take covariant derivative of various quantities along various surfaces in Mathematica, but I keep running into issues, frequently I get a tensor with the wrong dimension. Using the Einstein Summation Convention, computing the covariant derivative of a vector, $W^\mu$, is relatively intuitive:

$$D_\nu W^\mu \equiv \partial_\nu W^\mu + \Gamma_{\nu \lambda}^\mu W^\lambda$$

where $\Gamma_{\nu \lambda}^\mu$ is the Christoffel symbol.

However, Mathematica does not work very well with the Einstein Summation Convention. I would like a snippet of code or an approach that will compute the covariant the derivative of a vector given the Christoffel symbols. Ideally, this code should work for a surface of any dimension.

• You should try using xAct xact.es Sep 16, 2017 at 6:32

Given a coordinate list and a metric, this should work by using MMa Sum command.

Christoffel symbols from the standard formula

Γudd[aa_, bb_, cc_] := (1/2)*Sum[guu[[aa,dd]]*(D[gdd[[dd,cc]], clist[[bb]]] + D[gdd[[dd,bb]], clist[[cc]]] -
D[gdd[[bb,cc]], clist[[dd]]]), {dd, 1, Length[gdd]}]


∇[Au[[a]],clist[[b]]]. covariant derivative of a vector element A[[a]] wrt clist[[b]] from a standard formula.

covDu[A_, a_, b_] := D[A[[a]], clist[[b]]] + Sum[Γudd[a, b, c]*A[[c]], {c, 1, Length[gdd]}]


where gdd and guu are the covariant and contravariant metrics and clist is the coordinate list. For example the Schwarzschild metric.

Coordinate list

clist = {t, r, θ, ϕ}


The metrics - g down down.

gdd = DiagonalMatrix[{-(1 - 2 m/r), 1 - 2 m/r, r^2, r^2 Sin[θ]^2}];


g up up

guu = Inverse[gdd] // Simplify;


We can look at the Christoffel symbols.

Table[Γudd[a, b, c], {a, Length[gdd]}, {b, Length[gdd]}, {c, Length[gdd]}]

(*{{{0, -(m/((2 m - r) r)), 0, 0}, {-(m/((2 m - r) r)), 0, 0, 0}, {0, 0,
0, 0}, {0, 0, 0, 0}}, {{-(m/((2 m - r) r)), 0, 0,
0}, {0, -(m/((2 m - r) r)), 0, 0}, {0, 0, r^2/(2 m - r), 0}, {0, 0,
0, (r^2 Sin[θ]^2)/(2 m - r)}}, {{0, 0, 0, 0}, {0, 0, 1/r,
0}, {0, 1/r, 0, 0}, {0, 0, 0, -Cos[θ] Sin[θ]}}, {{0,
0, 0, 0}, {0, 0, 0, 1/r}, {0, 0, 0, Cot[θ]}, {0, 1/r,
Cot[θ], 0}}}*)


Example vector

A = {t, r , Cos[θ], Sin[ϕ]}


and a table of the covariant derivative components.

Table[covDu[A, a, b], {a, Length[gdd]}, {b, Length[gdd]}] // Simplify
(*{{1 - m/(2 m - r), -((m t)/(2 m r - r^2)), 0,
0}, {-((m t)/(2 m r - r^2)), 1 - m/(2 m - r), (r^2 Cos[θ])/(
2 m - r), (r^2 Sin[θ]^2 Sin[ϕ])/(2 m - r)}, {0,
Cos[θ]/r,
1 - Sin[θ], -Cos[θ] Sin[θ] Sin[ϕ]}, {0,
Sin[ϕ]/r, Cot[θ] Sin[ϕ],
Cos[ϕ] + Cos[θ] Cot[θ] + 1}}*)


It should work for any dimension. The user inputs are the coordinate list, the metric and the object vector to differentiate.