TExcelTAD
Home › Differential Equations › Conservative Systems and the Pendulum

Conservative Systems and the Pendulum

A system of the form x′′=−V′(x)x'' = -V'(x), a particle moving in a potential VV without friction, conserves energy. That single fact lets us draw its whole phase portrait as the level curves of the energy, and understand the full nonlinear pendulum, including the swing over the top.

Energy

Multiply x′′+V′(x)=0x'' + V'(x) = 0 by x′x':

ddt(12x′2+V(x))=x′x′′+V′(x)x′=0.\frac{d}{dt}\left(\frac{1}{2}x'^2 + V(x)\right) = x'x'' + V'(x)x' = 0.

So E=12y2+V(x)E = \frac{1}{2}y^2 + V(x) with y=x′y = x' is constant along every solution, and trajectories in the (x,y)(x, y) phase plane lie on its level curves E=constE = \text{const}. Minima of VV are centers, maxima of VV are saddles.

The pendulum

A pendulum of length ℓ\ell with angle θ\theta obeys θ′′+gℓsin⁡θ=0\theta'' + \frac{g}{\ell}\sin\theta = 0. With gℓ=1\frac{g}{\ell} = 1:

θ′′=−sin⁡θ,V(θ)=1−cos⁡θ,E=12ω2+1−cos⁡θ.\theta'' = -\sin\theta, \qquad V(\theta) = 1 - \cos\theta, \qquad E = \tfrac{1}{2}\omega^2 + 1 - \cos\theta.
  • θ=0\theta = 0 (hanging down), E=0E = 0: a center. Small swings have EE slightly above 0.
  • θ=±π\theta = \pm\pi (upside down), E=2E = 2: saddles.
  • E<2E < 2: the pendulum swings back and forth (closed orbits).
  • E>2E > 2: it goes over the top and keeps rotating.
  • E=2E = 2: the separatrix, the curve that takes infinitely long to creep up to the top.
python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

th, w = np.meshgrid(np.linspace(-2 * np.pi, 2 * np.pi, 400), np.linspace(-3, 3, 300))
E = 0.5 * w**2 + 1 - np.cos(th)
fig, ax = plt.subplots(figsize=(7, 3.5))
ax.contour(th, w, E, levels=[0.2, 0.6, 1.2, 1.7, 2.3, 3.0, 4.0], colors="gray", linewidths=1)
ax.contour(th, w, E, levels=[2.0], colors="red", linewidths=2)
ax.set_xlabel("theta"); ax.set_ylabel("omega"); ax.set_title("Pendulum phase portrait (red: separatrix E = 2)")
print("closed orbits for E < 2, rotations for E > 2")
closed orbits for E < 2, rotations for E > 2

The period depends on the amplitude

For small angles, sin⁡θ≈θ\sin\theta \approx \theta gives the harmonic oscillator with period 2π2\pi. The real pendulum is slower at large amplitude; the period from amplitude θ0\theta_0 is

T(θ0)=4∫0θ0dθ2(cos⁡θ−cos⁡θ0)=4K ⁣(sin⁡2θ02),T(\theta_0) = 4\int_0^{\theta_0}\frac{d\theta}{\sqrt{2(\cos\theta - \cos\theta_0)}} = 4K\!\left(\sin^2\tfrac{\theta_0}{2}\right),

where KK is the complete elliptic integral (SciPy's ellipk takes the parameter m=k2m = k^2).

python · try it yourself
import numpy as np
from scipy.special import ellipk
from scipy.integrate import solve_ivp

for deg in (5, 45, 90, 150, 179):
    th0 = np.radians(deg)
    T = 4 * ellipk(np.sin(th0 / 2)**2)
    # measure it: time until theta first returns to th0 (event on omega crossing 0 from below)
    ev = lambda t, z: z[1]; ev.direction = 1
    sol = solve_ivp(lambda t, z: [z[1], -np.sin(z[0])], (0, 50), [th0, 0.0], events=ev, rtol=1e-11, atol=1e-12)
    print(f"amplitude {deg:3d} deg: T = {T:.4f} (simulated half-period x2 = {2 * sol.t_events[0][0]:.4f})")
amplitude   5 deg: T = 6.2862 (simulated half-period x2 = 6.2862)
amplitude  45 deg: T = 6.5343 (simulated half-period x2 = 6.5343)
amplitude  90 deg: T = 7.4163 (simulated half-period x2 = 7.4163)
amplitude 150 deg: T = 11.0723 (simulated half-period x2 = 11.0723)
amplitude 179 deg: T = 24.5111 (simulated half-period x2 = 24.5111)

Adding friction

With damping, θ′′+cθ′+sin⁡θ=0\theta'' + c\theta' + \sin\theta = 0, the energy decreases: E˙=−cω2≤0\dot E = -c\omega^2 \le 0. The center at θ=0\theta = 0 becomes a spiral sink (asymptotically stable), the saddles stay saddles. EE is now a Lyapunov function.

In software

  • Physics engines aim to conserve energy over long runs; plain Euler integration makes a frictionless pendulum gain energy and eventually swing over the top. Symplectic integrators avoid this (Long-Time Integration and Symplectic Methods).
  • Pendulum clocks were made accurate by keeping the swing small, exactly because of the amplitude dependence of TT.

Exercises

Exercise 1: Energy levels

A frictionless pendulum (g/ℓ=1g/\ell = 1) passes θ=0\theta = 0 with angular velocity 1.5. Does it go over the top?

Answer

No: E=1.125<2E = 1.125 < 2.

Solution

E=12(1.5)2+1−1=1.125E = \frac{1}{2}(1.5)^2 + 1 - 1 = 1.125. Going over the top needs E>2E > 2, i.e. a speed above 2 at the bottom.

Exercise 2: Classify via the potential

For x′′=x−x3x'' = x - x^3, find VV and classify the critical points.

Answer

V=x44−x22V = \frac{x^4}{4} - \frac{x^2}{2}; centers at x=±1x = \pm 1, a saddle at x=0x = 0.

Solution

−V′(x)=x−x3-V'(x) = x - x^3 gives V=x44−x22V = \frac{x^4}{4} - \frac{x^2}{2}, a double well with minima at ±1\pm 1 and a maximum at 0.

Exercise 3: Energy drift with Euler (code)

Simulate the pendulum from θ=1\theta = 1, ω=0\omega = 0 with plain Euler (h=0.05h = 0.05, 2000 steps) and with semi-implicit Euler (update ω\omega first, then θ\theta with the new ω\omega). Compare the final energies with the initial one.

Answer

Plain Euler gains a lot of energy; semi-implicit Euler stays close to E0=1−cos⁡1≈0.4597E_0 = 1 - \cos 1 \approx 0.4597.

Solution
python · try it yourself
import math
E = lambda th, w: 0.5 * w * w + 1 - math.cos(th)
h = 0.05
a, b = 1.0, 0.0            # plain Euler
c, d = 1.0, 0.0            # semi-implicit Euler
for _ in range(2000):
    a, b = a + h * b, b - h * math.sin(a)
    d = d - h * math.sin(c); c = c + h * d
print(f"start {E(1, 0):.4f}  plain Euler {E(a, b):.4f}  semi-implicit {E(c, d):.4f}")
start 0.4597  plain Euler 3.0966  semi-implicit 0.4677

Test yourself

For x′′=−V′(x)x'' = -V'(x), which quantity is conserved?

  1. xx
  2. x′x'
  3. 12x′2+V(x)\frac{1}{2}x'^2 + V(x)
  4. V(x)V(x)

In a conservative system, a local maximum of the potential is…

  1. a center
  2. a saddle
  3. a sink
  4. a source

The period of a real pendulum…

  1. is independent of amplitude
  2. grows with amplitude
  3. shrinks with amplitude
  4. is always 2π2\pi