I am using xAct package and I would like to get geodesic equations in components for Schwarzshild metric (for instance).

DefManifold[M4, 4, {\[Alpha], \[Beta], \[Rho], \[Sigma], \[Mu], \[Nu], \[Lambda]}]
DefScalarFunction /@ {f, A};
DefChart[B, M4, {0, 1, 2, 3}, {t[], r[], \[Theta][], \[Phi][]}, ChartColor -> Red]
f[expr_] := (1 - 2 M/expr)
g = CTensor[DiagonalMatrix[{-f[r[]], 1/f[r[]], r[]^2,r[]^2 Sin[\[Theta][]]^2}], {-B, -B}];
g[-\[Mu], -\[Nu]]
SetCMetric[g, B, SignatureOfMetric -> {3, 1, 0}]
MetricCompute[g, B, All]

This part is pretty straightforward. Than I want to use CTensors to construct the geodesic equation, put I really don't know what to do.

A need to write something like x[a]''-Christoffel[a,-b,-c]x[b]'x[c]' ==0

  1. How do I define the velocity vector to work with the components?
  2. I tried a projector u = diag[{-1,0,0,0}] acting on X={X0,X1,X2,X3}, u[a]CD[-a] should give me the projected time derivative.
  3. u[a]CD[-a]X[b] should be the velocity V and V[a]CD[-a]@V[a] whould, in principle give me the geodesics.

It does not work. The output is enter image description here

I appreciate any help. Thanks in advance.


1 Answer 1


Rather than starting with the "vector of coordinates", which is not really a vector, it is better to start with the velocity components, which do form a vector.

Define the same structures you had:

<< xAct`xCoba`

DefManifold[M4, 4, {\[Alpha], \[Beta], \[Rho], \[Sigma], \[Mu], \[Nu], \[Lambda]}]


DefChart[B, M4, {0, 1, 2, 3}, {t[], r[], \[Theta][], \[Phi][]}]

f[expr_] := (1 - 2 M/expr)

g = CTensor[DiagonalMatrix[{-f[r[]], 1/f[r[]], r[]^2, r[]^2 Sin[\[Theta][]]^2}], {-B, -B}]

You can then find the LeviCivita connection of this metric with

cd = LC[g]

which can be used like any other covariant derivative in xAct. Try for example

cd[-\[Alpha]][g[-\[Mu], -\[Nu]]]

Its Christoffel, from the PDB of the chart you introduced, will be

Christoffel[cd, PDB][\[Alpha], -\[Mu], -\[Nu]]

To get the geodesic equation, you just need to introduce the velocity vector. To facilitate integration later, let us use scalar components for both the position and the velocity:

DefScalarFunction /@ {xt, xr, x\[Theta], x\[Phi], vt, vr, v\[Theta], v\[Phi]};

and a parameter tau for the trajectory:


Then we have this list of coordinates (not a vector):

x = {xt[tau], xr[tau], x\[Theta][tau], x\[Phi][tau]};

and the velocity vector in the coordinated basis B:

v = CTensor[{vt[tau], vr[tau], v\[Theta][tau], v\[Phi][tau]}, {B}]

You need the relation between x and v:

Thread[ParamD[tau][x] == First[v]]

and the actual geodesic equation, evaluating the Christoffel tensor on the trajectory:

ParamD[tau][v[\[Alpha]]] + Christoffel[cd, PDB][\[Alpha], -\[Mu], -\[Nu]] v[\[Mu]] v[\[Nu]] /. Thread[ScalarsOfChart[B] -> x] // Simplify
  • 1
    $\begingroup$ I did not know about the function ParamD, veru useful. I guess you meant x instead of pos in the last line, right? $\endgroup$ Commented Feb 8, 2019 at 0:42
  • $\begingroup$ Yes, thanks for pointing that out. I've fixed it, for the benefit of future readers. $\endgroup$
    – jose
    Commented Feb 8, 2019 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.