## Tuesday, 6 August 2019

### Question

 A diagonal metric in 4-space
Imagine we had a diagonal metric $g_{\mu\nu}$. Show that the Christoffel symbols are given by
\begin{align}
\Gamma_{\mu\nu}^\lambda&=0&\phantom {10000}(1)\nonumber\\
\Gamma_{\mu\mu}^\lambda&=-\frac{1}{2}\left(g_{\lambda\lambda}\right)^{-1}\partial_\lambda g_{\mu\mu}&\phantom {10000}(2)\nonumber\\
\Gamma_{\mu\lambda}^\lambda&=\partial_\mu\left(\ln{\sqrt{\left|g_{\lambda\lambda}\right|}}\right)&\phantom {10000}(3)\nonumber\\
\Gamma_{\lambda\lambda}^\lambda&=\partial_\lambda\left(\ln{\sqrt{\left|g_{\lambda\lambda}\right|}}\right)&\phantom {10000}(4)\nonumber
\end{align}In these expressions, $\mu\neq\nu\neq\lambda$ and repeated indices are not summed over.

At last I have recovered from the grind of that geodesic on a sphere and completed this question completely. It involved a bit of index manipulation, some knowledge about the inverse of a diagonal matrix and the chain rule (taken slowly).

All three pages in Ex 3.03 Diagonal metric.pdf.

## Saturday, 3 August 2019

### Geodesic equation on a sphere

I was looking for the geodesic equation on the surface of a sphere. We start with the general geodesic equation (2), the metric and the Christoffel symbol (3), (1). We arrive at the geodesic differential equations for the surface at (4), (5). I calculated these in two different ways to give me confidence. Both are fiddly but fairly simple. Since then I have found other references that confirm my equations.

At Great Circles we have also found (in three ways) an equation for a great circle (6) and checked it graphically. We know that is a geodesic. Differentiating (6) was at first difficult but when we do it and put it into (5) it disagrees. This indicates that the differentiation is wrong or the geodesic differential equations are wrong. But I have triple checked everything!

I started this at the end of March and it is now 3 August. I have had some diversions on the way:
• My niece got married in London (5 days)
• My computer died (7 days). I now have a giant 4500x3000 pixel 27.5" screen. Much better than 1920x1080 15" for formula editing and movies. I also improved the equation macros.
• Got right to reside permanently in Germany (1 day).
• Programming and managing distribution of 1064 items to eight brothers from the contents of my deceased father's house (4 days). (The programming inspired me to start programming Penrose tiles.)
• Validated the geodesic equation I have found by plotting various ones with my 3D graph plotter.
• Enhancing 3D graph plotter to show animations. (2 days)
• Writing a program to draw Penrose tiles (3 months)
So it's been a month really that I have been working on this problem. That's too long and it seems like a year.

I was in despair until Orodruin came to the rescue on Physics Forums in answer to my question. As ever he was slightly obscure and said "Your equation for the great circle is not affinely parametrised." I had not hear of this word "affine" before and poked around the internet, found a hint from Professor Govindarajan and then checked Carroll's book. There was affine parameter in the index on page 109. The geodesic equation is on page 106 and I had read to  the end of the section on page 108. Grrr! Orodruin's tip, Govindarajan's hint and Carrrol carried me over the finishing line. At last I could prove that the great circle equation did indeed satisfy the geodesic equation after a bit of indirect reparameterization. Phew!

It is interesting for many reasons including that the great circle equation could not be reparametrized directly but that only the derivative of the of its parameter with respect to an affine parameter was needed.

### Here's the problem

The Christoffel symbol (torsion-free and metric compatible)
\begin{align}
\Gamma_{\mu\nu}^\sigma=\frac{1}{2}g^{\sigma\rho}\left(\partial_\mu g_{\nu\rho}+\partial_\nu g_{\rho\mu}-\partial_\rho g_{\mu\nu}\right)&\phantom {10000}(1)\nonumber
\end{align}and the geodesic equation (Carroll's 3.44)
\begin{align}
G^\sigma\equiv\frac{d^2x^\sigma}{d\lambda^2}+\Gamma_{\mu\nu}^\sigma\frac{dx^\mu}{d\lambda}\frac{dx^\nu}{d\lambda}=0&\phantom {10000}(2)\nonumber
\end{align}$x^\mu\left(\lambda\right)$ is a parameterised curve. If it satisfies $G^\sigma=0$ then vectors are parallel transported on it and it is a geodesic. This is the definition of a geodesic in the manifold. Clearly $G^\sigma$ has $n$ components on an $n$-dimensional manifold and (2) is $n$ equations.

With $x^0=\phi,\ x^1=\theta$ (polar and azimuthal angle - slightly unconventional) the metric and inverse metric are
\begin{align}
g_{\mu\nu}=\left(\begin{matrix}1&0\\0&\sin^2{\phi}\\\end{matrix}\right)\ \ ,\ \ g^{\mu\nu}=\left(\begin{matrix}1&0\\0&\sin^{-2}{\phi}\\\end{matrix}\right)&\phantom {10000}(3)\nonumber
\end{align}I have checked the metric in many ways. The various ways of defining polar coordinates added to the confusion (also described in Great Circles).

### The geodesic equations for a sphere and the great circle equation

\begin{align}
\frac{d^2\phi}{d\lambda^2}-\sin{\phi}\cos{\phi}\left(\frac{d\theta}{d\lambda}\right)^2=0&\phantom {10000}(4)\nonumber\\
\frac{d^2\theta}{d\lambda^2}+2\cot{\phi}\frac{d\theta}{d\lambda}\frac{d\phi}{d\lambda}=0&\phantom {10000}(5)\nonumber\\
\theta=\lambda\ \ ,\ \ \phi=\tan^{-1}{\left(\frac{C}{A\cos{\lambda}+B\sin{\lambda}}\right)}&\phantom {10000}(6)\nonumber
\end{align}It is very simple to solve the geodesic equation on a plane. I did that for an exercise when I thought I was going insane. Connecting up (4),(5),(6) was much harder. It's in

Commentary 3.3 Parallel transport and geodesics.pdf (7 pages)

### Great circles

We know that a great circle is a line between two points on a sphere which is the intersection of a plane through the sphere's centre and the two points and the surface of the sphere. We also know that the shorter distance between the two points is the shortest distance between the two points if we are confined to the surface of the sphere.

Here we find the equation for a great circle and prove it is the same as the one given (rather ambiguously) in Wolfram Mathsworld and, loosely, the one by Professor Govindarajan. I also plotted some great circles to test the equations visually. That's the video. The reason for testing the equations so rigorously is that they did not seem to agree with Carroll's geodesic equation at (3.44). Eventually I showed that they did.

### Polar coordinates

First we must deal with the angular coordinates $\phi,\theta$. Some sources have $\theta$ as the longitude (azimuthal angle) and $\phi$ as the colatitude (angle from north pole) in other sources they are swapped around. I tried to follow the majority and did the former with $\phi,\theta$ in that order. Then Wikipedia told me that "in one system frequently encountered in physics $(r,\theta,\phi)$ gives the radial distance, polar angle, and azimuthal angle, whereas in another system used in many mathematics books $(r,\theta,\phi)$ gives the radial distance, azimuthal angle, and polar angle. ... Other conventions are also used, so great care needs to be taken to check which one is being used." Not only are the meanings of $\phi,\theta$ swapped but also the order!! I have followed neither convention. Boo hoo. At Mathworld a table of seven variations is given. They use the same as me, but not in the same order. Carroll and Govindarajan follow the physicist convention. In future will follow the physicist convention but here and in the upcoming post on the parallel transport and geodesics, I stick to my own.

### The great circle equations

Mine
\begin{align}
\phi=\tan^{-1}{\left(\frac{A_z}{A_x\cos{\theta}+A_y\sin{\theta}}\right)}&\phantom {10000}\nonumber
\end{align}Wolfram Mathsworld
\begin{align}
\cos{\theta}\sin{\phi}\sin{c_2}+\sin{\theta}\sin{\phi}\cos{c_2}+c_1\cos{\phi}=0&\phantom {10000}\nonumber
\end{align}Professor Govindarajan's
\begin{align}
\cot{\phi}=A\cos{\left(\theta+\theta_0\right)}&\phantom {10000}\nonumber
\end{align}There are two or three constants in each equation.

Read the full details at Commentary 3.3 Great circle.pdf
The spreadsheet which generated the video is at Commentary 3.3 Parallel transport and geodesics.xlsm

## Sunday, 28 July 2019

### Question about geodesic on sphere

I am working from Sean Carroll's Spacetime and Geometry : An Introduction to General Relativity and have got to the geodesic equation. I wanted to test it on the surface of a sphere where I know that great circles are geodesics and is about the simplest non-trivial case I can think of.

Carroll derives the geodesic equation:
\begin{align}
\frac{d^2x^\sigma}{d\lambda^2}+\Gamma_{\mu\nu}^\sigma\frac{dx^\mu}{d\lambda}\frac{dx^\nu}{d\lambda}=0&\phantom {10000}(1)\nonumber
\end{align}$\Gamma_{\mu\nu}^\sigma$ is the Christoffel symbol (torsion-free and metric compatible)
\begin{align}
\Gamma_{\mu\nu}^\sigma=\frac{1}{2}g^{\sigma\rho}\left(\partial_\mu g_{\nu\rho}+\partial_\nu g_{\rho\mu}-\partial_\rho g_{\mu\nu}\right)&\phantom {10000}(2)\nonumber
\end{align}In this case the indices are 0,1 and $x^0=\phi$ the colatitude (angle from north pole), $\ x^1=\theta$ , longitude. The metric and inverse metric are
\begin{align}
g_{\mu\nu}=\left(\begin{matrix}1&0\\0&\sin^2{\phi}\\\end{matrix}\right)\ \ ,\ \ g^{\mu\nu}=\left(\begin{matrix}1&0\\0&\sin^{-2}{\phi}\\\end{matrix}\right)&\phantom {10000}(3)\nonumber
\end{align}Those should give me equations for $\phi,\theta$ parameterized by $\lambda$.

I now expand the second term in (1) for $\sigma=1$ and using the fact that $\Gamma$ is torsion-free ($\Gamma_{\mu\nu}^\sigma=\Gamma_{\nu\mu}^\sigma$).
\begin{align}
\Gamma_{\mu\nu}^1\frac{dx^\mu}{d\lambda}\frac{dx^\nu}{d\lambda}&=\Gamma_{00}^1\frac{dx^0}{d\lambda}\frac{dx^0}{d\lambda}+2\Gamma_{10}^1\frac{dx^1}{d\lambda}\frac{dx^0}{d\lambda}+\Gamma_{11}^1\frac{dx^1}{d\lambda}\frac{dx^1}{d\lambda}&\phantom {10000}(4)\nonumber\\

&=\Gamma_{00}^1\left(\frac{d\phi}{d\lambda}\right)^2+2\Gamma_{10}^1\frac{d\phi}{d\lambda}\frac{d\theta}{d\lambda}+\Gamma_{11}^1\left(\frac{d\theta}{d\lambda}\right)^2&\phantom {10000}(5)\nonumber
\end{align}using the metric and (2) and taking each $\Gamma$ in turn, many terms vanish because the metric components are constant or 0
\begin{align}
\Gamma_{00}^1&=\frac{1}{2}g^{1\rho}\left(\partial_0g_{0\rho}+\partial_0g_{\rho0}-\partial_\rho g_{00}\right)=g^{1\rho}\partial_0g_{0\rho}&\phantom {10000}(6)\nonumber\\

&=g^{10}\partial_0g_{00}+g^{11}\partial_0g_{01}=0&\phantom {10000}(7)\nonumber\\
2\Gamma_{10}^1&=g^{1\rho}\left(\partial_1g_{0\rho}+\partial_0g_{\rho1}-\partial_\rho g_{10}\right)=g^{1\rho}\partial_1g_{0\rho}+g^{1\rho}\partial_0g_{\rho1}&\phantom {10000}(8)\nonumber\\

&=g^{10}\partial_1g_{00}+g^{11}\partial_1g_{01}+g^{10}\partial_0g_{01}+g^{11}\partial_0g_{11}&\phantom {10000}(9)\nonumber\\

&=\frac{1}{\sin^2{\phi}}\frac{\partial}{\partial\phi}\left(\sin^2{\phi}\right)=\frac{2\sin{\phi}\cos{\phi}}{\sin^2{\phi}}=2\cot{\phi}&\phantom {10000}(10)\nonumber\\
\Gamma_{11}^1&=\frac{1}{2}g^{1\rho}\left(\partial_1g_{1\rho}+\partial_1g_{\rho1}-\partial_\rho g_{11}\right)=g^{1\rho}\partial_1g_{\rho1}-\frac{1}{2}g^{1\rho}\partial_\rho g_{11}&\phantom {10000}(11)\nonumber\\

&=g^{10}\partial_1g_{01}+g^{11}\partial_1g_{11}-\frac{1}{2}g^{10}\partial_0g_{11}-\frac{1}{2}g^{11}\partial_1g_{11}&\phantom {10000}(12)\nonumber\\

&=\frac{1}{2}\frac{1}{\sin^2{\phi}}\frac{\partial}{\partial\theta}\left(\sin^2{\phi}\right)=0&\phantom {10000}(13)\nonumber
\end{align}Putting the expressions for $\Gamma$ back into (5) we get
\begin{align}
\Gamma_{\mu\nu}^1\frac{dx^\mu}{d\lambda}\frac{dx^\nu}{d\lambda}&=2\cot{\phi}\frac{d\phi}{d\lambda}\frac{d\theta}{d\lambda}&\phantom {10000}(14)\nonumber
\end{align}Putting that back into (1) we have
\begin{align}
\frac{d^2\theta}{d\lambda^2}+2\cot{\phi}\frac{d\phi}{d\lambda}\frac{d\theta}{d\lambda}=0&\phantom {10000}(15)\nonumber
\end{align}I can use the same method to get a solution for $\sigma=0$, but that's not relevant yet. Put together they show that lines of longitude are always geodesics as is the equator. So far so good… but

A great circle equation (which we know is a geodesic) can be written as
\begin{align}
\theta=\lambda\ \ ,\ \ \phi=\tan^{-1}{\left(\frac{C}{A\cos{\lambda}+B\sin{\lambda}}\right)}&\phantom {10000}(16)\nonumber
\end{align}where $A,B,C$ are constants depending on the start and end points. I calculated this and checked it against the slightly ambiguous Wolfram maths article at http://mathworld.wolfram.com/GreatCircle.html.

From (16) clearly
\begin{align}
\frac{d^2\theta}{d\lambda^2}=0&\phantom {10000}(17)\nonumber
\end{align}so the other term in (15) should always be zero. It is
\begin{align}
2\cot{\phi}\frac{d\phi}{d\lambda}\frac{d\theta}{d\lambda}=-2\frac{\left(B\cos{\lambda}-A\sin{\lambda}\right)\left(A\cos{\lambda}+B\sin{\lambda}\right)}{C^2+\left(A\cos{\lambda}+B\sin{\lambda}\right)^2}&\phantom {10000}(18)\nonumber
\end{align}which is not always zero! So something is wrong.
It's either
(15) which I have calculated in another way to check it or
(16) which I have also plotted and gives good results or
my differentiation of $\frac{d\phi}{d\lambda}$ which I checked with Symbolab: https://www.symbolab.com/solver/ordinary-differential-equation-calculator/?or=dym&query=%5Cfrac%7Bd%7D%7Bdx%7D(%5Carctan(%5Cfrac%7BC%7D%7BD%5Ccos(x)%2BB%5Csin(x)%7D))

Help! What has gone wrong?

## Sunday, 21 July 2019

### Question on partial derivative

I am working on the geodesic equation for the surface of a sphere. While doing so I come across the partial derivative
\begin{align}
\frac{\partial}{\partial\theta}\left(\sin^2{\phi}\right)=0?&\phantom {10000}(1)\nonumber
\end{align}where $\phi, \theta$ are colatitude(angle from north pole) and longitude. I could say that the expression must vanish because $\phi,\theta$ are orthogonal. But I know thate $\phi$ is a function $\theta$  so I could say, using the chain rule twice, that the expression is
\begin{align}
\frac{\partial}{\partial\theta}\left(\sin^2{\phi}\right)=2\sin{\phi}\cos{\phi}\frac{d\phi}{d\theta}?&\phantom {10000}(2)\nonumber
\end{align}The answer might be very obvious and simple. I think the former is correct but would like some confirmation please.

The detailed reasons for the question are given below. They include my fears about the metric.

The geodesic equation is
\begin{align}
\frac{d^2x^\sigma}{d\lambda^2}+\Gamma_{\mu\nu}^\sigma\frac{dx^\mu}{d\lambda}\frac{dx^\nu}{d\lambda}=0&\phantom {10000}(3)\nonumber
\end{align}where $\Gamma$ is the Christoffel symbol (torsion-free and metric compatible), given by
\begin{align}
\Gamma_{\mu\nu}^\sigma=\frac{1}{2}g^{\sigma\rho}\left(\partial_\mu g_{\nu\rho}+\partial_\nu g_{\rho\mu}-\partial_\rho g_{\mu\nu}\right)&\phantom {10000}(4)\nonumber
\end{align}The coordinates are  $x^0=\phi$ and $\ x^1=\theta$ and the metric and inverse metric are
\begin{align}
g_{\mu\nu}=\left(\begin{matrix}1&0\\0&\sin^2{\phi}\\\end{matrix}\right)\ \ ,\ \ g^{\mu\nu}=\left(\begin{matrix}1&0\\0&\sin^{-2}{\phi}\\\end{matrix}\right)&\phantom {10000}(5)\nonumber
\end{align}$\lambda$ will parameterise a line which gives the required geodesic. First I derived what these equations mean and I get two second order differential equations involving $\phi,\theta,\lambda$. I believe these are
\begin{align}
\frac{d^2\phi}{d\lambda^2}-\sin{\phi}\cos{\phi}\left(\frac{d\theta}{d\lambda}\right)^2=0&\phantom {10000}(6)\nonumber
\end{align}and
\begin{align}
\frac{d^2\theta}{d\lambda^2}+2\cot{\phi}\frac{d\phi}{d\lambda}\frac{d\theta}{d\lambda}=0&\phantom {10000}(7)\nonumber
\end{align}There were two ways to work these equations out. Assuming (2) (that ${\partial f(\phi)}/{\partial\theta}\neq0$) each method gave a different answer for equation (7) unless I made a mistake, which is quite likely.

I have not yet tried to solve these equations, but I know that a geodesic on a sphere is a great circle so I can work out its equation and it can be written
\begin{align}
\theta=\lambda\ \ ,\ \ \phi=\tan^{-1}{\left(\frac{C}{A\cos{\lambda}+B\sin{\lambda}}\right)}&\phantom {10000}(8)\nonumber
\end{align}where $A,B,C$ are constants depending on the start and end points (in quite a complicated way.) It should be simple to check that (8) satisfies (6) and (7). Clearly $\phi$ depends only on $\theta$ and the start and end points, as one would expect. This leads to the original question.

I checked my equation (8) by using my wonderful 3-D plotter. The geodesics look perfect.
I also searched the internet for the equation and found one on Wolfram MathWorld (http://www.mathworld.wolfram.com/GreatCircle.html). It was slightly different from mine and cause me great pain. It is incorrect! Their colatitudes and latitudes are mixed up. I have told them, but there is no response. I also plotted their solution and it gave a rather long route to Peking. Whatever the case $\phi$ depends on $\theta$ and the start and end points.

(8) tells us that
\begin{align}
\frac{d^2\theta}{d\lambda^2}=0&\phantom {10000}(9)\nonumber
\end{align}Which does not sit well with (7). If I had the metric at (5) 'the wrong way round', it would be
\begin{align}
g_{\mu\nu}=\left(\begin{matrix}\sin^2{\phi}&0\\0&1\\\end{matrix}\right)\ \ ,\ \ g^{\mu\nu}=\left(\begin{matrix}\sin^{-2}{\phi}&0\\0&1\\\end{matrix}\right)&\phantom {10000}(10)\nonumber
\end{align}this would have given (9) at (7). However I want to cross one bridge at a time …

The first three answers satisfy me that$$\frac{\partial}{\partial\theta}\left(\sin^2{\phi}\right)=0$$Equation (8) is just the equation of some line on the sphere, in this case a geodesic.

### MS-Word macros for equations and more

Since I have got a new computer and Office 365 (upgrading from Office 2007), I have been taking advantage of the new features. In particular the ability to switch to Latex equations is great and I have used it and been able to stop using GrindEQ. I have written a completely new macro to generate web pages containing Latex. Sadly, there seems to be no way to determine in Word VBA whether equations are in Latex or Unicode mode. This must be done by hand. Also sadly, if Latex mode is always turned on, variables such as $x,\phi$ come out as non italic. This is disliked by mathematicians.

This is an update of older posts like this one in Tools. I will recap and add in the new stuff.

This post has three main sections
1) Equations in MS-Word
2) Converting a Word document to something suitable for a web page.
3) Getting the macros

## 1) Equations in MS-Word

I had been copying and pasting tables and equations in MS-Word for far too long, so I wrote some word macros to speed things up. I can now easily produce correctly aligned equations like
 Fig 1: Aligning equation numbers neatly using 2 x 1 tables
and
 Fig 2: LHS of equations unchanged and aligning equation numbers
I now have a "Quick access toolbar", part of it is like this

From the left, they have the following effects
1. Select table (MS-Word command)
2. Outside border on selected table Macro: BordersOutside
3. Remove all borders from table Macro: BordersNone
4. Add all borders to table Macro: BordersAll
5. 0.8 cm row height on selected rows Macro: Point8cmTableRows
6. ($\pi$) Insert inline equation (font size 12). Macro: InsertEquationInLine
7. Insert unbarred 2 x 1 table with centred justified equation in column 1, (nn) in column 2 (Fig 1). Macro: EquationTable2
8. Insert unbarred 3 x 1 with right justified equation in column 1, left justified equation in column 2 and (nn) in column 3 (Fig 2) Macro: EquationTable3
9. Renumber all equations Macro: aaRenumberEquations
The first five are useful for quickly sorting problems with tables and tidying them. With 7 & 8, the equation number (nn) is one bigger than the last one up the document. The one line tables are inserted according to customary MS-Word rules. There are three constants in the macros which may be adjusted to suit your taste:
• EquationFontSize - default 12 points
• TableHeight - height of new equation rows in cm, default 1.29
• EquationColumnWidth - column width in cm of equation number column, default 1.38
It often happens that you need to insert a few extra equations in the middle of a document. Here's a tip: Insert the first equation which will probably have the same number as the equation below. Change its number to 100 (or another large number). Following equations will be numbered 101, 102, ... When you have finished adding the group, renumber all equations. Which brings us to the next macro.

### aaRenumberEquations

Obviously after a bit of copying and pasting or writing things out of order, equation numbers can become a mess. For this we have the aaRenumberEquations macro which just renumbers all the equations from 1-n. It also adjusts all the references to said equations. Equation numbers such as a, b, b123,  2.5 will be renumbered.

I have tested it on the .docx which produced Commentary 1.1 Tensors matrices and indexes.pdf . It contains 213 equations numbers and 154 references to them. It took 112 seconds. The macro estimates the time that will be taken at the beginning (92 seconds in this case) and gives suitable warnings if it is more than 40 seconds. Clearly the overall time will depend on the machine.

#### aaRenumberEquations detects two kinds of error:

1) There is a reference to an equation that does not exist and the reference number would become a new equation number. In this case you get an error like
Equation (4) is referenced. It does not exist.
2) Equations are numbered with the same number twice or more and that number is used as an equation reference. (It does not matter if duplicate equation numbers are used but they are not referenced). In this case you get an error like
Equation (33) is defined 3 times and referenced one or more times.
Progress, and all errors found are displayed in another window.

I now activate this macro from the Quick access tool bar because it is robust and I use it often.
I used to only activate it from the Macros button, which is in the View and Developer ribbons, which explains the aa in the name.

It is now possible to create Word documents containing beautifully numbered equation and created .pdf files from them for example. What about a web page or a long question with equation numbers on Physics Forums? That brings us to the final macro which I use rarely and therefore only activate from the Macros button.