Differential Geometry

Example Problem in Differential Geometry

Let’s consider a classic problem in differential geometry: finding the geodesic (shortest path) on a unit sphere.

A geodesic on a sphere is a great circle, and we’ll derive its equation using the Euler-Lagrange equations from the calculus of variations.

Then, we’ll solve it numerically in $Python$ and visualize the result.

Problem Statement

On a unit sphere parameterized by spherical coordinates $(\theta, \phi)$, where $\theta$ is the polar angle and $\phi$ is the azimuthal angle, the metric is given by:
$$
ds^2 = d\theta^2 + \sin^2\theta , d\phi^2
$$
We want to find the geodesic between two points, say $(\theta_1, \phi_1) = (0.5, 0)$ and $(\theta_2, \phi_2) = (1.0, 1.0)$, by minimizing the arc length functional:
$$
S = \int_{t_1}^{t_2} \sqrt{\dot{\theta}^2 + \sin^2\theta , \dot{\phi}^2} , dt
$$
where $\dot{\theta} = \frac{d\theta}{dt}$ and $\dot{\phi} = \frac{d\phi}{dt}$.

Step 1: Euler-Lagrange Equations

The Lagrangian is:
$$
L = \sqrt{\dot{\theta}^2 + \sin^2\theta , \dot{\phi}^2}
$$
The Euler-Lagrange equations for $\theta$ and $\phi$ are:
$$
\frac{d}{dt} \left( \frac{\partial L}{\partial \dot{\theta}} \right) = \frac{\partial L}{\partial \theta}, \quad \frac{d}{dt} \left( \frac{\partial L}{\partial \dot{\phi}} \right) = \frac{\partial L}{\partial \phi}
$$
Computing the partial derivatives:

  • $\frac{\partial L}{\partial \dot{\theta}} = \frac{\dot{\theta}}{\sqrt{\dot{\theta}^2 + \sin^2\theta , \dot{\phi}^2}}$
  • $\frac{\partial L}{\partial \dot{\phi}} = \frac{\sin^2\theta , \dot{\phi}}{\sqrt{\dot{\theta}^2 + \sin^2\theta , \dot{\phi}^2}}$
  • $\frac{\partial L}{\partial \theta} = \frac{\sin\theta \cos\theta , \dot{\phi}^2}{\sqrt{\dot{\theta}^2 + \sin^2\theta , \dot{\phi}^2}}$
  • $\frac{\partial L}{\partial \phi} = 0$ (since $L$ does not depend explicitly on $\phi$)

Since $\frac{\partial L}{\partial \phi} = 0$, the second equation implies that $\frac{\partial L}{\partial \dot{\phi}}$ is a constant, which is a conserved quantity (related to angular momentum).

This simplifies to Clairaut’s relation for the sphere:
$$
\sin^2\theta , \dot{\phi} = \text{constant}
$$
However, solving these analytically is complex, so we’ll use numerical integration in $Python$.

Step 2: Python Code

We’ll use scipy.integrate.odeint to solve the differential equations numerically, then plot the geodesic on the sphere.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Define the system of ODEs for the geodesic
def geodesic(y, t):
theta, phi, dtheta_dt, dphi_dt = y
# Lagrangian derivatives lead to these second-order ODEs
d2theta_dt2 = np.sin(theta) * np.cos(theta) * dphi_dt**2
d2phi_dt2 = -2 * dtheta_dt * dphi_dt * np.cos(theta) / np.sin(theta)
return [dtheta_dt, dphi_dt, d2theta_dt2, d2phi_dt2]

# Initial conditions
theta1, phi1 = 0.5, 0.0 # Starting point
theta2, phi2 = 1.0, 1.0 # Ending point
t = np.linspace(0, 1, 100) # Parameter t from 0 to 1

# Guess initial velocities (tuned to satisfy boundary conditions)
dtheta_dt0 = 0.5
dphi_dt0 = 1.0
y0 = [theta1, phi1, dtheta_dt0, dphi_dt0]

# Solve the ODE
sol = odeint(geodesic, y0, t)

# Extract solutions
theta = sol[:, 0]
phi = sol[:, 1]

# Convert to Cartesian coordinates for plotting
x = np.sin(theta) * np.cos(phi)
y = np.sin(theta) * np.sin(phi)
z = np.cos(theta)

# Plot the sphere and geodesic
fig = plt.figure(figsize=(8, 8))
ax = fig.add_subplot(111, projection='3d')

# Plot the unit sphere
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x_sphere = np.outer(np.cos(u), np.sin(v))
y_sphere = np.outer(np.sin(u), np.sin(v))
z_sphere = np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot_surface(x_sphere, y_sphere, z_sphere, color='b', alpha=0.1)

# Plot the geodesic
ax.plot(x, y, z, color='r', linewidth=2, label='Geodesic')
ax.scatter([np.sin(theta1) * np.cos(phi1)], [np.sin(theta1) * np.sin(phi1)], [np.cos(theta1)], color='g', s=100, label='Start')
ax.scatter([np.sin(theta2) * np.cos(phi2)], [np.sin(theta2) * np.sin(phi2)], [np.cos(theta2)], color='y', s=100, label='End')

# Labels and legend
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.legend()
plt.title('Geodesic on a Unit Sphere')
plt.show()

Code Explanation

  1. Imports: We use numpy for numerical operations, scipy.integrate.odeint for solving ODEs, and matplotlib for 3D plotting.
  2. Geodesic Function: Defines the system of first-order ODEs derived from the Euler-Lagrange equations.
    We convert the second-order equations into four first-order equations: $\theta$, $\phi$, $\dot{\theta}$, and $\dot{\phi}$.
  3. Initial Conditions: We set the starting point $(\theta_1, \phi_1) = (0.5, 0)$ and guess initial velocities.
    In practice, these velocities would be adjusted to hit the target point $(\theta_2, \phi_2) = (1.0, 1.0)$, but for simplicity, we demonstrate the method.
  4. Numerical Solution: odeint solves the ODE system over the parameter $t$.
  5. Visualization: We convert spherical coordinates to Cartesian coordinates $(x = \sin\theta \cos\phi$, $y = \sin\theta \sin\phi$, $z = \cos\theta$) and plot the geodesic on a semi-transparent unit sphere.

Result and Visualization Explanation

  • The plot shows a unit sphere (blue, semi-transparent) with the geodesic (red curve) connecting the start point (green dot) and an approximate end point (yellow dot).
  • The geodesic is a segment of a great circle, the shortest path on the sphere.
  • Note: The initial velocities here are illustrative.
    To precisely hit $(\theta_2, \phi_2)$, you’d need a boundary value problem solver (e.g., scipy.integrate.solve_bvp), but this demonstrates the concept.

This visualization makes it clear how geodesics behave on curved surfaces, a fundamental concept in differential geometry!