← Laboratorium
Physics · deterministic chaos

Experiment · nonlinear dynamics

Chaos — the double pendulum

Two rods, two balls and not a shred of randomness. And yet after just a few seconds the motion can no longer be predicted. Grab a ball, let it go and watch chaos grow out of simple equations.

Butterfly effect

Lyapunov exponent

Release N copies of the pendulum. Each copy's lower-arm angle is larger than the previous one's by a tiny ε. At first they move together, then suddenly they drift apart.

10
10⁻⁶ rad
ε = 0.000001 rad
split (δ > 0.1)
—
exponent λ
—
Lyapunov time 1/λ
—
10× precision buys
—

δ is the distance between copies in phase space: δ = √(Δθ₁² + Δθ₂² + (Δω₁² + Δω₂²)/Ω²), where Ω = √(g/l̄). The dashed line is a fitted exponential δ₀·eλt.

Phase space

Each point is a state of the arm: its angle and angular velocity. Regular motion draws closed loops. Chaos smears over the whole available space.

The last 20 s of motion. The angle is wrapped to the range from −π to π. In the butterfly effect, the colored dots are the pendulum copies.

Chaos map

Each pixel is a separate double pendulum released from rest at angles (θ1, θ2). The color tells you how long it takes the lower arm to swing over the top for the first time.

Click a pixel (or pick one with the arrow keys and press Enter), and the pendulum will start from there.

no flip during the simulation too little energy — flip impossible

The map will be computed when you scroll here.

Hover over the map to read the flip time.

Challenges

0 / 4
  1. A millionth of a radian

    In the butterfly effect, set N = 2 and ε = 10⁻⁶ rad (0.000001 rad). Release the double pendulums and measure how many seconds it takes them to split apart.

  2. A calm region

    Find a calm, dark region on the chaos map (where the lower arm never flips over) and click it to start the pendulum.

  3. Five somersaults

    Set the angles yourself (drag the balls, use the sliders or the map) so that the lower arm flips over the top 5 times within the first 20 s.

  4. A predictable neighbor

    Switch to the single pendulum and release the copies. Check that they stay together for 30 s (δ < 0.1).

Your progress is saved in this browser.

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.