Watch deterministic chaos in a double pendulum solved from the real Lagrangian equations, with a ghost copy started 0.0001 radians away.
Knobs patch the running animation live. A few (marked in the code as baked-in values like particle counts) restart the preview.
The real equations of motion, plus a ghost copy to show the chaos.
Your code runs in a sandboxed frame with no access to this page, and it is never sent to a server. three.js demos load the library from jsDelivr; the rest need nothing but the browser.
A double pendulum is two rigid arms, the second hanging from the end of the first, swinging under gravity. It is the standard textbook demonstration of deterministic chaos, and it earns that status honestly: the system has no random element whatsoever, yet its long-term behaviour cannot be predicted. This simulator integrates the actual coupled equations derived from the Lagrangian — not a spring approximation, not a canned animation — and runs a second, faint pendulum alongside the first, started one ten-thousandth of a radian away, so you can watch the two identical systems diverge into unrelated motion.
It is aimed at physics students, teachers looking for a demonstration that does not require apparatus, and anyone curious about what “sensitive dependence on initial conditions” actually looks like when you can adjust the initial conditions yourself. Every parameter is a live control: masses, arm lengths, gravity, damping, simulation speed, and trace length all take effect on the next rendered frame.
Let θ₁ and θ₂ be the angles of the upper and lower arms from vertical, with masses m₁, m₂ and lengths l₁, l₂. Solving the Lagrangian for a planar double pendulum gives two coupled angular accelerations that share a single denominator:
den = 2m₁ + m₂ − m₂·cos(2(θ₁ − θ₂))
The upper arm’s acceleration is
θ̈₁ = [ −g(2m₁ + m₂)sinθ₁ − m₂g·sin(θ₁ − 2θ₂) − 2sin(θ₁ − θ₂)m₂(θ̇₂²l₂ + θ̇₁²l₁cos(θ₁ − θ₂)) ] / (l₁·den)
and the lower arm’s is
θ̈₂ = [ 2sin(θ₁ − θ₂)(θ̇₁²l₁(m₁ + m₂) + g(m₁ + m₂)cosθ₁ + θ̇₂²l₂m₂cos(θ₁ − θ₂)) ] / (l₂·den)
Two structural facts matter more than the algebra. First, every term is either a squared angular velocity, a gravity component, or a coupling through sin(θ₁ − θ₂) — and that coupling term is the entire story. It is the channel through which the lower arm’s motion feeds back into the upper arm and vice versa, and it is nonlinear. A single pendulum at small angles reduces to θ̈ = −(g/l)θ, a linear equation with a periodic solution; the double pendulum never linearises into anything periodic once the swing is large.
Second, the shared denominator vanishes only when m₁ is zero, which is why the upper-mass control has a floor rather than reaching 0. A massless upper bob is a singularity, not a physical configuration.
The faint second pendulum starts at θ₁ + 0.0001 radians — about six thousandths of a degree, a difference far smaller than any physical apparatus could be set to. For the first few seconds the two are visually one line. Then they part. Within twenty seconds they are in unrelated states, and knowing the position of one tells you nothing about the other.
That is sensitive dependence on initial conditions, and it is the working definition of chaos. The separation grows roughly exponentially, at a rate characterised by the system’s largest Lyapunov exponent: a difference of 10⁻⁴ that doubles every fraction of a second reaches order 1 — the scale of the system itself — in a matter of seconds, after which no further growth is possible and the two trajectories are simply independent.
The practical consequence is the important one. Prediction of a chaotic system requires knowing the initial state to a precision that grows exponentially with how far ahead you want to predict. Doubling the forecast horizon does not require twice the precision; it requires exponentially more. No double pendulum simulation, this one included, is a prediction of any real double pendulum, because floating-point rounding is itself a perturbation of exactly the kind the ghost demonstrates. It is why weather forecasts degrade past about ten days regardless of how much computing power is applied.
The simulator uses semi-implicit (symplectic) Euler at a fixed step, subdivided into 12 substeps per rendered frame:
dt = (0.016 × speed) / 12
Two choices are deliberate here. Semi-implicit Euler updates velocity first and then uses the new velocity to update position, which for a conservative system keeps energy bounded instead of letting it drift upward the way plain explicit Euler does. And the step is decoupled from the frame rate on purpose, because a chaotic system amplifies integration error exactly as fast as it amplifies a genuine perturbation — a numerical artifact and a real initial-condition difference are indistinguishable to the dynamics.
You can see this failure mode directly. Push the Speed control to maximum, which enlarges dt, and watch the pendulum gain amplitude it should not have. With damping at 0 the system is conservative and total energy must be constant; if the swing grows, that energy came from the integrator, not the physics.
g.The simulation runs entirely in your browser on an HTML canvas — nothing is computed on a server, and the source is the same code shown in the playground.
No. It is fully deterministic — the same initial conditions and the same arithmetic produce the same motion every time. Chaos is not randomness; it is the exponential amplification of arbitrarily small differences in a deterministic system. That is why the ghost, which differs by 0.0001 radians, ends up somewhere completely different despite obeying identical equations.
Because their initial conditions are not identical. One starts 0.0001 radians further along. The nonlinear coupling term amplifies that gap roughly exponentially until it reaches the scale of the system, at which point the trajectories are unrelated.
Not in this sense. An undriven single pendulum is periodic — predictable indefinitely, and at small amplitude it reduces to simple harmonic motion. Adding the second arm introduces the nonlinear coupling that produces chaos. A driven, damped single pendulum can become chaotic, but that requires an external forcing term this system does not have.
They are the standard Lagrangian solution for a planar double pendulum with point masses at the ends of massless rigid rods. The idealisations are in the model — no air resistance unless you add damping, no friction at the pivots, rods of zero mass, motion confined to a plane — not in the solution of it.
Numerical error. Raising the speed enlarges the integration step, and a chaotic system amplifies integration error as readily as any other perturbation. With damping at 0 the true system conserves energy, so visible amplitude growth is a sign that the step has become too large to be trusted.
The rate at which nearby trajectories separate. A positive largest Lyapunov exponent is the formal criterion for chaos, and its reciprocal gives a rough horizon beyond which prediction is useless. The visible gap between the white and pink traces is that exponent made concrete.
Yes. It is free, requires no account, and runs client-side, so it works on a classroom projector or a student laptop without installation. The equations and integration method above are the ones the simulation actually uses, so the demonstration and the derivation match.
Two related simulations on the site: Conway’s Game of Life, where complex structure emerges from four rules on a grid, and the JavaScript animation playground, which contains this pendulum alongside boids flocking and other physics demos with their source visible and editable.
Nothing in this simulation is random. It integrates the equations of motion each frame, and identical starting conditions always produce identical motion. What makes a double pendulum chaotic is not randomness but sensitivity: differences in the starting state grow exponentially rather than staying proportional.
The ghost pendulum makes this concrete. It begins one ten-thousandth of a radian from the main one, a difference far too small to see. The two move as a single pendulum for several seconds, separate slightly, and are then doing entirely unrelated things. No better measurement of the starting angle would fix this - it would only postpone the divergence.
This is the same property that limits weather forecasting. The equations are known; the starting conditions can never be measured precisely enough.
Masses and lengths change the physics rather than the appearance. A heavy lower bob on a long lower arm stores more energy in the second segment and produces wilder motion.
Gravity scales the whole system's speed. Lower it towards lunar values and the same starting position unfolds slowly enough to follow by eye.
Damping is the one control that removes the chaos. At zero, energy is conserved and the motion never settles. Raise it and the pendulum loses energy until it drops into a predictable swing and finally stops.
A real simulation. It integrates the Lagrangian equations of motion for a double pendulum each frame, so masses, lengths, gravity and damping all change the behaviour the way they would physically.
It starts one ten-thousandth of a radian away from the main pendulum and is otherwise identical. The two track each other for a few seconds, then diverge completely. That is sensitive dependence on initial conditions, shown rather than asserted.
Because it is a nonlinear system with enough freedom for tiny differences to grow exponentially. A single pendulum is predictable indefinitely. Adding a second segment makes long-term prediction impossible in practice, even though the equations are completely deterministic.
Yes. A heavy lower mass on a long lower arm produces wilder motion, and raising damping settles the system into a predictable swing. Setting damping to zero conserves energy and the motion never settles.
Entirely. Nothing random is involved. The same starting conditions always produce the same motion; it is the sensitivity to those conditions, not randomness, that makes it unpredictable.