Multi-Pendulum Chaos Simulator
Simulate double and triple pendulums via Lagrangian mechanics - observe deterministic chaos and sensitive dependence on initial conditions in real time.
The double and triple pendulum are canonical examples of deterministic chaos: the equations of motion are exact and deterministic, yet trajectories diverge exponentially from nearby initial conditions.
Lagrangian Formulation
Double Pendulum - Exact Lagrangian
\(\phantom{\mathcal{L}_2 = {}}+ (m_1+m_2)gL_1\cos\theta_1 + m_2 gL_2\cos\theta_2\)
The Euler–Lagrange equations give the closed-form angular accelerations: \[\ddot\theta_1 = \frac{-G(2m_1+m_2)\sin\theta_1 - m_2 G\sin(\theta_1-2\theta_2) - 2m_2\sin(\theta_1-\theta_2)(\dot\theta_2^2 L_2+\dot\theta_1^2 L_1\cos(\theta_1-\theta_2))}{L_1(2m_1+m_2-m_2\cos(2\theta_1-2\theta_2))}\]
Triple Pendulum - Exact Lagrangian
\(\phantom{\mathcal{L}_3 = {}}+ M_{13}\dot\theta_1\dot\theta_3 + M_{23}\dot\theta_2\dot\theta_3 + V(\theta_1,\theta_2,\theta_3)\)
where \(M_{11}=(m_1+m_2+m_3)L_1^2\), \(M_{22}=(m_2+m_3)L_2^2\), \(M_{33}=m_3 L_3^2\), \(M_{12}=(m_2+m_3)L_1 L_2\), \(M_{13}=m_3 L_1 L_3\), \(M_{23}=m_3 L_2 L_3\), and \(V = -(m_1+m_2+m_3)gL_1\cos\theta_1 - (m_2+m_3)gL_2\cos\theta_2 - m_3 gL_3\cos\theta_3\). The mass matrix system \(M(\mathbf{\theta})\ddot{\mathbf{\theta}}=\mathbf{F}(\mathbf{\theta},\dot{\mathbf{\theta}})\) is inverted via Cramer's rule at each time step.
Sensitive Dependence on Initial Conditions
Set the Perturbation field to launch a second pendulum (B, red) with \(\theta_1\) offset by any amount you enter - try as little as \(0.001\) rad (enter \(0\) for none; expressions like pi/1000 or 1e-5 are accepted). Initially the two trails overlap; within seconds they diverge completely - the Lyapunov exponent is positive.
Trail Coloring
- Color by speed: blue = slow, red = fast (bottom-bob speed).
- Solid color: fixed cyan (A) / red (B).
- Fading trail: recent path fully opaque, older path fades.
Numerical Method
The coupled ODE system is integrated with a user-selectable integrator (see the Integrator control). The default is the 2-stage Gauss–Legendre Runge–Kutta method (GLRK4), an implicit 4th-order symplectic integrator. Symplecticity is the right structure for Hamiltonian mechanics: it guarantees the energy drift is bounded (oscillates around the true value) over arbitrarily long simulations, whereas non-symplectic methods like RK4 exhibit slow secular drift. Each implicit step is solved by fixed-point iteration to tolerance \(10^{-12}\); 3–6 iterations are typical at \(\Delta t = 0.005\,\text{s}\), 8 steps per frame.
Also available is DOP853, the Dormand–Prince 8(5,3) explicit Runge–Kutta method of 8th order (Hairer, Nørsett & Wanner). Used here as a fixed-step scheme, its high order yields very small local truncation error per step; being non-symplectic it does not preserve the bounded-energy property of GLRK4, but it is an excellent general-purpose high-accuracy integrator.
pi/4, etc.Cite this tool
Kapita, S. (2026). Multi-Pendulum Chaos Simulator. Math Tools. https://doi.org/10.5281/zenodo.20981314
Kapita, Shelvean. "Multi-Pendulum Chaos Simulator." Math Tools, 2026, doi.org/10.5281/zenodo.20981314.
@online{kapita2026multipendulum,
author = {Shelvean Kapita},
title = {{Multi-Pendulum Chaos Simulator}},
year = {2026},
organization = {Math Tools},
doi = {10.5281/zenodo.20981314},
url = {https://doi.org/10.5281/zenodo.20981314}
}