Nonlinear pendulum vs the small-angle approximation
The small-angle formula T = 2π√(L/g) is an approximation. At large amplitudes the true pendulum is slower, and an accurate integrator conserves energy when there is no damping.
What it demonstrates
The small-angle formula T = 2π√(L/g) is an approximation. At large amplitudes the true pendulum is slower, and an accurate integrator conserves energy when there is no damping.
How it works
The nonlinear equation θ'' = −(g/L) sin θ − c·θ' is integrated with fourth-order Runge–Kutta at 1 kHz. The ghost pendulum is the closed-form solution of the linearised equation (sin θ ≈ θ), including the same damping.
The measured period comes from successive upward zero crossings, interpolated within a step. It is compared with 2π√(L/g) and with the exact undamped period 4√(L/g)·K(sin(θ₀/2)), where K is the complete elliptic integral of the first kind, computed with the arithmetic–geometric mean.
Adjustable parameters
- Release angle θ₀ (5–175°)
- Length L (0.25–3 m)
- Damping c (0–1 s⁻¹)
- Show/hide small-angle model
Known limitations
- Point mass on a massless rod. A real pendulum has a distributed mass and pivot friction that is not purely viscous.
- The rod is drawn at a fixed size regardless of L.
Equations
Core update rule
const f = (th: number, om: number) => -(g / L) * Math.sin(th) - c * om;
// one RK4 step
const k1 = [om, f(th, om)];
const k2 = [om + h/2 * k1[1], f(th + h/2 * k1[0], om + h/2 * k1[1])];
const k3 = [om + h/2 * k2[1], f(th + h/2 * k2[0], om + h/2 * k2[1])];
const k4 = [om + h * k3[1], f(th + h * k3[0], om + h * k3[1])];
th += h/6 * (k1[0] + 2*k2[0] + 2*k3[0] + k4[0]);
om += h/6 * (k1[1] + 2*k2[1] + 2*k3[1] + k4[1]);Explained in Chapter 2: Physics Engines