tero.co.uk

# Parallel Transport and Geodesics

This is the fourth in a series of articles about tensors, which includes an introduction, a treatise about the troubled ordinary tensor differentation and the Lie derivative and covariant derivative which address those troubles. The examples in these articles took place in a variety of coordinate systems including females/males, snacks/shoes, embraces/hugs, women/couples and also polar. This page looks at some other general properties of coordinate systems culminating with straight lines (aka geodesics).

Please note: you'll need a modern HTML5 browser to see the graphs on this page. They are done using SVG. And you'll need Javascript enabled to see the equations which are written in Tex and rendered using MathJax and may take a few seconds to run. This page also has some graphs created using Octave, an open-source mathematical programming package. Click here to see the commands.

## Curves

First we'll go back to algebra and discuss curves and gradients, because it's useful to see how the graphs of algebraic equations (which you may first encountered in secondary/high school) relate to vector fields and tensors. So to start with, below is a plot of the function $$y=x^2$$ from $$x=-3$$ to $$x=3$$:

## Congruence of Curves

We could also plot $$y=x^2$$ all over the place. As long as the curves don't cross, this is called a congruence of curves. The next graph is $$y=x^2$$ repeated at different heights. The original $$y=x^2$$ is bolder than the others. The one above it is $$y=x^2+1$$, the one below is $$y=x^2-1$$ and so on. You could imagine curves like these filling the whole coordinate system from $$-\infty$$ to $$+\infty$$ in both directions:

We could describe this family of curves as:

$$y = x^2 + C$$

Where C is a constant number. So for every C we get a different curve. We could then swap this around so that we choose an x and a y and that defines which curve we are on:

$$C = y - x^2$$

We could go even crazier and call this equation a function of the two variables x and y. "function" here means an "operation" or "combination". We would write this as:

$$f(x,y) = y - x^2$$

A mathematical gradient is very similar to the popular usage of the word "gradient" which denotes the steepness of a hill, as in signs like these:

We could write a function for the one-dimensional Welsh hill on the left:

$$f(x) = 0.25x$$

The mathematical symbol for a gradient is confusingly the same as the covariant derivative (though they are related). It also uses the nabla symbol $$\nabla$$. The gradient of a function is the derivative:

$$\nabla y = \frac{dy}{dx} = \frac{d}{dx} (0.25x) = 0.25 = 25\%$$

Maybe in some hilly mathematical paradise they actually put f(x) = 0.25x on the signs instead of 25%. That's very steep. You can see in the bottom right a cyclist already walking his/her bike.

In more dimensions, the mathematical gradient becomes a vector which points up the steepest slope. For example, below is a map of a lake near the Peak District between Manchester and Sheffield. The little wiggly lines are contours, showing the height of the land above sea level. Combs Reservoir sits in a valley. To the left of it is Ladder Hill. I've chosen three spots on the map, and drawn an arrow in the steepest direction from each spot. In that direction the contour lines bunch together. It would probably be very difficult on a bicycle:

Who knows what the equation for the Peak District actually is? Instead we will calculate the gradient of the congruence of curves above. First of all we can plot the function in three dimensions, treating the C or f(x,y) as the third height dimension:

Now imagine that this is a hill somewhere in the Peak district. We can look at it from above and draw the contour lines. They look very much like the congruence of curves:

And now we can compute the gradient by adding the two partial derivatives together (after being multiplied by the basis vectors):

$$\nabla f(x,y) = \frac{df}{dx} \begin{bmatrix} 1 \\ 0 \end{bmatrix} + \frac{df}{dy} \begin{bmatrix} 0 \\ 1 \end{bmatrix} = -2x \begin{bmatrix} 1 \\ 0 \end{bmatrix} + 1 \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \begin{bmatrix} -2x \\ 1 \end{bmatrix}$$

We can plot this gradient over whole congruence of curves. Imagine that we are looking down on a hill. The sides are very steep and the central bit less so. These gradients are scaled down or else the whole thing would be covered with lots of red arrows:

This is already a vector field because it covers the whole coordinate system. Now we'll look at how to make a tangent vector field.

The tangent vector field is any vector field which is normal to the gradient. "Normal" doesn't mean "ordinary" in this case, it means "perpendicular". Vectors are perpendicular when their dot product equals zero. For example the vector field V:

$$V = \begin{bmatrix} 1 \\ 2x \end{bmatrix}$$

This is perpendicular to the gradient because:

$$\nabla f(x,y) V = \begin{bmatrix} -2x & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 2x \end{bmatrix} = -2x * 1 + 1 * 2x = 0$$

Also note that the magnitude of the normal doesn't matter, only the direction. So it could be 10 times bigger or smaller. Therefore all the graphs on this page have been scaled down.

## Tangent Vector Fields

Now we can plot this tangent vector field V:

In the previous article we had a more complicated vector field like this (except in the female/male coordinate system):

$$V = \begin{bmatrix} x+y \\ 1 \end{bmatrix}$$

I wondered for a while how a tangent vector field could have an x and a y in it. What kind of congruence of curves could possibly create a vector field like that? To be honest, I don't know (yet). But here's a different one with both an x and y:

$$y^2 + x^2 = 1$$

And make into a congruence of curves:

$$y^2 + x^2 = C$$

And turn that into a function:

$$f(x,y) = x^2 + y^2$$

Now we can compute the gradient:

$$\nabla f(x,y) = \begin{bmatrix} \frac{df}{dx} \\ \frac{df}{dy} \end{bmatrix} = \begin{bmatrix} 2x \\ 2y \end{bmatrix}$$

And a normal to this:

$$V = \begin{bmatrix} -x \\ y \end{bmatrix}$$

We can plot this tangent vector field:

## Tangents to a Sphere

In three dimensions, the normal to the gradient will be a plane, and we can choose any vector field in that plane as the tangent vector field. For example, for a sphere:

$$f(x,y,z) = x^2 + y^2 + z^2 - C$$

$$\nabla f(x,y,z) = \begin{bmatrix} 2x \\ 2y \\ 2z \end{bmatrix}$$

And something perpendicular to this is:

$$V = \begin{bmatrix} -y \\ -x \\ 1 \end{bmatrix}$$

This vector field lies in the plane normal to the gradient because:

$$\nabla f(x,y,z) V = \begin{bmatrix} 2x & 2y & 2z \end{bmatrix} \begin{bmatrix} -y \\ -x \\ 0 \end{bmatrix} = 2x * -y + 2y * -x + 2z * 0 = 0$$

## Parametric Equations

This is a slight tangent (very weak pun intended). There is another way to write down equations like $$y=x^2$$ which works especially well for more complex equations like circles, and now is a good time to mention it. Imagine a new parameter, which we'll call $$\theta$$. It represents how far along the curve we are. For example, here is a circle with marks every 45 degrees:

We can write the equation for this circle in two ways. First of all the traditional way as above:

$$y^2 + x^2 = 1$$

And now we'll also write it parametrically as two different equations like this:

$$x = \cos \theta$$

$$y = \sin \theta$$

Here $$\theta$$ is the degrees around the curve. The red mark on the right at (1,0) above corresponds to $$\theta=0$$. For graphing, instead of choosing an x and finding its corresponding y, we choose a $$\theta$$ and find the x and y. This rule from trigonometry shows that these equations are equivalent ways of expressing a circle:

$$x^2 + y^2 = \cos^2 \theta + \sin^2 \theta = 1$$

## Directional Derivative

The directional derivative is the amount of gradient (aka derivative) in a specific direction (along a vector). For example, let's we say have the vector field:

$$W = \begin{bmatrix} 0.2 \\ 0.4 \end{bmatrix}$$

I'll add that vector field to the plot with a bunch of black arrows:

The next plot shows how much of the gradient goes in the direction of this vector field:

On the left of this graph, where the gradient points in a similar direction to W, it is a lot. In the middle, the directional derivative disappears because the gradient is perpendicular to the W. On the right, it points in the opposite, negative direction.

How is this computed? Well, the sybmol for the directional derivative is the $$\nabla$$ with a little W as a subscript. This means to multiply-and-add (aka contract or "take the dot product of") the gradient times the vector field W. Like this:

$$\nabla_W f(x,y) = W^a \nabla {f(x,y)}^a = \begin{bmatrix} 0.2 & 0.4 \end{bmatrix} \begin{bmatrix} -2x \\ 1 \end{bmatrix} = -0.4x + 0.2$$

The result of this is a single number (a scalar) which describes how long the arrows are in the graph above. For example, at the point (0.5,1) the directional derivative vanishes -0.4 * 0.5 + 0.2 = 0 because the gradient is perpendicular to W.

## Absolute Derivative

Related to the directional derivative is the absolute derivative. This is the amount of covariant derivative in a specific direction (along the tangent vector field in this case). Let's choose a more complicated vector field:

$$W = \begin{bmatrix} x+y \\ 1 \end{bmatrix}$$

And let's compute the covariant derivative:

$$\nabla W = \partial W + \Gamma W = \begin{bmatrix} \frac{dW_x}{dx} & \frac{dW_x}{dy} \\ \frac{dW_y}{dx} & \frac{dW_y}{dy} \end{bmatrix} + 0 W = \begin{bmatrix} 1 & 1 \\ 0 & 0 \end{bmatrix}$$

Because this is flat space, $$\Gamma$$ is 0, and the covariant derivative reduces to the two partial derivatives. The top row is the derivative of $$W_x$$ and the bottom row $$W_y$$. We now multiply this matrix times the tangent vector field.

$$\nabla_V W = \nabla W V = \begin{bmatrix} 1 & 1 \\ 0 & 0 \end{bmatrix} \begin{bmatrix} 1 \\ 2x \end{bmatrix} = \begin{bmatrix} 1+2x \\ 0 \end{bmatrix}$$

The symbol for the absolute derivative is the $$\nabla$$ with a subscript. It just means that $$\nabla W$$ gets multiplied by the subscript V.

## Parallel Transport

Where am I going with all this? Not much further as it happens. A vector/tensor W is said to be parallel transported along a congruence of curves if the absolute derivative is zero. Parallel transport magically happens when:

$$\nabla_V W = 0$$

This didn't happen for the W above because the absolute derivative was not zero. So let's choose a new W:

$$W = \begin{bmatrix} 2x^2 - 2y \\ 1 \end{bmatrix}$$

And compute its covariant derivative:

$$\nabla W = \partial W + \Gamma W = \begin{bmatrix} 4x & -2 \\ 0 & 0 \end{bmatrix}$$

And now let's calculate the absolute derivative:

$$\nabla_V W = \nabla W V = \begin{bmatrix} 4x & -2 \\ 0 & 0 \end{bmatrix} \begin{bmatrix} 1 \\ 2x \end{bmatrix} = \begin{bmatrix} 4x - 2 * 2x \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$

What does this mean in practice? It means that our vector field will be the same everywhere along the curve, as in this graph:

This makes perfect sense really because $$y = x^2$$ so the top part of our W is really $$2x^2-2y = 2x^2-2x^2 = 0$$.

## Parallel Transport in Cyland

Howver, this is all much less obvious in Cyland. This is a cylindrical habitat floating somewhere out in space:

.

Many years ago in Cyland a famous artist decided to create a series of 16 massive parabolas onto the surface of Cyland in honour of differential geometry. They were created as canals. Standing on the ground of Cyland they stretched into the distance parabolically. But what did they look like when viewed from space?

These are the equations to go between flat (x,y) and Cyland-from-space (s,u) coordinates (standing for sideways and up/down):

$$x = s$$

$$y = \arcsin(u)$$

So our family of curves:

$$y = x^2 + C$$

Becomes:

$$\arcsin(u) = s^2 + C$$

We can solve this for u:

$$u = \sin (s^2 + C)$$

We can plot the parabolas as seen from a distance. On the left are the canals on a flat map, and on the right as seen from space. The C=0 canal is wider than the others. Even tourists from Earth agree they are quite beautiful:

How does this affect parallel transport? First of all let's transform W and V into Cyland-from-space coordinates:

$$T = \begin{bmatrix} 1 & 0 \\ 0 & \sqrt {1 - u^2} \end{bmatrix}$$

$$\tilde W = TW = T \begin{bmatrix} 2x^2 - 2y \\ 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & \sqrt {1 - u^2} \end{bmatrix} \begin{bmatrix} 2s^2 - 2 \arcsin (u) \\ 1 \end{bmatrix} = \begin{bmatrix} 2s^2 - 2 \arcsin (u) \\ \sqrt {1 - u^2} \end{bmatrix}$$

$$\tilde V = TV = T \begin{bmatrix} 1 \\ 2x \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & \sqrt {1 - u^2} \end{bmatrix} \begin{bmatrix} 1 \\ 2s \end{bmatrix} = \begin{bmatrix} 1 \\ 2s \sqrt {1 - u^2} \end{bmatrix}$$

And now we can caculate the covariant derivative:

$$\nabla \tilde W = \partial \tilde W + \Gamma \tilde W = \begin{bmatrix} 4s & \frac{-2}{\sqrt{1-u^2}} \\ 0 & \frac{-u}{\sqrt{1-u^2}} \end{bmatrix} + \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} _\class{matrix3d}{\begin{bmatrix} 0 & 0 \\ 0 & \frac {u}{1-u^2} \end{bmatrix}} \begin{bmatrix} 2s^2 - 2 \arcsin (u) \\ \sqrt {1 - u^2} \end{bmatrix} = \begin{bmatrix} 4s & \frac{-2}{\sqrt{1-u^2}} \\ 0 & 0 \end{bmatrix}$$

Did you notice what happened there? The bottom right corner of $$\Gamma \tilde W$$ cancelled out the bottom right of $$\partial \tilde W$$. And now the absolute derivative:

$$\nabla_{\tilde V} \tilde W = \nabla \tilde W \tilde V = \begin{bmatrix} 4s & \frac{-2}{\sqrt{1-u^2}} \\ 0 & 0 \end{bmatrix} \begin{bmatrix} 1 \\ 2s \sqrt {1 - u^2} \end{bmatrix} = \begin{bmatrix} 4s + (\frac{-2}{\sqrt{1-u^2}}) (2s \sqrt {1 - u^2}) \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$

It works! The transformed $$\tilde W$$ is still parallel transported along the transformed $$\tilde V$$ which is a tangent vector field to the transformed congruence of parabolic curves.

Let's see what that looks like, but I'll use a slightly smaller V (scaled down to $$\pi/8$$ so that the lines match up). Imagine that the artist has also planted a series of vast forests connecting the Grand Canal to the canal above it. All the forests should be exactly the same size, so parallel transport comes in very handy. The artist just laid out the first forest and then transported it along the canal. From the ground and from space, it looks like this:

To be clear, the green forest vector is being parallel transported along the parabolic curves. In practice, I think that you would start with a tangent vector field, and have to work out the corresponding parallel-ly transported vector.

## Geodesics

A geodesic is the shortest path between two points, also known as a straight line. Except it is only really straight in flat space. On a sphere or in Cyland it is not. A geodesic is a curve with a tangent vector field which is parallel transported along itself. In other words when:

$$\nabla_V V = 0$$

Let's start with a new congruence of curves which correspond to the two dimensional line y=2x:

$$y = 2x + C$$

$$f(x,y) = y - 2x$$

$$\nabla f(x,y) = \begin{bmatrix} -2 \\ 1 \end{bmatrix}$$

And perpendical to that is our tangent vector field:

$$V = \begin{bmatrix} 0.1 \\ 0.2 \end{bmatrix}$$

This is a constant vector field because it only has numbers and no variables. This vector field can be transported along itself because it has a zero derivative:

$$\nabla_V V = \nabla V V = (\partial V + \Gamma V) V = (\begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} + 0) V = 0$$

What happens to this congruence of curves and vector field in Cyland? Our family of curves becomes:

$$\arcsin(u) = 2s + C$$

$$u = \sin (2s + C)$$

We can also tranform the tangent vector field:

$$\tilde V = TV = \begin{bmatrix} 1 & 0 \\ 0 & \sqrt {1 - u^2} \end{bmatrix} \begin{bmatrix} 0.1 \\ 0.2 \end{bmatrix} = \begin{bmatrix} 0.1 \\ 0.2 \sqrt {1 - u^2} \end{bmatrix}$$

Now let's calculate the covariant derivative (which we expect to be zero as well):

$$\nabla \tilde V = \partial \tilde V + \Gamma \tilde V = \begin{bmatrix} 0 & 0 \\ 0 & \frac{-0.2u}{\sqrt{1-u^2}} \end{bmatrix} + \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} _\class{matrix3d}{\begin{bmatrix} 0 & 0 \\ 0 & \frac {u}{1-u^2} \end{bmatrix}} \begin{bmatrix} 0.1 \\ 0.2 \sqrt {1 - u^2} \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 0 & \frac{-0.2u}{\sqrt{1-u^2}} + \frac{0.2u}{\sqrt{1-u^2}} \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix}$$

Since it is zero, it follows that:

$$\nabla_{\tilde V} \tilde V = \nabla \tilde V \tilde V = 0 * \tilde V = 0$$

And because $$\tilde V$$ gets parallel transported along itself, it means that our family of curves $$u=\sin(2s+C)$$ represents geodesics, a.k.a., "straight" lines, in Cyland as well. Every one of the blue lines in both these graphs is a geodesic. The one on the left shows geodesics in flat space and on the right in Cyland as viewed from a distance:

In flat space, any linear combination of y and x will have a zero derivative and so will describe a geodesic. But you can see that in a curved space like Cyland the definition of "straight line" is not so simple any more.

## Riemann Curvature Tensor

The 19th century mathematician Bernhard Riemann made many contributions to maths, some of which were very important in Einstein's formulation of General Relativity. One of these is the Riemann Curvature Tensor. This is a four dimensional tensor, computed from $$\Gamma$$ which describes the intrinsic curvature of surfaces.

I've read a few descriptions of intrinsic versus extrinsic curvature. The most intuitive explanation relates to measuring the angles of a triangle. The first image below comes from the Wikipedia article about the shape of the universe. It shows a sphere, a saddle (or hyperbolic surface) and a plane. Only on the plane do the angles of a triangle add up to 180 degrees. On a sphere, it is over 180, and on a saddle under 180. The second image also from Wikipedia shows a hyperbolic triangle more clearly:

The sphere and the saddle are intrinsically curved because their triangles' angles don't add up to 180 degrees. Another way of saying this is "Can a person living on the surface tell if it is curved?" On a sphere, they could by drawing a triangle on the ground and measuring the angles (assuming the ground is extremely flat, their instruments are extremely precise, and they know what they are doing). On a cylinder however, they couldn't. Even if Cyland looks curved from space, that is extrinsic rather than intrinsic curvature. They can't tell their world is curved! They have to rely on pictures from space. (The people of Cyland are a bit embarrassed about this, so don't bring it up if you ever go there.)

The Riemann curvature tensor captures this intrinsic curvature. The formula is:

$$R^a_{bcd} = \partial_c \Gamma^a_{bd} - \partial_d \Gamma^a_{bc} + \Gamma^e_{bd} \Gamma^a_{ec} - \Gamma^e_{bc} \Gamma^a_{ed}$$

It's not quite as intimidating as it looks but we have to be careful with the indices when multiplying $$\Gamma$$. Recall that $$\Gamma$$ looks like this:

$${\Gamma^c}_{ab} = \ \overset{a}\downarrow \underset {c \searrow} {\overset{b}{\overrightarrow{ \begin{bmatrix}{\Gamma^1}_{11} & {\Gamma^1}_{12} \\ {\Gamma^1}_{21} & {\Gamma^1}_{22}\end{bmatrix} }}} _\class{matrix3d}{ \overset{a}\downarrow \overset{b}{\overrightarrow{ \begin{bmatrix}{\Gamma^2}_{11} & {\Gamma^2}_{12} \\ {\Gamma^2}_{21} & {\Gamma^2}_{22}\end{bmatrix}}} }$$

In a two dimensional coordinate system (with just an x and y), $$\Gamma$$ is a 2x2x2 box of numbers. It has a front half and a back half. In three dimensions it would be a 3x3x3 box. R on the other hand is a 2x2x2x2 box. You can imagine it as two $$\Gamma$$ lying on top of each other. Or you can imagine that R is made of 2x2=4 boxes of 2x2. Here are what those 4 boxes of 4 numbers look like ($$\Gamma_\text{front}$$ and $$\Gamma_\text{back}$$ each represent the 2x2 box for c=1 and c=2 respectively):

$$R_{c=1, d=1} = \begin{bmatrix} \frac{\partial}{\partial x} \Gamma_\text{front} - \frac{\partial}{\partial x} \Gamma_\text{front} + \Gamma_\text{front} * \Gamma_\text{front} - \Gamma_\text{front} * \Gamma_\text{front} \end{bmatrix} = 0$$

$$R_{c=2, d=1} = \begin{bmatrix} \frac{\partial}{\partial y} \Gamma_\text{front} - \frac{\partial}{\partial x} \Gamma_\text{back} + \Gamma_\text{front} * \Gamma_\text{back} - \Gamma_\text{back} * \Gamma_\text{front} \end{bmatrix}$$

$$R_{c=1, d=2} = \begin{bmatrix} \frac{\partial}{\partial x} \Gamma_\text{back} - \frac{\partial}{\partial y} \Gamma_\text{front} + \Gamma_\text{back} * \Gamma_\text{front} - \Gamma_\text{front} * \Gamma_\text{back} \end{bmatrix}$$

$$R_{c=2, d=2} = \begin{bmatrix} \frac{\partial}{\partial y} \Gamma_\text{back} - \frac{\partial}{\partial y} \Gamma_\text{back} + \Gamma_\text{back} * \Gamma_\text{back} - \Gamma_\text{back} * \Gamma_\text{back} \end{bmatrix} = 0$$

Remember that the matrix/tensor multiplications are not communative so:

$$\Gamma_\text{front} * \Gamma_\text{back} \ne \Gamma_\text{back} * \Gamma_\text{front}$$

We can see that half of R (when c=1,d=1 and c=2,d=2) is zero. In three dimensions, one third of all entires would be 0. And in four dimensions, one quarter of it would be 0.

Now we can compute the Riemann tensor for Cyland. The $$\Gamma$$ for Cyland is:

$$\begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} _\class{matrix3d}{\begin{bmatrix} 0 & 0 \\ 0 & \frac {u}{1-u^2} \end{bmatrix}}$$

The only non-zero entry in this $$\Gamma$$ is right at the back. So in the Riemann tensor, the only non-zero entries will be for $$\frac{\partial}{\partial y} \Gamma_\text{back}$$ and $$\Gamma_\text{back} * \Gamma_\text{back}$$, and both of these will cancel out. Which means the Riemann tensor will be all zeros as well. Which means that Cyland has only extrensic and not intrinsic curvature.

## Parallel Transport on a Sphere

A sphere on the other hand does have intrinsic curvature. I won't work it out here, but you can view the four non-zero entries of a sphere's Riemann tensor.

There is an example of parallel transport around a sphere involving Roman soliders which sometimes gets mentioned. The example is like this: Imagine you are a spear-carrying solider at point B in the graph below. You can parallel transport the spear back to point A as shown. The spear is now pointing to the right. Or you can transport up to N and then down to A, in which case it will be pointing upwards. Both paths $$B \rightarrow A$$ and $$B \rightarrow N \rightarrow A$$ are perfectly valid parallel transports. But depending on which path you take the spears at A will be pointing in different directions! This means that on a sphere parallel transport is path dependent.

This is in contrast to a cylinder, where parallel transport is always path independent. In other words, no matter which way you parallel transport the spear on Cyland, it will always end up pointing in the same direction. (I did not understand this at first so I asked about it on Physics StackExchange.)

Because of this cylinders can also be called affine flat spaces whereas spheres can not. So all the following concepts are related: extrinsic (or no) curvature = path independent parallel transport = vanishing Riemann tensor = affine flat

And for surfaces like spheres and saddles: intrinsic curvature = path dependent parallel transport = non-zero Riemann curvature tensor = not flat

So in fact, when I have referred to Cyland as a curved space up till now, I really meant extrinsically curved. By these definitions it is still (affine) flat.

## Conclusion

This article has covered parallel transport and geodesics, touching on the congruence of curves, gradients, directional derivatives and the Riemann curvature tensor along the way. This represents pages 74-81 from the text book I've been following. The next article builds up to the Einstein tensor.

## Octave Commands

%y=x^2
hold off;
x = [-3:0.1:3];
plot (x, x.^2, 'LineWidth', 4);
title ("Plot of y=x^2 from x=-3 to x=3");
grid on; axis ([-3 3 0 6]);
print "plots/geodesics-x2.gif";

%Congruence of y=x^2 curves
hold off;
x = [-3:0.1:3];
for v=[-10:1:10]; plot (x, v+x.^2, 'LineWidth', 1); hold on; end;
plot (x, x.^2, 'LineWidth', 4);
title ("Congruence of curves of y=x^2"); %plot a thicker line for y=x^2
grid on; axis ([-3 3 0 6]);
print "plots/geodesics-x2-congruence.gif";

%3D hill
hold off;
[x, y] = meshgrid ([-3:0.1:3], [0:0.1:6]);
mesh (x, y, y - x.^ 2);
title ("3D plot of f(x,y)=y-x^2");
print "plots/geodesics-x2-hill.gif";

%Contours of f(x,y)=y-x^2
hold off;
[x, y] = meshgrid ([-3:0.1:3], [0:0.1:6]);
contour (x, y, y - x.^ 2, 20);
title ("Contour lines for f(x,y)=y-x^2");
print "plots/geodesics-x2-contours.gif";

%Scaled gradient vectors field for y=x^2
hold on;
[x, y] = meshgrid ([-3:0.4:6]);
quiver (x, y, 0.1 * -2*x, 0.1 * 1, 'r-', 'LineWidth', 1, 'AutoScale', 'off', 'MaxHeadSize', 0.1);
grid on; axis ([-3 3 0 6]);

%Tangent vecors to y=x^2
hold off;
[x, y] = meshgrid ([-3:0.1:3], [0:0.1:6]);
contour (x, y, y - x.^ 2, 20);
hold on;
[x, y] = meshgrid ([-3:0.4:6]);
quiver (x, y, 0.1 * 1, 0.1 * 2*x, 'r-', 'LineWidth', 1, 'AutoScale', 'off', 'MaxHeadSize', 0.1);
title ("Scaled tangent vector field [1,2x]");
grid on; axis ([-3 3 0 6]);
print "plots/geodesics-x2-tangent-vector-field.gif";

%Cirlces with tangents
hold off;
t = [0:pi/30:2*pi];
for r=[0.1:0.1:1.5]; plot (r * cos(t), r * sin(t)); hold on; end;
grid on; axis ([-1 1 -1 1]);
[x, y] = meshgrid ([-1:0.1:1]);
quiver (x, y, 0.1 * y, 0.1 * -x, 'r-', 'LineWidth', 1, 'AutoScale', 'off', 'MaxHeadSize', 0.1);
title ("Scaled tangent vector field [y,-x]");
print "plots/geodesics-circle-tangent-vector-field.gif";

%Circle with tick marks
hold off;
t = [0:0.01:2*pi];
plot (cos(t), sin(t), 'LineWidth', 2);
grid on; axis ([-1.2 1.2 -1.2 1.2]);
hold on;
t = [0:pi/4:2*pi];
plot (cos(t), sin(t), 'r*');
title ("Circle with marks every t=pi/4");
print "plots/geodesics-circle-with-marks.gif";

%Directional derivative
hold off;
[x, y] = meshgrid ([-3:0.1:3], [0:0.1:6]);
contour (x, y, y - x.^ 2, 20);
title ("Contour lines for f(x,y)=y-x^2");
hold on;
[x, y] = meshgrid ([-3:0.5:3], [0:0.5:6]);
quiver (x, y, 0.1 * 1, 0.1 * 2*x, 'r-', 'LineWidth', 1, 'AutoScale', 'off', 'MaxHeadSize', 0.1);
quiver (x, y, 0.2, 0.4, 'k-', 'LineWidth', 1, 'Autoscale', 'off', 'MaxHeadSize', 0.05);
title ("Scaled gradients with vector field [0.2, 0.4]");
print "plots/geodesics-x2-tangent-with-vector-field.gif";

hold off;
[x, y] = meshgrid ([-3:0.1:3], [0:0.1:6]);
contour (x, y, y - x.^ 2, 20);
title ("Contour lines for f(x,y)=y-x^2");
hold on;
[x, y] = meshgrid ([-3:0.4:3], [0:0.4:6]);
quiver (x, y, 0.2 .* (-0.4*x+0.2), 0.4 .* (-0.4*x+0.2), 'k-', 'LineWidth', 1, 'Autoscale', 'off', 'MaxHeadSize', 0.1);
title ("Directional derivative along [0.2, 0.4]");
print "plots/geodesics-x2-directional-derivative.gif";

%y=x^2 with transported vector
hold off;
x = [-3:0.2:3];
plot (x, x.^2, 'LineWidth', 1); hold on;
%plot (x,y) pointing to W=(2x^2-2y,1) where y=x^2, so basically (x,x^2) to (0,1)
quiver (x, x.^2, 2 * x.^2 - 2 .* (x.^2), 1, 'g-', 'LineWidth', 1, 'Autoscale', 'off', 'MaxHeadSize', 0.1);
grid on; axis ([-3 3 0 6]);
title ("Parallel transported vector along y=x^2");
print "plots/geodesics-x2-with-parallel-transport.gif";

%Congruence of y=x^2 curves in Cyland
hold off;
x = [-pi/2:pi/20:pi/2];
for v=[-2*pi:pi/8:2*pi]; plot (x, v+x.^2, 'LineWidth', 1); hold on; end;
plot (x, x.^2, 'LineWidth', 4);
title ("Parabolic canals on a flat map"); %plot a thicker line for y=x^2
grid on; axis ([-pi/2 pi/2 -pi/2 pi/2]);
print "plots/geodesics-x2-congruence-canals.gif";

%Plot some vectors from the main canal
quiver (x, x.^2, (pi/8) * (2 * x.^2 - 2 .* (x.^2)), pi/8, 'g-', 'LineWidth', 3, 'Autoscale', 'off', 'MaxHeadSize', 0.1);
title ("Parabolic canals with woods");
print "plots/geodesics-x2-congruence-canals-woods.gif";

%u=sin(s^2+C) front half only
%To do this solve for s = sqrt (arcsin(u) - C) and only show u from -1 to 1
hold off;
for v=[-pi/2:pi/8:pi];
smin = sqrt (asin (-1) + v); smax = sqrt (asin (1) + v);
s = [smin : 0.1: smax];
lw = 1; if (v == 0); lw = 4; end;
plot (s, sin(s.^2 - v), 'LineWidth', lw); hold on;
plot (-s, sin(s.^2 - v), 'LineWidth', lw); hold on;
end;
axis ([-pi/2 pi/2 -pi/2 pi/2]);
title ("Parabolic canals from space");
grid on;
print "plots/geodesics-sins2-congruence-front.gif";

%plot parallel transported vectors on top of this only for v=0
smin = sqrt (asin (-1)); smax = sqrt (asin (1));
s = [smin : 0.1: smax];
%plot (s,u) pointing to W=(2s^2-2arcsin(u),sqrt(1-u^2)) where y=x^2 or arcsin(u)=s^2 or u=sin(s^2)
%so basically (s,sin(s^2)) to (0,sqrt(1-(sin s^2)^2))
quiver (s, sin (s.^2), 0, pi/8 * sqrt (1 - (sin (s.^2) .^ 2)), 'g-', 'LineWidth', 3, 'Autoscale', 'off', 'MaxHeadSize', 0.1);
hold on;
quiver (-s, sin (s.^2), 0, pi/8 * sqrt (1 - (sin (s.^2) .^ 2)), 'g-', 'LineWidth', 3, 'Autoscale', 'off', 'MaxHeadSize', 0.1);
axis ([-pi/2 pi/2 -pi/2 pi/2]);
title ("Parabolic canals with woods from space");
print "plots/geodesics-sins2-congruence-front-woods.gif";

%Constant vector field in flat space
hold off;
x=[-pi/2:pi/8:pi/2];
for C=[-2*pi:pi/8:2*pi]; plot (x, -2*x + C, 'b-'); hold on; end;
[x, y] = meshgrid ([-pi/2:pi/8:pi/2]);
quiver (x, y, 0.1, 0.2, 'g-', 'LineWidth', 1, 'AutoScale', 'off', 'MaxHeadSize', 0.1);
title ("Straight lines y=-2x with tangent vector field");
grid on; xlabel ('x'); ylabel ('y');
axis ([-pi/2 pi/2 -pi/2 pi/2]);
print "plots/geodesics-constant-vector-field.gif";

%Constant vector field in Cyland
hold off;
s=[-pi/2:pi/32:pi/2];
for C=[-2*pi:pi/8:2*pi]; plot (s, sin(2*s + C), 'b-'); hold on; end;
[s, u] = meshgrid ([-pi/2:pi/16:pi/2], [-1:0.2:1]);
quiver (s, u, 0.1, 0.2 * sqrt (1 - u.^2), 'g-', 'LineWidth', 1, 'AutoScale', 'off', 'MaxHeadSize', 0.1);
title ("Same staright lines on Cyland from space");
grid on; xlabel ('s'); ylabel ('u');
axis ([-pi/2 pi/2 -pi/2 pi/2]);
print "plots/geodesics-constant-vector-field-in-cyland.gif";

%Constant vector field in Cyland
hold off;
s=[-pi/2:pi/32:pi/2];
for C=[-2*pi:pi/8:2*pi]; plot (s, sin(2*s + C), 'b-'); hold on; end;
[s, u] = meshgrid ([-pi/2:pi/16:pi/2], [-1:0.2:1]);
quiver (s, u, 0.1, 0.2 * sqrt (1 - u.^2), 'g-', 'LineWidth', 1, 'AutoScale', 'off', 'MaxHeadSize', 0.1);
title ("Same curves on Cyland from space");
grid on; xlabel ('s'); ylabel ('u');
axis ([-pi/2 pi/2 -pi/2 pi/2]);
print "plots/geodesics-constant-vector-field-in-cyland.gif";