Geodesics generalize the idea of straight lines in a plane to curved surfaces. They are the paths taken by objects that move freely, without acceleration. They are determined by the geodesic equation

$\frac{{d}^{2}{x}^{i}}{d{s}^{2}}+{\Gamma}_{km}^{i}\frac{d{x}^{k}}{ds}\frac{d{x}^{m}}{ds}=0$

where *s* is the invariant interval measured along the geodesics and repeated indices are summed. The Christoffel symbols in the equation are defined in terms of a metric tensor by

${\Gamma}_{kl}^{i}=\frac{1}{2}{g}^{im}[\frac{\partial {g}_{ml}}{\partial {x}^{k}}+\frac{\partial {g}_{mk}}{\partial {x}^{l}}-\frac{\partial {g}_{kl}}{\partial {x}^{m}}]$

As a step towards meaningful visualizations of geodesics for general relativistic metrics, this presentation will consider geodesics for two-dimensional surfaces embedded in our three-dimensional space. This means that given a parametrization of a surface in terms of two independent variables

$x=x(u,v)\phantom{\rule{4em}{0ex}}y=y(u,v)\phantom{\rule{4em}{0ex}}z=z(u,v)$

the expression for the square of the invariant interval formed by summing squared differentials of the parametrized dependent variables reduces to two dimensions:

$d{s}^{2}=d{x}^{2}+d{y}^{2}+d{z}^{2}=Ed{u}^{2}+2Fdudv+Gd{v}^{2}$

This expression in general has three terms with coefficient functions depending on both independent variables. The two-dimensional metric tensor and its inverse are

$\begin{array}{l}g=\left[\begin{array}{cc}E& F\\ F& G\end{array}\right]\phantom{\rule{5em}{0ex}}{g}^{-1}=\frac{1}{\Delta}\left[\begin{array}{cc}G& -F\\ -F& E\end{array}\right]\phantom{\rule{1em}{0ex}},\phantom{\rule{1em}{0ex}}\Delta =detg=EG-{F}^{2}\end{array}$

In the general case there are six independent Christoffel symbols, where derivatives with respect to the two variables are denoted by numerical indices:

$\begin{array}{l}{\Gamma}_{11}^{1}=\frac{{E}_{1}G-2{F}_{1}F+{E}_{2}F}{2\Delta}\\ {\Gamma}_{12}^{1}={\Gamma}_{21}^{1}=\frac{-{G}_{1}F+{E}_{2}G}{2\Delta}\\ {\Gamma}_{22}^{1}=\frac{-{G}_{1}G+2{F}_{2}G-{G}_{2}F}{2\Delta}\end{array}\phantom{\rule{4em}{0ex}}\begin{array}{l}{\Gamma}_{11}^{2}=\frac{-{E}_{1}F+2{F}_{1}E-{E}_{2}E}{2\Delta}\\ {\Gamma}_{12}^{2}={\Gamma}_{21}^{2}=\frac{{G}_{1}E-{E}_{2}F}{2\Delta}\\ {\Gamma}_{22}^{2}=\frac{{G}_{1}F-2{F}_{2}F+{G}_{2}E}{2\Delta}\end{array}$

One can now easily construct the two geodesic equations using these symbols, remembering to include a factor of two due to symmetry whenever symbols with differing lower indices occur.

Since many people consider evaluating Christoffel symbols to be tedious, it is worth pointing out that there is an alternative method for deriving geodesic equations. Define a Lagrangian for the metric as

$L=\frac{1}{2}[E{\stackrel{\xb7}{u}}^{2}+2F\stackrel{\xb7}{u}\stackrel{\xb7}{v}+G{\stackrel{\xb7}{v}}^{2}]$

where the dot is differentiation with respect to invariant interval, and evaluate the Lagrange equations

$\frac{d}{ds}\frac{\partial L}{\partial {\stackrel{\xb7}{q}}_{i}}=\frac{\partial L}{\partial {q}_{i}}$

This process is entirely equivalent to the one requiring explicit statement of Christoffel symbols and perhaps a bit less error prone. The explicit Lagrange equations are

$\begin{array}{l}\frac{d}{ds}[E\stackrel{\xb7}{u}+F\stackrel{\xb7}{v}]=\frac{1}{2}[{E}_{1}{\stackrel{\xb7}{u}}^{2}+2{F}_{1}\stackrel{\xb7}{u}\stackrel{\xb7}{v}+{G}_{1}{\stackrel{\xb7}{v}}^{2}]\\ \frac{d}{ds}[F\stackrel{\xb7}{u}+G\stackrel{\xb7}{v}]=\frac{1}{2}[{E}_{2}{\stackrel{\xb7}{u}}^{2}+2{F}_{2}\stackrel{\xb7}{u}\stackrel{\xb7}{v}+{G}_{2}{\stackrel{\xb7}{v}}^{2}]\end{array}$

Expanding the left-hand side and rearranging

$\begin{array}{l}E\stackrel{\xb7\xb7}{u}+F\stackrel{\xb7\xb7}{v}=\frac{1}{2}[-{E}_{1}{\stackrel{\xb7}{u}}^{2}-2{E}_{2}\stackrel{\xb7}{u}\stackrel{\xb7}{v}+({G}_{1}-2{F}_{2}\left){\stackrel{\xb7}{v}}^{2}\right]\\ F\stackrel{\xb7\xb7}{u}+G\stackrel{\xb7\xb7}{v}=\frac{1}{2}\left[\right({E}_{2}-2{F}_{1}){\stackrel{\xb7}{u}}^{2}-2{G}_{1}\stackrel{\xb7}{u}\stackrel{\xb7}{v}-{G}_{2}{\stackrel{\xb7}{v}}^{2}]\end{array}$

so that the second derivatives of the independent variables are

$\begin{array}{l}\stackrel{\xb7\xb7}{u}=\frac{-{E}_{1}G+2{F}_{1}F-{E}_{2}F}{2\Delta}{\stackrel{\xb7}{u}}^{2}+\frac{{G}_{1}F-{E}_{2}G}{\Delta}\stackrel{\xb7}{u}\stackrel{\xb7}{v}+\frac{{G}_{1}G-2{F}_{2}G+{G}_{2}F}{2\Delta}{\stackrel{\xb7}{v}}^{2}\\ \stackrel{\xb7\xb7}{v}=\frac{{E}_{1}F-2{F}_{1}E+{E}_{2}E}{2\Delta}{\stackrel{\xb7}{u}}^{2}+\frac{-{G}_{1}E+{E}_{2}F}{\Delta}\stackrel{\xb7}{u}\stackrel{\xb7}{v}+\frac{-{G}_{1}F+2{F}_{2}F-{G}_{2}E}{2\Delta}{\stackrel{\xb7}{v}}^{2}\end{array}$

One can easily verify that the quantities on the right-hand side are the negatives of the Christoffel symbols previously calculated, allowing for the extra factor of two mentioned above for those with differing lower indices.

For the purposes of visualization, there is no need to simplify any further: all the functions involved can be written in code and evaluated as is. Since the set of resulting equations is nonlinear for nontrivial metrics, numerical integration is in any case generally necessary for a solution.

A good starting point is a spherical surface of radius *a* that can be parametrized with

$\begin{array}{l}x=asinucosv\\ y=asinusinv\\ z=acosu\end{array}\phantom{\rule{4em}{0ex}}0\le u\le \pi \phantom{\rule{1em}{0ex}},\phantom{\rule{1em}{0ex}}0\le v\le 2\pi $

The corresponding two-dimensional metric is

$d{s}^{2}=d{x}^{2}+d{y}^{2}+d{z}^{2}={a}^{2}(d{u}^{2}+{sin}^{2}u\phantom{\rule{.3em}{0ex}}d{v}^{2})$

Not only is the off-diagonal component zero, but the first metric coefficient is constant and the other depends on only one independent variable. The geodesic equations are relatively simple:

$\begin{array}{l}\stackrel{\xb7\xb7}{u}=\frac{{G}_{1}}{2E}{\stackrel{\xb7}{v}}^{2}=sinucosu\phantom{\rule{.3em}{0ex}}{\stackrel{\xb7}{v}}^{2}\\ \stackrel{\xb7\xb7}{v}=-\frac{{G}_{1}}{G}\stackrel{\xb7}{u}\stackrel{\xb7}{v}=-2cotu\phantom{\rule{.3em}{0ex}}\stackrel{\xb7}{u}\stackrel{\xb7}{v}\end{array}$

Note that these equations are independent of the radius. That parameter is here merely an overall scaling factor for the transformation to three dimensions, but will be included for consistency with later surfaces.

Numerical integration for an arbitrary starting point and a spray of geodesics around it:

The geodesics visibly trace out a spherical surface from any starting point. All of these geodesics are closed great circles on the sphere. Closed geodesics do not occur in general on arbitrary surfaces, which will become evident with more complicated cases.

One curiosity of the code for this graphic is how the initial velocities are assigned in the two-dimensional angular space. Since the differential of *v* is multiplied by *u**u* when assigning values equally spaced around a unit circle. Otherwise there is a noticeable and misleading artifact from the coordinate system in the resulting geodesics. Try altering the underlying code to see it!

Further, the regions around *u* = 0 and *u* = *π* are avoided due to the singularity in the second geodesic equation. The same applies to the initial velocities, where a small offset is used to avoid passing through these poles. This will no longer be necessary when adaptive Runge-Kutta integration is added to MathCell.

The embedding of this surface in three-dimensional space is easily shown by parametrizing an arbitrary point in three-dimensional space as

$\begin{array}{l}x=rsinucosv\\ y=rsinusinv\\ z=rcosu\end{array}$

and evaluating the corresponding metric:

$d{s}^{2}=d{x}^{2}+d{y}^{2}+d{z}^{2}=d{r}^{2}+{r}^{2}d{u}^{2}+{r}^{2}{sin}^{2}u\phantom{\rule{.3em}{0ex}}d{v}^{2}$

This is the metric of a flat three-dimensional space expressed in spherical coordinates. The metric of the spherical surface by contrast has only the two dimensions parametrized by angles. The restriction of the radius to a constant value is what produces the curvature of the surface in its ambient three-dimensional space.

A generalization of the simple spherical surface is an ellipsoid of revolution parametrized with

$\begin{array}{l}x=asinucosv\\ y=asinusinv\\ z=ccosu\end{array}\phantom{\rule{4em}{0ex}}0\le u\le \pi \phantom{\rule{1em}{0ex}},\phantom{\rule{1em}{0ex}}0\le v\le 2\pi $

with an independent scaling factor in the *z* direction. The metric formed by summing squared differentials is

$d{s}^{2}=({a}^{2}{cos}^{2}u+{c}^{2}{sin}^{2}u)d{u}^{2}+{a}^{2}{sin}^{2}u\phantom{\rule{.3em}{0ex}}d{v}^{2}$

This metric is diagonal like the last but with functional dependence for the first metric function. The geodesic equations are a bit more complicated:

$\begin{array}{l}\stackrel{\xb7\xb7}{u}=-\frac{{E}_{1}}{2E}{\stackrel{\xb7}{u}}^{2}+\frac{{G}_{1}}{2E}{\stackrel{\xb7}{v}}^{2}=\frac{sinucosu}{{a}^{2}{cos}^{2}u+{c}^{2}{sin}^{2}u}\left[\right({a}^{2}-{c}^{2}){\stackrel{\xb7}{u}}^{2}+{a}^{2}{\stackrel{\xb7}{v}}^{2}]\\ \stackrel{\xb7\xb7}{v}=-\frac{{G}_{1}}{G}\stackrel{\xb7}{u}\stackrel{\xb7}{v}=-2cotu\phantom{\rule{.3em}{0ex}}\stackrel{\xb7}{u}\stackrel{\xb7}{v}\end{array}$

Simplification is possible for the first equation, but it will be left in this form to avoid introducing additional singularities. It reduces to the first equation for the spherical surface when $a=c$ as expected.

Numerical integration for an arbitrary starting point and a spray of geodesics around it:

The geodesics now visibly trace out an ellipsoid of rotation from any starting point. One major difference from the spherical surface is that these geodesics do not in general close upon themselves, but cover the surface densely as the maximum interval is increased. The initial velocities are again divided by their factors in the metric to reduce artifacts from the coordinate system.

A further generalization of the spherical surface is an ellipsoid parametrized with

$\begin{array}{l}x=asinucosv\\ y=bsinusinv\\ z=ccosu\end{array}\phantom{\rule{4em}{0ex}}0\le u\le \pi \phantom{\rule{1em}{0ex}},\phantom{\rule{1em}{0ex}}0\le v\le 2\pi $

where there are now three independent constants scaling each axial direction. The metric formed by summing squared differentials is

$\begin{array}{l}d{s}^{2}=\left[{cos}^{2}u\right({a}^{2}{cos}^{2}v+{b}^{2}{sin}^{2}v)+{c}^{2}{sin}^{2}u]d{u}^{2}\\ \phantom{\rule{6em}{0ex}}+2({b}^{2}-{a}^{2})sinucosusinvcosv\phantom{\rule{.3em}{0ex}}dudv\\ \phantom{\rule{6em}{0ex}}+{sin}^{2}u({a}^{2}{sin}^{2}v+{b}^{2}{cos}^{2}v)d{\phi}^{2}\end{array}$

All metric functions here are nonzero and dependent on both variables of parametrization. The corresponding geodesic equations are so complicated that there is not much point in writing them out in full, apart from in the code itself.

Numerical integration for an arbitrary starting point and a spray of geodesics around it:

The geodesics now trace out a general ellipsoid from any starting point. Simplifications with double-angle identities are used in the code to reduce function calls, but this beast still can take some time to evaluate. The equations are mathematically less stable under numerical integration than the previous two examples, so input parameter ranges have been restricted.

This last example indicates how one can visualize geodesics for any complicated two-dimensional surface. The underlying code already has the full geodesic equations for the general case. All that would need to change for other surfaces is the set of metric function definitions and their partial derivatives in the code.

The remainder of this presentation will visualize a couple less complicated compact surfaces for which the geodesic equations are easily expressed. While one can visualize noncompact surfaces similarly, the results are less striking than for compact surfaces because geodesics mostly run off to infinity.

The surface of a torus can be parametrized with

$\begin{array}{l}x=(a+bsinu)cosv\\ y=(a+bsinu)sinv\\ z=bcosu\end{array}\phantom{\rule{4em}{0ex}}0\le u\le 2\pi \phantom{\rule{1em}{0ex}},\phantom{\rule{1em}{0ex}}0\le v\le 2\pi $

where $a>b$ and the first angular variable runs from the top of the torus around the circumference of the tube. The metric formed by summing squared differentials is

$d{s}^{2}={b}^{2}d{u}^{2}+(a+bsinu{)}^{2}d{v}^{2}$

The metric is diagonal and depends on only one angular variable. The geodesic equations are

$\begin{array}{l}\stackrel{\xb7\xb7}{u}=\frac{{G}_{1}}{2E}{\stackrel{\xb7}{v}}^{2}=\frac{1}{b}(a+bsinu)cosu\phantom{\rule{.3em}{0ex}}{\stackrel{\xb7}{v}}^{2}\\ \stackrel{\xb7\xb7}{v}=-\frac{{G}_{1}}{G}\stackrel{\xb7}{u}\stackrel{\xb7}{v}=-\frac{2bcosu}{a+bsinu}\stackrel{\xb7}{u}\stackrel{\xb7}{v}\end{array}$

and do not have singularities in the first angular variable, unlike the surfaces of the sphere and ellipsoid of revolution, as long as *a* is nonzero.

Numerical integration for an arbitrary starting point and a spray of geodesics around it:

Like the sphere, a toroidal surface can have closed geodesics, but they are special cases. One is visible with the default settings: experiment a bit to find others.

A surface similar to an ellipsoid can be generated by revolution of the ovals of Cassini. Like ellipses these ovals are defined with respect to two centers or foci. For an ellipse the sum of distances to the foci is constant, but for the ovals of Cassini it is the product of the distances. If the foci lie on the *x*-axis equal distances from the origin, the ovals have the implicit equation

$\left[\right(x-a{)}^{2}+{y}^{2}]\left[\right(x+a{)}^{2}+{y}^{2}]={b}^{4}$

A parametrization of the curves is found by setting

$x=R\left(u\right)cosu\phantom{\rule{5em}{0ex}}y=R\left(u\right)sinu$

and solving for the introduced radial variable as a function of angle:

$\begin{array}{c}{R}^{4}-2{a}^{2}{R}^{2}cos2u+{a}^{4}={b}^{4}\\ \\ R\left(u\right)=\pm \sqrt{{a}^{2}cos2u\pm \sqrt{{b}^{4}-{a}^{4}{sin}^{2}2u}}\end{array}$

The allowed domain of the angular variable *u* is chosen to keep the inner radical real, and that depends on the relative values of the two parameters. When
$b\ge a$
the entire angular domain
$0\le u\le 2\pi $
is allowed, otherwise it is restricted to

$-\frac{1}{2}{sin}^{-1}\frac{{b}^{2}}{{a}^{2}}\le u\le \frac{1}{2}{sin}^{-1}\frac{{b}^{2}}{{a}^{2}}\phantom{\rule{1em}{0ex}},\phantom{\rule{1em}{0ex}}b<a$

On the unrestricted domain the positive signs of the radicals are used, while on the restricted domain all four combinations of signs are necessary to draw the entire curve. Here is how it looks as the parameters are varied:

The ovals becomes circles in the limit
$b\to \infty $
for fixed *a*, as well as
$a\to 0$
for nonzero *b*.

A surface of revolution can be formed by rotation about either the *z*-axis as for the ellipsoid above or about the *x*-axis. In the interest of possible future application, the latter will be chosen, with the parametrization

$\begin{array}{l}x=R\left(u\right)cosu\\ y=R\left(u\right)sinusinv\\ z=R\left(u\right)sinucosv\end{array}\phantom{\rule{4em}{0ex}}0\le u\le 2\pi \phantom{\rule{1em}{0ex}},\phantom{\rule{1em}{0ex}}0\le v\le 2\pi $

with the restriction $b\ge a$ for simplicity. The metric formed by summing squared differentials is

$d{s}^{2}=[{R}^{2}+{{R}^{\prime}}^{2}]d{u}^{2}+{R}^{2}{sin}^{2}u\phantom{\rule{.3em}{0ex}}d{v}^{2}$

Like the ellipsoid of rotation and the torus, the metric is diagonal and depends on only one angular variable. As an aside, for revolution about the *z*-axis the sine here would be replaced by a cosine.

The geodesic equations for the chosen axis of revolution are

$\begin{array}{l}\stackrel{\xb7\xb7}{u}=-\frac{{E}_{1}}{2E}{\stackrel{\xb7}{u}}^{2}+\frac{{G}_{1}}{2E}{\stackrel{\xb7}{v}}^{2}=-\frac{1}{2}\frac{dln[{R}^{2}+{{R}^{\prime}}^{2}]}{du}{\stackrel{\xb7}{u}}^{2}+\frac{R{R}^{\prime}{sin}^{2}u+{R}^{2}sinucosu}{{R}^{2}+{{R}^{\prime}}^{2}}{\stackrel{\xb7}{v}}^{2}\\ \stackrel{\xb7\xb7}{v}=-\frac{{G}_{1}}{G}\stackrel{\xb7}{u}\stackrel{\xb7}{v}=-2[\frac{{R}^{\prime}}{R}+cotu]\stackrel{\xb7}{u}\stackrel{\xb7}{v}\end{array}$

The second equation has singularities in the first angular variable like the surfaces of the sphere and ellipsoid of revolution. Differentiating the defining equation for $R\left(u\right)$ gives

${R}^{\prime}=-\frac{{a}^{2}sin2u}{{R}^{2}-{a}^{2}cos2u}R=-\frac{{a}^{2}sin2u}{\sqrt{{b}^{4}-{a}^{4}{sin}^{2}2u}}R$

from which one can find

${R}^{2}+{{R}^{\prime}}^{2}=\frac{{b}^{4}}{{b}^{4}-{a}^{4}{sin}^{2}2u}{R}^{2}$

The geodesic equations then can be written fairly compactly as

$\begin{array}{l}\stackrel{\xb7\xb7}{u}=-[\frac{{R}^{\prime}}{R}+2(\frac{{R}^{\prime}}{R}{)}^{2}cot2u]{\stackrel{\xb7}{u}}^{2}\\ \phantom{\rule{5em}{0ex}}+(1-\frac{{a}^{4}}{{b}^{4}}{sin}^{2}2u)[sinucosu+\frac{{R}^{\prime}}{R}{sin}^{2}u]{\stackrel{\xb7}{v}}^{2}\\ \stackrel{\xb7\xb7}{v}=-2[\frac{{R}^{\prime}}{R}+cotu]\stackrel{\xb7}{u}\stackrel{\xb7}{v}\end{array}$

with the ratio $\frac{{R}^{\prime}}{R}$ defined above. As a check, since $\frac{{R}^{\prime}}{R}\to 0$ for either $b\to \infty $ or $a\to 0$ , these equations become those for the spherical surface in both limits as expected.

Numerical integration for an arbitrary starting point and a spray of geodesics around it:

The geodesics for $b<a$ will be left as a possible future addition.

*Uploaded 2018.04.03*
analyticphysics.com