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
Enable Perturbation to launch a second pendulum (B, red) with \(\theta_1\) offset by as little as \(0.001\) rad. 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 the classical 4th-order Runge-Kutta (RK4) method at fixed step \(\Delta t = 0.005\,\text{s}\), 8 steps per frame.
pi/4, etc.