How does it work?
Chaos without chance
A double pendulum is an ordinary pendulum with a second one hanging from its end. Its motion is described by two equations with no randomness at all. If you know the starting angles and velocities exactly, the future is uniquely determined. The trouble lies in the word “exactly”: the tiniest error grows exponentially and after a dozen or so seconds it eats up the whole forecast. That is deterministic chaos.
Equations of motion
The angles θ1, θ2 are measured from the vertical. ω = dθ/dt is the angular velocity and α = dω/dt is the angular acceleration. Kinetic and potential energy:
T = ½(m1 + m2)l12ω12 + ½m2l22ω22 + m2l1l2ω1ω2 cos(θ1 − θ2)
V = −(m1 + m2)gl1 cos θ1 − m2gl2 cos θ2
From the Lagrangian L = T − V and the Euler–Lagrange equations we get two coupled equations (Δ = θ1 − θ2):
(m1 + m2)l1α1 + m2l2α2 cos Δ + m2l2ω22 sin Δ + (m1 + m2)g sin θ1 = 0
l2α2 + l1α1 cos Δ − l1ω12 sin Δ + g sin θ2 = 0
The program solves them with the 4th-order Runge–Kutta method (RK4) using a fixed step h, usually 1 ms. The total energy E = T + V should stay constant. The “drift” readout shows by how many percent it has changed because of numerical errors. Usually that is millionths of a percent. We measure energy from the rest position, so a pendulum hanging still has E = 0.
The butterfly effect and the Lyapunov exponent
In chaotic motion a small difference δ0 between two pendulums grows, on average, exponentially:
δ(t) ≈ δ0 · eλt
λ — Lyapunov exponent
tforecast ≈ 1λ ln δmaxδ0
On a logarithmic chart exponential growth is a straight line, and its slope is λ. The logarithm is merciless: a measurement 1000 times more precise extends the forecast by only ln 1000 / λ ≈ 6.9 / λ. With λ ≈ 1 s⁻¹ that is less than 7 seconds.
Lorenz, the butterfly and the weather forecast
In 1963 the MIT meteorologist Edward Lorenz published the paper “Deterministic Nonperiodic Flow”. In it he showed that a very simple model of convection in the atmosphere, made of just three equations, behaves chaotically. The conclusion was surprising: the weather cannot be predicted arbitrarily far ahead even with a perfect model, because we will never measure the atmosphere perfectly. In 1972 Lorenz titled a talk with the question of whether the flap of a butterfly’s wings in Brazil could set off a tornado in Texas. Hence the name butterfly effect.
Today forecasts are good for roughly a week, and the limit of weather predictability is estimated at about two weeks. That is why weather centers run ensemble forecasts. The European Centre for Medium-Range Weather Forecasts (ECMWF) computes 51 versions of every forecast with slightly altered starting conditions. In other words, it does exactly what our “Butterfly effect” button does. When the copies drift apart, the forecast loses confidence.
The single pendulum for comparison
A single pendulum obeys the equation α = −(g/l) sin θ. For small swings its period is T ≈ 2π√l/g. Its motion is regular: copies move apart at most linearly, because the period depends slightly on the amplitude. Chaos is impossible in such a system. According to the Poincaré–Bendixson theorem, chaos needs at least three dimensions of phase space. A single pendulum has two (θ, ω), and a double one has four.
Normal modes
At small swings even the double pendulum is not chaotic. Its motion is the sum of two natural oscillations, or modes. For m1 = m2 and l1 = l2 = l:
ω1,2 = √(2 ∓ √2) · g/l
in-phase mode: θ₂ = √2·θ₁, anti-phase mode: θ₂ = −√2·θ₁
The “In-phase mode” and “Anti-phase mode” presets set the pendulum in exactly these shapes. We compute them for the current masses and lengths.
Chaos map
In the middle of the map there is too little energy for the lower arm to swing over the top. This happens when (m1 + m2)l1 cos θ1 + m2l2 cos θ2 > (m1 + m2)l1 − m2l2. For equal masses and lengths the condition becomes 2 cos θ1 + cos θ2 > 1. Outside this region the colors form a fractal structure: the longer the simulation time and the finer the grid, the more tiny details appear. The map is symmetric about its center, because the mirror image of a pendulum moves like a mirror image. That is why we only compute half of the pixels.
What did we simplify?
- The balls are points, the rods are rigid and weightless, and the joints have no friction. The rods can pass through each other.
- Air drag γ is simple linear drag: each ball feels a force −γ·m·v. We add the lost energy back when computing the drift, so the drift still measures only the numerical error.
- The map is computed with a step 8 times larger than the animation. So in the most chaotic places the flip time on the map may differ from the one in the simulation. That, too, is a consequence of chaos.