Skip to content
Physical AI
All experiments

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.

Loading simulation…

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

θ¨=−gLsin⁡θ−c θ˙\ddot\theta = -\tfrac{g}{L}\sin\theta - c\,\dot\theta
θlin(t)=θ0e−ζω0t(cos⁡ωdt+ζω0ωdsin⁡ωdt),ω0=g/L, ζ=c2ω0\theta_{lin}(t) = \theta_0 e^{-\zeta\omega_0 t}\Big(\cos\omega_d t + \tfrac{\zeta\omega_0}{\omega_d}\sin\omega_d t\Big), \quad \omega_0 = \sqrt{g/L},\ \zeta = \tfrac{c}{2\omega_0}
T0=2πL/g,T=4L/g  K ⁣(sin⁡θ02)T_0 = 2\pi\sqrt{L/g}, \qquad T = 4\sqrt{L/g}\;K\!\big(\sin\tfrac{\theta_0}{2}\big)
E=12mL2θ˙2+mgL(1−cos⁡θ)E = \tfrac12 m L^2 \dot\theta^2 + m g L (1 - \cos\theta)

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