# Curvature

<h1>Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#Preliminary-definitions" data-toc-modified-id="Preliminary-definitions-1"><span class="toc-item-num">1&nbsp;&nbsp;</span>Preliminary definitions</a></span></li><li><span><a href="#Lengths-and-volumes" data-toc-modified-id="Lengths-and-volumes-2"><span class="toc-item-num">2&nbsp;&nbsp;</span>Lengths and volumes</a></span></li><li><span><a href="#Christoffel-symbols-(connection-coefficients)" data-toc-modified-id="Christoffel-symbols-(connection-coefficients)-3"><span class="toc-item-num">3&nbsp;&nbsp;</span>Christoffel symbols (connection coefficients)</a></span><ul class="toc-item"><li><span><a href="#Covariant-derivatives" data-toc-modified-id="Covariant-derivatives-3.1"><span class="toc-item-num">3.1&nbsp;&nbsp;</span>Covariant derivatives</a></span></li><li><span><a href="#Christoffel-symbols-and-the-metric" data-toc-modified-id="Christoffel-symbols-and-the-metric-3.2"><span class="toc-item-num">3.2&nbsp;&nbsp;</span>Christoffel symbols and the metric</a></span></li><li><span><a href="#Example:-the-surface-of-a-unit-sphere-in-polar-coordinates" data-toc-modified-id="Example:-the-surface-of-a-unit-sphere-in-polar-coordinates-3.3"><span class="toc-item-num">3.3&nbsp;&nbsp;</span>Example: the surface of a unit sphere in polar coordinates</a></span></li></ul></li><li><span><a href="#Parallel-transport-of-vectors" data-toc-modified-id="Parallel-transport-of-vectors-4"><span class="toc-item-num">4&nbsp;&nbsp;</span>Parallel transport of vectors</a></span><ul class="toc-item"><li><span><a href="#Geodesics" data-toc-modified-id="Geodesics-4.1"><span class="toc-item-num">4.1&nbsp;&nbsp;</span>Geodesics</a></span></li></ul></li><li><span><a href="#The-Riemann-curvature-tensor" data-toc-modified-id="The-Riemann-curvature-tensor-5"><span class="toc-item-num">5&nbsp;&nbsp;</span>The Riemann curvature tensor</a></span></li><li><span><a href="#The-Ricci-and-Einstein-tensors" data-toc-modified-id="The-Ricci-and-Einstein-tensors-6"><span class="toc-item-num">6&nbsp;&nbsp;</span>The Ricci and Einstein tensors</a></span><ul class="toc-item"><li><span><a href="#The-Ricci-tensor" data-toc-modified-id="The-Ricci-tensor-6.1"><span class="toc-item-num">6.1&nbsp;&nbsp;</span>The Ricci tensor</a></span></li><li><span><a href="#The-Ricci-scalar" data-toc-modified-id="The-Ricci-scalar-6.2"><span class="toc-item-num">6.2&nbsp;&nbsp;</span>The Ricci scalar</a></span></li><li><span><a href="#The-Einstein-tensor" data-toc-modified-id="The-Einstein-tensor-6.3"><span class="toc-item-num">6.3&nbsp;&nbsp;</span>The Einstein tensor</a></span></li><li><span><a href="#Bianchi-identities" data-toc-modified-id="Bianchi-identities-6.4"><span class="toc-item-num">6.4&nbsp;&nbsp;</span>Bianchi identities</a></span></li></ul></li></ul></div>

## Preliminary definitions

In simple terms (to be made more precise later):

A __geodesic__ is the shortest distance between two points, e.g. a straight line in Euclidean space or a great circle on the surface of a sphere.

A __manifold__ is a smoothly curved space which is locally flat. In GR we are interested in manifolds which are (a) differentiable and (b) have a symmetric metric tensor (so $g_{\mu \nu} = g_{\nu \mu}$). This is a _Riemannian manifold_.

A __path__ is a connected series of points. A __curve__ is a parameterized path, with each point associated with a real value.

## Lengths and volumes

An $n$-dimensional Riemannian manifold has a line element given by $dl^2 = g_{ij} dx^i dx^j$. 

To get the length $L$ of an arbitrary curve parameterized by $\lambda$, between $\lambda_0$ and $\lambda_1$, we use the square root of the absolute value of the line element and integrate:
$$ L = \int_{\lambda_0}^{\lambda_1} \left| g_{\alpha \beta} \frac{dx^\alpha}{d\lambda} \frac{dx^\beta}{d\lambda} \right|^{1/2} d\lambda $$

But $\frac{dx^\alpha}{d\lambda}$ are the components of the tangent vector $\vec{V}$, so
$$ L = \int_{\lambda_0}^{\lambda_1} \left| \vec{V} \cdot \vec{V} \right|^{1/2} d\lambda $$

A small 4-dimensional region in a local Lorentz frame is $dx^0 dx^1 dx^2 dx^3 \equiv d^4x$. In other frames we in principle need to use the Jacobian. In practice we can more conveniently use the determinant $g$ of the metric: $g = det(g_{\alpha \beta})$. Then the _element of proper volume_ is $d^4x' = |g|^{1/2} d^4x$.

## Christoffel symbols (connection coefficients)

Differentiation of a vector $\vec{V} = V^\alpha \vec{e}_\alpha$ gives (chain rule):
$$ \frac{\partial \vec{V}}{\partial x^\beta} = \frac{\partial V^\alpha}{\partial x^\beta} \vec{e}_\alpha + V^\alpha \frac{\partial \vec{e}_\alpha}{\partial x^\beta} $$

In flat Minkowski space the basis vectors are constant and the second term disappears, but this is not the case in the curved space of GR.

To handle derivatives of the basis vectors we introduce the Christoffel symbols $\Gamma$ (also known as connection coefficients):

$$ \frac{\partial e_\alpha}{\partial x^\beta} = \Gamma^\gamma\!_{\alpha \beta}\ e_\gamma $$

Here index $\alpha$ gives the basis being differentiated, $\beta$ the coordinate with respect to which it is diffentiated, and $\gamma$ the component of the resulting derivative vector.

Substituting back into the original derivative equation (and after juggling dummy indices a bit):

$$ \frac{\partial \vec{V}}{\partial x^\beta} = \left( \frac{\partial V^\alpha}{\partial x^\beta} +  V^\gamma \Gamma^\alpha\!_{\gamma \beta} \right) \vec{e}_\alpha = V^\alpha\!_{;\beta}\ \vec{e}_\alpha $$

where we use semicolon notation for components of the _covariant derivative_ $\nabla\vec{V}$ and comma notation for the partial derivative:

$$ V^\alpha\!_{;\beta} \equiv V^\alpha\!_{,\beta} + V^\gamma \Gamma^\alpha\!_{\gamma \beta} \qquad V^\alpha\!_{,\beta} \equiv \frac{\partial V^\alpha}{\partial x^\beta} \qquad ( \nabla \vec{V} )^\alpha\!_\beta \equiv \nabla_\beta V^\alpha \equiv  V^\alpha\!_{;\beta} $$

In 4-dimensional spacetime we expect $4^3 = 64$ Christoffel symbols, but in GR this is reduced by symmetry. In particular, $\Gamma^\gamma\!_{\alpha \beta} = \Gamma^\gamma\!_{\beta \alpha}$.

### Covariant derivatives

We saw above that the covariant derivative of a vector is $\nabla_\beta V^\alpha = V^\alpha\!_{,\beta} +  V^\gamma \Gamma^\alpha\!_{\gamma \beta}$. 

Similarly, the covariant derivative of a 1-form is $\nabla_\beta V_\alpha = V_{\alpha\,,\beta} - V_\gamma \Gamma^\gamma\!_{\alpha \beta}$.

Higher rank tensors follow a regular pattern:
- take the partial derivative of the tensor
- for each upper index add a term of the form $V^\gamma \Gamma^\alpha\!_{\gamma \beta}$
- for each lower index subtract a term of the form $V_\gamma \Gamma^\gamma\!_{\alpha \beta}$

### Christoffel symbols and the metric

__Within GR__ it is always true that the covariant derivative of the metric tensor is zero (_"metric compatibility"_):
$$ \nabla_\beta g_{\mu \nu} = \nabla_\beta g^{\mu \nu} = 0 $$

Given this, it is possible (and very useful) to express the Christoffel symbols in terms of the inverse metric and partial derivatives of the metric:
$$ \Gamma^\gamma\!_{\beta \mu} = \frac{1}{2} g^{\alpha \gamma} \left( g_{\alpha \mu\,,\beta} + g_{\alpha \beta\,,\mu} + g_{\beta \mu\,,\alpha} \right) $$

### Example: the surface of a unit sphere in polar coordinates

The radius $r$ is a constant, $1$, so the coordinates are $\theta$ and $\phi$. The metric $g_{ij}$ and inverse metric $g^{ij}$ are:

$$ [g_{ij}] = \begin{bmatrix} 1 & 0 \\ 0 & \sin^2 \theta \end{bmatrix} \qquad [g^{ij}] = \begin{bmatrix} 1 & 0 \\ 0 & \frac{1}{\sin^2 \theta} \end{bmatrix}  $$




```python
from sympy.interactive.printing import init_printing
from sympy.matrices import *
from sympy import Array, sin, cos, diff, derive_by_array, simplify
from sympy.abc import phi, theta
init_printing()
```


```python
coords = (theta, phi)
g_ij = Matrix([[1, 0], [0, sin(theta)**2]])
inv_gij = g_ij.inv()
display(g_ij, inv_gij)
```

Given a (2D) matrix, SymPy can calculate all the partial derivatives at once and return them in an 3D array. Then `result[i,j,k]` = $\displaystyle \frac{\partial A_{jk}}{\partial x^i}$ (note the order of indices).

In our example, only $\displaystyle \frac{\partial g_{\phi \phi}}{\partial \theta}$ is non-zero.


```python
def getPartialDiffs(metric, coords):
    result = derive_by_array(metric, coords)
    return result
```


```python
diffs = getPartialDiffs(g_ij, coords)
display(diffs)
diffs[0,1,1]
```

Though we expect few non-zero terms in our example, the following functions calculate $\Gamma^{up}\!_{l1\,l2}$ in as general a way as possible. 

Unfortunately SymPy doesn't seem to have a way to pre-allocate 3D arrays (`zeros()` only handles 1 or 2 dimensions), so there are lots of ugly list appends as a workaround.


```python
def calcOneChristoffel(invmetric, diffs, up, l1, l2):
    result = 0
    for c in range(invmetric.shape[0]): # dummy index to sum over
        result += 1/2*invmetric[up, c]*(diffs[l1, c, l2] + diffs[l2, c, l1] - diffs[c, l1, l2])
    return result

def calcAllChristoffel(metric, coords):
    diffs = getPartialDiffs(metric, coords)
    invmetric = metric.inv()
    ndims = len(coords)
    result = []
    for up in range(ndims):
        result_l1 = []
        for l1 in range(ndims):
            result_l2 = []
            for l2 in range(ndims):
                result_l2.append(calcOneChristoffel(invmetric, diffs, up, l1, l2))
            result_l1.append(result_l2)
        result.append(result_l1)
    return Array(result)
```


```python
Gamma = calcAllChristoffel(g_ij, coords)
simplify(Gamma)
```

Next show just the non-zero values. We expect $\Gamma^\theta\!_{\phi \phi} = -\sin \theta \cos \theta = -0.5 \sin(2 \theta)$ and $\Gamma^\phi\!_{\theta \phi} = \Gamma^\phi\!_{\phi \theta} = \cot \theta$. See Collier, Problem 6.3.


```python
def showNonzeroChristoffel(Gamma, coords):
    ndims = len(coords)
    for up in range(ndims):
        for l1 in range(ndims):
            for l2 in range(ndims):
                if Gamma[up, l1, l2] != 0:
                    display((coords[up], coords[l1], coords[l2]), Gamma[up, l1, l2])
                    
showNonzeroChristoffel(Gamma, coords)
```

## Parallel transport of vectors

This is intuitive in flat Euclidean space: a vector moved around such that at each point it it parallel to the vector at the previous point will always keeping pointing in the same direction. In a curved space, such as on the surface of a sphere, the results can be different.

Consider a vector parallel-transported around the path A-N-B-A. On returning to A it is clearly ___not___ parallel to how it started.

 _(Image attribution: Fred the Oyster [CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0)])_



Consider a smooth curve parameterized by $\lambda$. The tangent vector is 
$$ U^\beta = \frac{dx^\beta}{d\lambda} = \left( \frac{dx^0}{d\lambda}, \frac{dx^1}{d\lambda}, \frac{dx^2}{d\lambda}, \frac{dx^3}{d\lambda} \right) $$

We assume in GR that space is locally flat and a small enough region at a point $\mathcal{P}$ will act as a _locally intertial coordinate frame_. So at $\mathcal{P}$ on the curve, the components of a non-tangent vector $\vec{V}$ must be constant: $\frac{d\vec{V}}{d\lambda} = 0$. Also at $\mathcal{P}$, the Christoffel symbol $\Gamma^\alpha\!_{\beta \gamma} = 0$ and the covariant derivative is equal to the partial derivative.

Notation varies for how textbooks describe this, but in one version:
$$ \frac{dV^\alpha}{d\lambda} = U^\beta V^\alpha\!_{,\beta} = U^\beta V^\alpha\!_{;\beta} = 0 $$

Alternatively,
$$ \frac{d\vec{V}}{d\lambda} = \left( \frac{dV^\alpha}{d\lambda} + V^\gamma \Gamma^\alpha\!_{\gamma \beta} \frac{dx^\beta}{d\lambda} \right) \vec{e}_\alpha = \frac{DV^\alpha}{d\lambda} \vec{e}_\alpha $$
where the upper case D refers to the covariant derivative along the curve, sometimes known as the _absolute_ or _intrinsic_ derivative. For parallel transport, $\frac{DV^\alpha}{d\lambda} = 0$.

### Geodesics

These are lines that in curved space are "as straight as possible" in the sense that the tangent vector $U^\alpha = \frac{dx^\alpha}{d\lambda}$ is parallel-transported along the curve. This (eventually) leads to:
$$ \frac{DU^\alpha}{d\lambda} = \frac{d^2x^\alpha}{d\lambda^2} + \Gamma^\alpha\!_{\gamma \beta} \frac{dx^\beta}{d\lambda} \frac{dx^\gamma}{d\lambda} = 0 $$

## The Riemann curvature tensor

This rank-4 tensor is a measure of how a vector transforms a it is parallel-transported around an infinitessimal loop on the manifold. The derivation is quite long (read a book!), but the result is
$$ R^\alpha\!_{\beta \mu \nu} = \Gamma^\alpha\!_{\beta \nu,\mu} - \Gamma^\alpha\!_{\beta \mu,\nu} + \Gamma^\alpha\!_{\sigma \mu} \Gamma^\sigma\!_{\beta \nu} - \Gamma^\alpha\!_{\sigma \nu} \Gamma^\sigma\!_{\beta \mu} $$
So the first two terms are partial derivatives of the Christoffel terms and the last two are products summed over a dummy variable. In $n$ dimensions this means $n^4$ terms but this is reduced by symmetries to 1 in 2D space, 6 in 3D and 20 in 4D. 

The metric can be used to lower the upstairs index: $R_{\alpha \beta \mu \nu} = g_{\alpha \lambda} R^\lambda\!_{\beta \mu \nu}$.

Both $R^\alpha\!_{\beta \mu \nu}$ and $R_{\alpha \beta \mu \nu}$ are antisymmetric on the second pair of indices and $R_{\alpha \beta \mu \nu}$ is also antisymmetric on the first pair and symmetric on exchange of the two pairs:
$$ R_{\alpha \beta \mu \nu} = -R_{\beta \alpha \mu \nu} = -R_{\alpha \beta \nu \mu} = R_{\mu \nu \alpha \beta} $$
Also:
$$ R_{\alpha \beta \mu \nu} + R_{\alpha \nu \beta \mu} +R_{\alpha \mu \nu \beta} = 0 $$


```python
def calcRiemann(Gamma, coords, up, l1, l2, l3):
    R = diff(Gamma[up, l1, l3], coords[l2]) - diff(Gamma[up, l1, l2], coords[l3])
    for c in range(len(coords)):
        R += (Gamma[up, c, l2] * Gamma[c, l1, l3] - Gamma[up, c, l3] * Gamma[c, l1, l2])
    return simplify(R)
```

Calculation for the surface of a sphere, using the Christoffel symbols we calculated above:


```python
ndims = len(coords)
for up in range(ndims):
    for l1 in range(ndims):
        for l2 in range(ndims):
            for l3 in range(ndims):
                R = calcRiemann(Gamma, coords, up, l1, l2, l3)
                if R != 0:
                    display((coords[up], coords[l1], coords[l2], coords[l3]), R)
```

As expected, we get $R^\theta\!_{\phi \theta \phi} = -R^\theta\!_{\phi \phi \theta} = \sin^2 \theta$ (see Collier, Problem 6.9 and http://einsteinrelativelyeasy.com/index.php/general-relativity/70-the-riemann-curvature-tensor-for-the-surface-of-a-sphere).

Getting $R^\phi\!_{\theta \phi \theta} = -R^\phi\!_{\theta \theta \phi} = 1$ was not expected from what I had read. Repeating this manually, I find $R^\phi\!_{\theta \phi \theta} = -\partial_\theta \Gamma^\phi\!_{\theta \phi} - \Gamma^\phi\!_{\theta \phi} \Gamma^\phi\!_{\phi \theta} = -\partial_\theta \cot \theta - \cot^2 \theta = 1$.

We know from the Riemann symmetries that $R_{\phi \theta \phi \theta} = R_{\theta \phi \theta \phi}$ and that $R_{\phi \theta \phi \theta} = g_{\phi \alpha} R^\alpha\!_{\theta \phi \theta} = g_{\phi \theta} R^\theta\!_{\theta \phi \theta} + g_{\phi \phi} R^\phi\!_{\theta \phi \theta} = 0 + \sin^2(\theta)\ R^\phi\!_{\theta \phi \theta}$. Similarly, $R_{\theta \phi \theta \phi} = g_{\theta \theta} R^\theta\!_{\phi \theta \phi} = \sin^2(\theta)$.

So $R^\phi\!_{\theta \phi \theta} = 1$ is correct, and symmetry-connected to the $\sin^2 \theta$ terms via the metric.

## The Ricci and Einstein tensors

The rank-4 Riemann tensor is clearly quite complicated, but in GR we usually work with lower-rank contractions.

### The Ricci tensor 

Contracting the first and last index of the Riemann tensor gives $R^\alpha\!_{\mu \nu \alpha} = R_{\mu \nu}$, where $R_{\mu \nu}$ is the Ricci tensor. Because of the symetry of the Riemann tensor, various other contractions are possible to get $\pm R_{\mu \nu}$.

Equivalently, we can use the inverse metric with the index-lowered form of the Riemann tensor: $R_{\mu \nu} = g^{\alpha \beta} R^\alpha\!_{\alpha \mu \nu \beta}$


```python
def calcRicciTensor(Gamma, coords):
    ndims = len(coords)
    R = zeros(ndims)
    for i in range(ndims):
        for j in range(ndims):
            for c in range(len(coords)):
                R[i,j] += calcRiemann(Gamma, coords, c, i, j, c)
    return simplify(R)
```

The surface of a sphere example again:


```python
R_ij = calcRicciTensor(Gamma, coords)
R_ij
```

### The Ricci scalar

Contracting the Ricci tensor gives the Ricci scalar $R = g^{\mu \nu} R_{\mu \nu}$

In practice, we just sum the elementwise products of these matrices:


```python
def calcRicciScalar(R_ij, invmetric):
    return sum(invmetric * R_ij)
```

The surface of a sphere example yet again:


```python
R = calcRicciScalar(R_ij, inv_gij)
R
```

### The Einstein tensor

This symmetric tensor is defined from both the Ricci tensor and the Ricci scalar: 
$$ G^{\alpha \beta} = G^{\beta \alpha} = R^{\alpha \beta} - \frac{1}{2} R g^{\alpha \beta} \qquad G_{\alpha \beta} = G_{\beta \alpha} = R_{\alpha \beta} - \frac{1}{2} R g_{\alpha \beta} $$

This is the left hand side of the Einstein filed equations, so extremely important.


```python
def calcEinstein(R_ij, R, g_ij):
    return R_ij - R/2*g_ij
```

The result is particularly boring on the surface of a sphere:


```python
calcEinstein(R_ij, R, g_ij)
```

### Bianchi identities

In full form, these are a relationship between covariant derivatives:
$$ R_{\alpha \beta \mu \nu ;\lambda} + R_{\alpha \beta \lambda \mu ;\nu} + R_{\alpha \beta \nu \lambda ;\mu} == 0 $$ 

Applying the Ricci contraction then using the symmetries eventually simplifies this to
$$ (2R^\mu\!_\lambda - \delta^\mu\!_\lambda R)_{;\mu} = 0 $$ 

The implication for the Einstein tensor is
$$ G^{\alpha \beta}\!_{;\beta} = 0 $$

This means that the Einstein tensor has zero divergence.


```python

```

f8f1d924ba3c9204d1e89db61b561ff64c6932d0
ipynb
Jupyter Notebook
relativity/3-Curvature.ipynb
colinleach/astro-Jupyter
8d7618068f0460ff0c514075ce84d2bda31870b6
MIT
2020-06-06T15:35:35.000Z
2020-06-06T15:35:35.000Z
relativity/3-Curvature.ipynb
colinleach/astro-Jupyter
8d7618068f0460ff0c514075ce84d2bda31870b6
MIT
2019-06-08T11:44:15.000Z
2019-06-10T17:42:32.000Z
relativity/3-Curvature.ipynb
colinleach/astro-Jupyter
8d7618068f0460ff0c514075ce84d2bda31870b6
MIT
2021-04-14T15:28:43.000Z
2021-04-14T15:28:43.000Z
Qwen/Qwen-72B
1. YES
2. YES