Measuring Chaos in the Browser

By Lucian — builder & engineer, LK Forge

"Chaotic" gets thrown around loosely, so we made it a number. Our physics labs run real integrators in your browser, so we took the exact engines behind two of them — the double pendulum and the bifurcation diagram — and measured how fast order turns into unpredictability. Every figure below comes straight out of that code; the reproduce-this box at the end shows exactly how.

A thousandth of a radian, gone in seven seconds

Release two identical double pendulums from almost the same spot and watch how long they stay in step. We start both from the simulator's default position (173.12° and 178.85° from hanging), then nudge one of them by just 0.001 radian — that's 0.0573°, about a seventeenth of a single degree — and integrate both forward with the same RK4 solver the live lab uses.

Key finding: the two pendulums stay visually locked for about 5.61 seconds, then fully decorrelate by 7.2 seconds. The largest Lyapunov exponent is ≈ 1.095 per second — a Lyapunov time of 0.91 s, meaning the gap between them multiplies by e (≈2.7×) roughly every second.

1e-3 1e-2 1e-1 1e0 Gap between the two pendulums (log scale) full divergence · 7.2s 0 4.5 9 time (seconds) lkforge.com
The gap starts at about a thousandth of a unit and climbs a near-straight line on a log scale — the signature of exponential growth — until the pendulums are as different as they can be. Computed from the simulator's own RK4 engine.

The straight climb is the whole story: the error doesn't grow steadily, it grows exponentially. Make the initial nudge ten times bigger and you don't lose ten times the time — full divergence just arrives sooner (2.82 s for a 0.05 rad start versus 7.2 s for 0.001 rad). No matter how precisely you measure the start, the unknown part doubles and redoubles until it swamps everything. That is why the third swing of a double pendulum is, for all practical purposes, unpredictable.

Where chaos begins: r ≈ 3.56989

The double pendulum is chaos in continuous motion. The bifurcation diagram shows the other classic route in, from one of the simplest equations that can misbehave — the logistic map x → r·x·(1−x). Pick a growth rate r, iterate, and see what value the population settles onto. For low r it settles on one number. Turn r up and that single value splits in two, then four, then eight — a period-doubling cascade — with the splits crowding together until, at a precise point, the sequence never repeats at all.

248chaos 2.83.03.23.43.63.84.0 growth rate r lkforge.com
Every point is a value the logistic map settles onto, computed from x₀ = 0.5. One line becomes two, four, eight… then a chaotic band. The dashed lines mark where each doubling happens.

Key finding: the cascade lands at r ≈ 3.00 (period 2), 3.449 (4), 3.544 (8), 3.564 (16), accumulating into chaos at r ≈ 3.56989. About 39% of the range r ∈ [3, 4] is chaotic; the rest still settles to a finite cycle.

The spacing between successive doublings shrinks by a fixed ratio. From our own numbers that ratio comes out to 4.749 then 4.652 — converging on the Feigenbaum constant, 4.669. This is the strange, beautiful part: that same 4.669 governs the double pendulum too, and dripping taps, and heart-rhythm models. The route into chaos is universal — it doesn't care what the underlying equation is. Two labs, one constant.

Reproduce this

Every number and both charts come from scripts/gen-chaos-study.mjs, which copies the exact engines the live labs ship. No dependencies, fully deterministic — you get the same output every run. The two engines are just these:

// Double pendulum — one RK4 step of the equations of motion (g = 9.8, DT = 1/240)
function deriv([th1, w1, th2, w2]) {
  const d = th1 - th2, cd = Math.cos(d), sd = Math.sin(d)
  const den = 3 - Math.cos(2*th1 - 2*th2)                // 2*M1 + M2 - M2*cos(...), equal masses
  const a1 = (-g*3*Math.sin(th1) - g*Math.sin(th1 - 2*th2)
             - 2*sd*(w2*w2 + w1*w1*cd)) / den
  const a2 = (2*sd*(w1*w1*2 + g*2*Math.cos(th1) + w2*w2*cd)) / den
  return [w1, a1, w2, a2]
}

// Logistic map — the whole of it
const next = (x, r) => r * x * (1 - x)

Run two pendulums 0.001 rad apart and time the separation → 7.2 s to full divergence. Iterate the logistic map while raising r and record where the cycle length doubles → chaos at r ≈ 3.56989. That's the entire study.

See it move

Open the double pendulum, turn on the ghost twin, and watch the two arms trace each other for a few seconds before splitting for good — the 7.2-second number, live. Then drag the growth-rate slider on the bifurcation diagram across r ≈ 3.56989 and see the single line shatter into a band. Both run entirely in your browser; nothing is uploaded.

Keep exploring the physics labs

  • Lorenz Attractor — the weather-model system whose butterfly shape gave "the butterfly effect" its name.
  • Reaction–Diffusion — simple local rules that grow the spots and stripes of chaos's creative cousin.
  • All the physics labs — orbits, collisions, waves, fields and fluids, each running real physics in the browser.
Share this X Facebook Reddit

Common Questions

How sensitive is a double pendulum to its starting position?

Extremely. Using the exact simulator engine (RK4 integration, g = 9.8, equal masses and lengths), two double pendulums released just 0.001 radian apart — 0.0573°, a seventeenth of a degree — stay visually locked together for about 5.61 seconds, then diverge completely by 7.2 seconds. The largest Lyapunov exponent is about 1.095 per second, so the gap between them multiplies by e roughly every 0.91 seconds.

At what value does the logistic map become chaotic?

The logistic map x → r·x·(1−x) becomes chaotic at a growth rate of about r = 3.56989. Below that it settles into a stable cycle whose length doubles — period 1, then 2 (at r ≈ 3.00), 4 (r ≈ 3.449), 8 (r ≈ 3.544), 16 — with the steps getting geometrically closer until they accumulate at r ≈ 3.56989 and chaos begins.

What is the Feigenbaum constant?

It is the universal ratio at which a period-doubling cascade converges: about 4.669. Measuring the spacing of the doublings in our own logistic map gives 4.749 for the first ratio and 4.652 for the second — already closing in on 4.669. The remarkable part is that the same constant shows up in the double pendulum, in dripping taps and in many other systems that reach chaos this way, regardless of the specific equations.

Is a chaotic system random?

No. Both systems here are fully deterministic — the same starting numbers produce the same trajectory every single run, which is why this study is reproducible from one short script. Chaos is not randomness; it is sensitive dependence on initial conditions. The rules are exact, but any uncertainty in the starting point grows exponentially, so long-term prediction becomes impossible in practice even though the system is, in principle, perfectly determined.