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

d2xi ds2 +Γkmi dxk ds dxm 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

Γkli =12 gim [ gml xk + gmk xl - gkl xm]

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) y=y (u,v) 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:

ds2 =dx2 +dy2 +dz2 =Edu2 +2Fdudv +Gdv2

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

g=[ EF FG ] g1 =1Δ [ GF FE ] , Δ=detg =EG-F2

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

Γ111 =E1G -2F1F +E2F 2Δ Γ121 =Γ211 =G1F +E2G 2Δ Γ221 =G1G +2F2G -G2F 2Δ Γ112 =E1F +2F1E -E2E 2Δ Γ122 =Γ212 =G1E -E2F 2Δ Γ222 =G1F -2F2F +G2E 2Δ

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=12 [E u·2 +2F u· v· +G v·2 ]

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

dds L q· i =L qi

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

dds [Eu· +Fv· ] =12 [E1 u·2 +2F1 u· v· +G1 v·2 ] dds [Fu· +Gv· ] =12 [E2 u·2 +2F2 u· v· +G2 v·2 ]

Expanding the left-hand sides and rearranging

Eu ·· +Fv ·· =12 [E1 u·2 -2E2 u· v· +(G1 -2F2) v·2 ] Fu ·· +Gv ·· =12 [(E2 -2F1) u·2 -2G1 u· v· -G2 v·2 ]

so that the second derivatives of the independent variables are

u·· =E1G +2F1F -E2F 2Δ u·2 +G1F -E2GΔ u· v· +G1G -2F2G +G2F 2Δ v·2 v·· =E1F -2F1E +E2E 2Δ u·2 +G1E +E2F Δ u· v· +G1F +2F2F -G2E 2Δ v·2

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

x=asinucosv y=asinusinv z=acosu 0uπ , 0v2π

The corresponding two-dimensional metric is

ds2 =dx2 +dy2 +dz2 =a2( du2 +sin2u dv2)

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:

u ·· =G1 2E v·2 =sinucosu v·2 v ·· =G1G u· v· =2cotu u· v·

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 sin u in the metric, it must be divided by this quantity to achieve parity with the variable 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 Math.

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

x=rsinucosv y=rsinusinv z=rcosu

and evaluating the corresponding metric:

ds2 =dx2 +dy2 +dz2 =dr2 +r2 du2 +r2 sin2u dv2

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

x=asinucosv y=asinusinv z=ccosu 0uπ , 0v2π

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

ds2 =(a2 cos2u +c2 sin2u) du2 +a2 sin2u dv2

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

u ·· =E1 2E u·2 +G1 2E v·2 =sinucosu a2cos2u +c2 sin2u [(a2 -c2) u·2 +a2 v·2 ] v·· =G1G u· v· =2cotu u· v·

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

x=asinucosv y=bsinusinv z=ccosu 0uπ , 0v2π

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

ds2 =[cos2u (a2 cos2v +b2 sin2v) +c2 sin2u] du2 +2(b2 -a2) sinucosu sinvcosv dudv +sin2u (a2 sin2v +b2 cos2v) dφ2

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

x=(a +bsinu)cosv y=(a +bsinu)sinv z=bcosu 0u2π , 0v2π

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

ds2 =b2du2 +(a+bsinu )2 dv2

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

u ·· =G1 2E v·2 =1b (a+bsinu) cosu v·2 v·· =G1G u· v· =2bcosu a+bsinu u· v·

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

[(x-a )2 +y2] [(x+a )2 +y2] =b4

A parametrization of the curves is found by setting

x=R(u) cosu y=R(u) sinu

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

R4 -2a2 R2cos2u +a4 =b4   R(u) =±a2 cos2u ±b4 -a4 sin22u

The domain of the angular variable u and signs of radicals are chosen to keep the expression real, and that depends on the relative values of the two parameters. When b>a the entire angular domain 0u2π is allowed, along with the positive signs of the radicals. When ba the angular variable is restricted to

12 sin1 b2a2 u12 sin1 b2a2 , ba

to keep the inner radical real, and all four combinations of signs are necessary to draw the entire curve, except for the the special case b=a where only the inner positive sign can be used. Here is how the curve looks as the parameters are varied:

The ovals becomes circles in the limit b for fixed a, as well as a0 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

x=R(u) cosu y=R(u) sinusinv z=R(u) sinucosv 0u2π , 0v2π

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

ds2 =[R2 +R2] du2 +R2 sin2u dv2

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

u ·· =E1 2E u·2 +G1 2E v·2 =12 d ln[R2 +R2 ] du u·2 +RR sin2u +R2sinucosu R2 +R2 v·2 v·· =G1G u· v· =2 [RR +cotu] u· v·

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(u) gives

R =a2 sin2u R2 -a2 cos2u R =a2 sin2u b4 -a4 sin22u R

from which one can find

R2 +R2 =b4 b4-a4 sin22u R2

The geodesic equations then can be written fairly compactly as

u·· =[ RR +2(RR )2cot2u] u·2 +(1 -a4 b4 sin22u) [sinucosu +RR sin2u] v·2 v·· =2[ RR +cotu] u· v·

with the ratio RR defined above. As a check, since RR 0 for either b or a0 , 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 — Updated 2019.11.24