A pendulum hanging from another pendulum. Two rods, four numbers, and a system that no closed formula can solve. The first pendulum is predictable for centuries. Adding the second one breaks that permanently.
EXP-003
Move the cursor over the canvas — it is part of the simulation.
Drag your finger across the canvas — it is part of the simulation.
What to look for
The trail never repeats a shape. Reload the page and it will draw something else, because the accumulated floating-point error is enough to send it down a different path.
The maths
L = T − V
The Lagrangian: kinetic minus potential energy. The equations of motion come out of it rather than from drawing force diagrams.
d/dt (∂L/∂θ̇) − ∂L/∂θ = 0
Euler-Lagrange, applied to each angle. Expanding it for two coupled rods gives the pair of second-order equations the simulation integrates.
λ > 0
The Lyapunov exponent is positive, which is the formal definition of chaos: nearby trajectories separate exponentially rather than linearly.
How it is built
The expanded equations are integrated three substeps per frame for stability, with a damping factor of 0.9999 so the motion decays over minutes instead of running forever. The tip leaves a 900-point trail that fades along its length.
The code, step by step
Cut straight from lab.js. These are the real lines that run above, not a simplified version.
While the pointer is over the canvas the pendulum stops integrating and simply points at it, with both velocities zeroed. Leave the canvas and it falls from wherever you left it.
n1 and n2 are the expanded Euler-Lagrange numerators and d the shared denominator. Three substeps per frame keep it stable. The damping slider is that final multiplication.
The state is two angles, not two points. Positions come out with plain trigonometry, chained: the second rod hangs from wherever the first one ended up.
Why it matters
It is the cheapest demonstration that determinism and predictability are not the same thing. Every step follows from the previous one with no randomness anywhere, and it is still impossible to say where the tip will be in thirty seconds.
The whole thing
Everything above, in one piece. This is the entire experiment as it lives in lab.js.