Introduction
In most presentations of Riemannian geometry, e.g. O’Neill (1983) and Wikipedia, the fundamental theorem of Riemannian geometry (“the miracle of Riemannian geometry”) is given: that for any semi-Riemannian manifold there is a unique torsion-free metric connection. I assume partly because of this and partly because the major application of Riemannian geometry is General Relativity, connections with torsion are given little if any attention.
It turns out we are all very familiar with a connection with torsion: the Mercator projection. Some mathematical physics texts, e.g. Nakahara (2003), allude to this but leave the details to the reader. Moreover, this connection respects the metric induced from Euclidean space.
We use SageManifolds to assist with the calculations. We hint at how this might be done more slickly in Haskell.
A Cartographic Aside
%matplotlib inline
/Applications/SageMath/local/lib/python2.7/site-packages/traitlets/traitlets.py:770: DeprecationWarning: A parent of InlineBackend._config_changed has adopted the new @observe(change) API
clsname, change_or_name), DeprecationWarning)
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import cartopy
import cartopy.crs as ccrs
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
plt.figure(figsize=(8, 8))
ax = plt.axes(projection=cartopy.crs.Mercator())
ax.gridlines()
ax.add_feature(cartopy.feature.LAND)
ax.add_feature(cartopy.feature.COASTLINE)
plt.show()

png
We can see Greenland looks much broader at the North than in the middle. But if we use a polar projection (below) then we see this is not the case. Why then is the Mercator projection used in preference to e.g. the polar projection or the once controversial Gall-Peters – see here for more on map projections.
plt.figure(figsize=(8, 8))
bx = plt.axes(projection=cartopy.crs.NorthPolarStereo())
bx.set_extent([-180, 180, 90, 50], ccrs.PlateCarree())
bx.gridlines()
bx.add_feature(cartopy.feature.LAND)
bx.add_feature(cartopy.feature.COASTLINE)
plt.show()

png
Colophon
This is written as an Jupyter notebook. In theory, it should be possible to run it assuming you have installed at least sage and Haskell. To publish it, I used
jupyter-nbconvert --to markdown Mercator.ipynb
pandoc -s Mercator.md -t markdown+lhs -o Mercator.lhs \
--filter pandoc-citeproc --bibliography DiffGeom.bib
BlogLiteratelyD --wplatex Mercator.lhs > Mercator.html
Not brilliant but good enough.
Some commands to jupyter
to display things nicely.
%display latex
viewer3D = 'tachyon'
Warming Up With SageManifolds
Let us try a simple exercise: finding the connection coefficients of the Levi-Civita connection for the Euclidean metric on in polar co-ordinates.
Define the manifold.
N = Manifold(2, 'N',r'\mathcal{N}', start_index=1)
Define a chart and frame with Cartesian co-ordinates.
ChartCartesianN.<x,y> = N.chart()
FrameCartesianN = ChartCartesianN.frame()
Define a chart and frame with polar co-ordinates.
ChartPolarN.<r,theta> = N.chart()
FramePolarN = ChartPolarN.frame()
The standard transformation from Cartesian to polar co-ordinates.
cartesianToPolar = ChartCartesianN.transition_map(ChartPolarN, (sqrt(x^2 + y^2), arctan(y/x)))
print(cartesianToPolar)
Change of coordinates from Chart (N, (x, y)) to Chart (N, (r, theta))
print(latex(cartesianToPolar.display()))
cartesianToPolar.set_inverse(r * cos(theta), r * sin(theta))
Check of the inverse coordinate transformation:
x == x
y == y
r == abs(r)
theta == arctan(sin(theta)/cos(theta))
Now we define the metric to make the manifold Euclidean.
g_e = N.metric('g_e')
g_e[1,1], g_e[2,2] = 1, 1
We can display this in Cartesian co-ordinates.
print(latex(g_e.display(FrameCartesianN)))
And we can display it in polar co-ordinates
print(latex(g_e.display(FramePolarN)))
Next let us compute the Levi-Civita connection from this metric.
nab_e = g_e.connection()
print(latex(nab_e))
If we use Cartesian co-ordinates, we expect that . Only non-zero entries get printed.
print(latex(nab_e.display(FrameCartesianN)))
Just to be sure, we can print out all the entries.
print(latex(nab_e[:]))
In polar co-ordinates, we get
print(latex(nab_e.display(FramePolarN)))
Which we can rew-rewrite as
with all other entries being 0.
The Sphere
We define a 2 dimensional manifold. We call it the 2-dimensional (unit) sphere but it we are going to remove a meridian to allow us to define the desired connection with torsion on it.
S2 = Manifold(2, 'S^2', latex_name=r'\mathbb{S}^2', start_index=1)
print(latex(S2))
To start off with we cover the manifold with two charts.
polar.<th,ph> = S2.chart(r'th:(0,pi):\theta ph:(0,2*pi):\phi'); print(latex(polar))
mercator.<xi,ze> = S2.chart(r'xi:(-oo,oo):\xi ze:(0,2*pi):\zeta'); print(latex(mercator))
We can now check that we have two charts.
print(latex(S2.atlas()))
We can then define co-ordinate frames.
epolar = polar.frame(); print(latex(epolar))
emercator = mercator.frame(); print(latex(emercator))
And define a transition map and its inverse from one frame to the other checking that they really are inverses.
xy_to_uv = polar.transition_map(mercator, (log(tan(th/2)), ph))
xy_to_uv.set_inverse(2*arctan(exp(xi)), ze)
Check of the inverse coordinate transformation:
th == 2*arctan(sin(1/2*th)/cos(1/2*th))
ph == ph
xi == xi
ze == ze
We can define the metric which is the pullback of the Euclidean metric on .
g = S2.metric('g')
g[1,1], g[2,2] = 1, (sin(th))^2
And then calculate the Levi-Civita connection defined by it.
nab_g = g.connection()
print(latex(nab_g.display()))
We know the geodesics defined by this connection are the great circles.
We can check that this connection respects the metric.
print(latex(nab_g(g).display()))
And that it has no torsion.
print(latex(nab_g.torsion().display()))
0
A New Connection
Let us now define an orthonormal frame.
ch_basis = S2.automorphism_field()
ch_basis[1,1], ch_basis[2,2] = 1, 1/sin(th)
e = S2.default_frame().new_frame(ch_basis, 'e')
print(latex(e))
We can calculate the dual 1-forms.
dX = S2.coframes()[2] ; print(latex(dX))
print(latex((dX[1], dX[2])))
print(latex((dX[1][:], dX[2][:])))
In this case it is trivial to check that the frame and coframe really are orthonormal but we let sage
do it anyway.
print(latex(((dX[1](e[1]).expr(), dX[1](e[2]).expr()), (dX[2](e[1]).expr(), dX[2](e[2]).expr()))))
Let us define two vectors to be parallel if their angles to a given meridian are the same. For this to be true we must have a connection with
.
nab = S2.affine_connection('nabla', latex_name=r'\nabla')
nab.add_coef(e)
Displaying the connection only gives the non-zero components.
print(latex(nab.display(e)))
For safety, let us check all the components explicitly.
print(latex(nab[e,:]))
Of course the components are not non-zero in other frames.
print(latex(nab.display(epolar)))
print(latex(nab.display(emercator)))
This connection also respects the metric .
print(latex(nab(g).display()))
Thus, since the Levi-Civita connection is unique, it must have torsion.
print(latex(nab.torsion().display(e)))
The equations for geodesics are
Explicitly for both variables in the polar co-ordinates chart.
We can check that and
are solutions although
sage
needs a bit of prompting to help it.
t = var('t'); a = var('a')
print(latex(diff(a * log(tan(t/2)),t).simplify_full()))
We can simplify this further by recalling the trignometric identity.
print(latex(sin(2 * t).trig_expand()))
print(latex(diff (a / sin(t), t)))
In the mercator co-ordinates chart this is
In other words: straight lines.
Reparametersing with we obtain
Let us draw such a curve.
R.<t> = RealLine() ; print(R)
Real number line R
print(dim(R))
1
c = S2.curve({polar: [2*atan(exp(-t/10)), t]}, (t, -oo, +oo), name='c')
print(latex(c.display()))
c.parent()
c.plot(chart=polar, aspect_ratio=0.1)

png
It’s not totally clear this is curved so let’s try with another example.
d = S2.curve({polar: [2*atan(exp(-t)), t]}, (t, -oo, +oo), name='d')
print(latex(d.display()))
d.plot(chart=polar, aspect_ratio=0.2)

png
Now it’s clear that a straight line is curved in polar co-ordinates.
But of course in Mercator co-ordinates, it is a straight line. This explains its popularity with mariners: if you draw a straight line on your chart and follow that bearing or rhumb line using a compass you will arrive at the end of the straight line. Of course, it is not the shortest path; great circles are but is much easier to navigate.
c.plot(chart=mercator, aspect_ratio=0.1)

png
d.plot(chart=mercator, aspect_ratio=1.0)

png
We can draw these curves on the sphere itself not just on its charts.
R3 = Manifold(3, 'R^3', r'\mathbb{R}^3', start_index=1)
cart.<X,Y,Z> = R3.chart(); print(latex(cart))
Phi = S2.diff_map(R3, {
(polar, cart): [sin(th) * cos(ph), sin(th) * sin(ph), cos(th)],
(mercator, cart): [cos(ze) / cosh(xi), sin(ze) / cosh(xi),
sinh(xi) / cosh(xi)]
},
name='Phi', latex_name=r'\Phi')
We can either plot using polar co-ordinates.
graph_polar = polar.plot(chart=cart, mapping=Phi, nb_values=25, color='blue')
show(graph_polar, viewer=viewer3D)

png
Or using Mercator co-ordinates. In either case we get the sphere (minus the prime meridian).
graph_mercator = mercator.plot(chart=cart, mapping=Phi, nb_values=25, color='red')
show(graph_mercator, viewer=viewer3D)

png
We can plot the curve with an angle to the meridian of
graph_c = c.plot(mapping=Phi, max_range=40, plot_points=200, thickness=2)
show(graph_polar + graph_c, viewer=viewer3D)

png
And we can plot the curve at angle of to the meridian.
graph_d = d.plot(mapping=Phi, max_range=40, plot_points=200, thickness=2, color="green")
show(graph_polar + graph_c + graph_d, viewer=viewer3D)

png
Haskell
With automatic differentiation and symbolic numbers, symbolic differentiation is straigtforward in Haskell.
> import Data.Number.Symbolic
> import Numeric.AD
>
> x = var "x"
> y = var "y"
>
> test xs = jacobian ((\x -> [x]) . f) xs
> where
> f [x, y] = sqrt $ x^2 + y^2
ghci> test [1, 1]
[[0.7071067811865475,0.7071067811865475]]
ghci> test [x, y]
[[x/(2.0*sqrt (x*x+y*y))+x/(2.0*sqrt (x*x+y*y)),y/(2.0*sqrt (x*x+y*y))+y/(2.0*sqrt (x*x+y*y))]]
Anyone wishing to take on the task of producing a Haskell version of sagemanifolds is advised to look here before embarking on the task.
Appendix A: Conformal Equivalence
Agricola and Thier (2004) shows that the geodesics of the Levi-Civita connection of a conformally equivalent metric are the geodesics of a connection with vectorial torsion. Let’s put some but not all the flesh on the bones.
The Koszul formula (see e.g. (O’Neill 1983)) characterizes the Levi-Civita connection
Being more explicit about the metric, this can be re-written as
Let be the Levi-Civita connection for the metric
where
. Following [Gadea2010] and substituting into the Koszul formula and then applying the product rule
Where as usual the vector field, for
, is defined via
.
Let’s try an example.
nab_tilde = S2.affine_connection('nabla_t', r'\tilde_{\nabla}')
f = S2.scalar_field(-ln(sin(th)), name='f')
for i in S2.irange():
for j in S2.irange():
for k in S2.irange():
nab_tilde.add_coef()[k,i,j] = \
nab_g(polar.frame()[i])(polar.frame()[j])(polar.coframe()[k]) + \
polar.frame()[i](f) * polar.frame()[j](polar.coframe()[k]) + \
polar.frame()[j](f) * polar.frame()[i](polar.coframe()[k]) + \
g(polar.frame()[i], polar.frame()[j]) * \
polar.frame()[1](polar.coframe()[k]) * cos(th) / sin(th)
print(latex(nab_tilde.display()))
print(latex(nab_tilde.torsion().display()))
0
g_tilde = exp(2 * f) * g
print(latex(g_tilde.parent()))
print(latex(g_tilde[:]))
nab_g_tilde = g_tilde.connection()
print(latex(nab_g_tilde.display()))
It’s not clear (to me at any rate) what the solutions are to the geodesic equations despite the guarantees of Agricola and Thier (2004). But let’s try a different chart.
print(latex(nab_g_tilde[emercator,:]))
In this chart, the geodesics are clearly straight lines as we would hope.
References
Agricola, Ilka, and Christian Thier. 2004. “The geodesics of metric connections with vectorial torsion.” Annals of Global Analysis and Geometry 26 (4): 321–32. doi:10.1023/B:AGAG.0000047509.63818.4f.
Nakahara, M. 2003. “Geometry, Topology and Physics.” Text 822: 173–204. doi:10.1007/978-3-642-14700-5.
O’Neill, B. 1983. Semi-Riemannian Geometry with Applications to Relativity, 103. Pure and Applied Mathematics. Elsevier Science. https://books.google.com.au/books?id=CGk1eRSjFIIC.
It seems my observations on cartography have been lost – sigh. I will try to reconstruct them but not today.
Hi Dominic, great post! Is the Mercator.ipynb file available for download on Github or somewhere?
Glad you enjoyed it 🙂 I put it here: https://github.com/idontgetoutmuch/DifferentialGeometry but be warned you may need to install a *lot* of stuff. At least sage manifolds. If you want to draw the maps then you will need cartopy. If you want to try the Haskell then clearly Haskell and the requisite libraries. Good luck – let me know how you get on and if I can help. Also you will probably want to remove the print(latex(…)) wrapping. I put that in to generate the LaTeX for the blog post. I couldn’t get IHaskell to work so the Haskell snippet was added by hand.