## Saturday, 19 October 2019

### VBA error 6219. One small step to the Christoffel symbol

I am trying to write a Word macro to expand the Christoffel symbol automatically. The expansion is simple:$$\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)$$One replaces the Christoffel symbol $\Gamma_{\mu\nu}^\sigma$ by a half times the inverse metric $g^{\sigma\rho}$ times the sum of slightly different index combinations of the partial derivative $\partial_\mu$ of the metric $g_{\nu\rho}$. A new dummy index, $\rho$ in this case, is introduced (it is summed over) and the original indices $\sigma,\mu,\nu$ are placed carefully in the expansion. The Christoffel symbol occurs frequently in General Relativity and once I have done this a few times with different indices my eyes start to pop out, thus the motivation to write a macro to save said eyes.

The macro should be fairly straightforward. We want it to replace something like$$A\Gamma_{\mu\nu}^\sigma X$$by$$A\frac{1}{2}g^{\sigma\rho}\left(\partial_\mu g_{\nu\rho}+\partial_\nu g_{\rho\mu}-\partial_\rho g_{\mu\nu}\right)X$$An equation is an OMath object which consists of OMathFunction objects. So each of $A,\Gamma_{\mu\nu}^\sigma,X$ in the first equation is an  OMathFunction object. In theory it should be easy to replace the OMathFunction object $\Gamma_{\mu\nu}^\sigma$ by a bunch of new OMathFunction objects $\frac{1}{2},g^{\sigma\rho},+\ etc$. Dream on!

When you want to add a new OMathFunction object, you need to call Add method of an OMathFunctions object. The OMathFunctions object is the list of OMathFunction objects in the equation. The second parameter of this Add method is the type of new OMathFunction to add. (This not well described in the documentation.) The list of types is here. So the fraction $\frac{1}{2}$ is an wdOMathFunctionFrac, the inverse metric which has superscripts $g^{\sigma\rho}$ is a wdOMathFunctionScrSup and $+$ is a wdOMathFunctionText. You can see all these in the debugger if you have a look at the OMathFunctions object. This Add method crashes with error 6219 if the type parameter is wdOMathFunctionText, so it is very difficult to get the $+,-$ signs into expansion. The only way I could discover was by using
Selection.TypeText ("+")
I could then insert $g_{\mu\nu}+g^{\mu\nu}$ at the selection point in an equation with this code:
Sub ExampleWriteExpression()
'insertion point should be in equation. Metric + inverse metric inserted
Dim Equation As OMath
Dim MathTerm As OMathFunction

If Selection.OMaths.Count <> 1 Then ExpanderFatalError ("Cursor must be in an equation.")
Set Equation = Selection.OMaths(1)
MathTerm.ScrSub.E.Range = "g"
MathTerm.ScrSub.Sub.Range = ChrW(&H3BC) & ChrW(&H3BD)

Selection.TypeText ("+")

'Set MathTerm = Equation.Functions.Add(Selection.Range, wdOMathFunctionText) still gets error

MathTerm.ScrSup.E.Range = "g"
MathTerm.ScrSup.Sup.Range = ChrW(&H3BC) & ChrW(&H3BD)
End Sub
There was quite a bit of difficulty in getting the selection in the right place and I kept getting things like$$\frac{1}{2}g^{\sigma\rho}\left(\partial_\mu g_{\nu\rho}\partial_\nu g_{\rho\mu}\partial_\rho g_{\mu\nu}\right)+-$$It is necessary align the selection range with the equation range and this is not the simple matter of subtraction that you might expect! It now works  properly and replaces multiple Christoffel symbols in an equation correctly. Click Read more below if you would like a look or copy. Covariant derivatives, Riemann tensors, using, metric and coordinates coming soon!

jpl on msofficeforums corrected me and showed me how to avoid using the Selection which is a bodge. I further refined his technique. It is now very beautiful.😅

## Saturday, 12 October 2019

### Symmetries and Killing vectors Sean Carroll, my guide and nemesis
I'm now reading section 3.8 on symmetries and Killing vectors. It's not too hard to follow but there are a few stumbling blocks.

After equation 3.161 for the geodesic in terms of 4 momentum $p^\lambda\nabla_\lambda p^\mu=0$  Carroll says that by metric compatibility we are free to lower the index $\mu$. Metric compatibility means that $\nabla_\rho g_{\mu\nu}=\nabla_\rho g^{\mu\nu}=0$ so I tried to show that, given that, $\nabla_\lambda p^\mu=\nabla_\lambda p_\mu$. Here was my first attempt:
Lower the index with the metric, use the Leibnitz rule, use metric compatibility$$\nabla_\lambda p^\mu=\nabla_\lambda g^{\mu\nu}p_\nu=p_\nu\nabla_\lambda g^{\mu\nu}+g^{\mu\nu}\nabla_\lambda p_\nu=0+\nabla_\lambda p^\mu$$Then I tried painfully expanding $\nabla_\lambda g^{\mu\nu}p_\nu$ and got the same result. So then I asked on Physics Forums: Why does metric compatibility imply  $\nabla_\lambda p^\mu=\nabla_\lambda p_\mu$? I got my wrist slapped by martinbn who pointed out that  $\nabla_\lambda p^\mu=\nabla_\lambda p_\mu$ made no sense because there are different types of tensors on each side of the equation. (The $\mu$ is up on one side and down on the other). I was embarrassed😡.

What Carroll is really saying is that metric compatibility means that$$\nabla_\lambda p^\mu=0\Rightarrow\nabla_\lambda p_\mu=0$$which is quite different and easy to show:$$\nabla_\lambda p^\mu=0$$$$\Rightarrow g^{\mu\nu}\nabla_\lambda p_\nu=0$$$$\Rightarrow g_{\rho\mu}g^{\mu\nu}\nabla_\lambda p_\nu=0$$$$\Rightarrow\delta_\rho^\nu\nabla_\lambda p_\nu=0$$$$\Rightarrow\nabla_\lambda p_\rho=0$$I posted something very like those steps and there was silence which usually means they are correct. The first step uses, $\nabla_\lambda p^\mu=g^{\mu\nu}\nabla_\lambda p_\nu$, which can be done in several ways
1) $\nabla_\lambda p^\mu$ is a tensor so you can lower (or raise) an index with the metric as usual.
2) $\nabla_\lambda p^\mu=\nabla_\lambda\left(g^{\mu\nu}p_\nu\right)=p_\nu\nabla_\lambda g^{\mu\nu}+g^{\mu\nu}\nabla_\lambda p_\nu=g^{\mu\nu}\nabla_\lambda p_\nu$ as in (1) use the Leibnitz rue and metric compatibility
3) $\nabla_\lambda p^\mu=\nabla_\lambda\left(g^{\mu\nu}p_\nu\right)=g^{\mu\nu}\nabla_\lambda p_\nu$ using Carroll's third rule for covariant derivatives: That they commutes with contractions.

The Leibnitz rule was the second rule of covariant derivatives and I discussed all four in Commentary 3.2 Christoffel Symbol. The third caused angst and another question on PF. I now think that the third rule is just saying that because the covariant derivative is a tensor you can raise and lower indexes on it. 3 and 1 above are really the same. I have suitably amended Commentary 3.2 Christoffel Symbol.

Sometimes I hate Carroll!

There was also another post on the thread ahead of the first two which referred to a similar question on Stack Exchange. MathematicalPhysicist was asked to show that $$U^\alpha\nabla_\alpha V^\beta=W^\beta\Rightarrow U^\alpha\nabla_\alpha W_\beta=W_\beta$$The proof for this is very similar to the above:$$U^\alpha\nabla_\alpha V^\beta=W^\beta$$$$\Rightarrow U^\alpha g^{\beta\gamma}\nabla_\alpha V_\gamma=g^{\beta\gamma}W_\gamma$$$$\Rightarrow U^\alpha g_{\mu\beta}g^{\beta\gamma}\nabla_\alpha V_\gamma=g_{\mu\beta}g^{\beta\gamma}W_\gamma$$$$\Rightarrow U^\alpha\delta_\mu^\gamma\nabla_\alpha V_\gamma=\delta_\mu^\gamma W_\gamma$$$$\Rightarrow U^\alpha\nabla_\alpha V_\mu=W_\mu$$Once again there are three ways to do the first step. Metric compatibility is not essential.

See Commentary 3.8 Symmetries and Killing vectors.pdf first two pages. Then I run into another problem with Killing.

## Thursday, 10 October 2019

### Question

A good approximation to the metric outside the surface of the Earth is provided by$${ds}^2=-\left(1+2\Phi\right){dt}^2+\left(1-2\Phi\right){dr}^2+r^2\left({d\theta}^2+\sin^2{\theta}{d\phi}^2\right)$$where$$\Phi=-\frac{GM}{r}$$may be thought of as the familiar Newtonian gravitational potential. Here $G$ is Newton's constant and $M$ is the mass of the Earth. For this problem $\Phi$ may be assumed to be small.
a) Imagine a clock on the surface of the Earth at a distance $R_1$ from the Earth's center, and another clock on a tall building at distance $R_2$ from the Earth's center. Calculate the time elapsed on each clock as a function of the coordinate time $t$. Which clock moves ticks faster?
b) Solve for a geodesic corresponding to a circular orbit around the equator of the Earth ($\theta=\pi/2$ ). What is $d\phi/dt$?
c) How much proper time elapses while a satellite at radius  $R_1$ (skimming along the surface of the Earth, neglecting air resistance) completes one orbit? You can work to  first order in $\Phi$ if you like. Plug in the actual numbers for the radius of the Earth and so on (don't forget to restore the speed of light) to get an answer in seconds. How does this number compare to the proper time elapsed on the clock stationary on the surface? Karl Schwarzschild Image credit
Apparently the metric given is the Newtonian metric. I learnt how to reinstate the speed of light $c$ and so do real calculations. I was brutally reminded that ${ds}^2=-{d\tau}^2$ where $\tau$ is the proper time and that the proper time is what appears on ideal clocks. I also found the Schwarzschild radius - the radius of the event horizon of a black hole with a given mass. Some time ago I had found two sample solutions which had been left lying around on the internet by careless professors. They have now gone but luckily I had downloaded them before. I found that they were both littered with errors! The worst was probably UCSB's who popped an extra question and got totally the wrong answer for gravitational time dilation on a GPS satellite. Lucky they weren't involved in the construction!  Finally I had a look to see if I  could do anything with elliptical orbits but then decided I had spent enough time on this exercise.