Double Pendulum Simulator

Watch deterministic chaos in a double pendulum solved from the real Lagrangian equations, with a ghost copy started 0.0001 radians away.

Double Pendulum

Live controls

1
1
1
1
9.81
0
1
500
1

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.

Pick an animation

All 40 animations →

Canvas 2D
three.js
WebGL
CSS / DOM
Advertisement

An Interactive Double Pendulum Built on the Real Equations of Motion

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.

The Equations

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.

Watching Chaos Happen: The Ghost Pendulum

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.

Integration and Why the Time Step Is Small

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.

Things Worth Trying

  • Damping at 0 versus 0.05. Zero damping is a conservative system that never settles — the trace fills the reachable region indefinitely. Nudge damping to 0.05 and the chaos collapses within seconds into a boring, decaying single-arm swing. Chaos here is fragile; it needs energy to sustain it.
  • A heavy lower bob. Set the lower mass to 8 against a light upper arm. The lower bob’s inertia whips the upper arm right over the pivot, producing full rotations rather than swings.
  • Change gravity. Low gravity slows everything and lengthens the time before the ghost separates; high gravity accelerates the divergence. The qualitative behaviour is unchanged — chaos is not a consequence of the value of g.
  • Small initial angles. Release from near-vertical and the motion looks almost periodic, because at small amplitude the system is close to two coupled linear oscillators. Increase the release angle and the nonlinear coupling takes over. Chaos in this system is an amplitude phenomenon, not an inevitability.
  • Long trails. Raise the trace length and the path of the lower tip fills a bounded region without ever repeating — the visual signature of a trajectory that is confined but not periodic.
  • Click to re-drop. Clicking anywhere restarts the pendulum from that angle, which is the fastest way to compare how different starting configurations behave.

How to Use It

  1. Let the default run first. Both arms start at 135° with the ghost enabled, which is the clearest demonstration of divergence.
  2. Watch the two traces for the first thirty seconds without touching anything, and note roughly when they visibly separate.
  3. Change one control at a time. Adjustments apply on the next frame without a restart, so you can perturb a running system and watch it respond.
  4. Turn the ghost off when you want a clean trace of a single trajectory.
  5. Pan and zoom to follow the lower bob when a heavy configuration sends it outside the default view.

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.

Frequently Asked Questions

Is the double pendulum random?

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.

Why do the two pendulums separate if the physics is identical?

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.

Is a single pendulum chaotic too?

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.

Are these the real equations or an approximation?

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.

Why does the pendulum gain energy at high speed settings?

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.

What is a Lyapunov exponent?

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.

Can I use this for a class or a project?

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.

Where else can I see emergent behaviour like this?

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.

Deterministic but unpredictable

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.

What the controls actually change

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.

Frequently Asked Questions

Is this a real simulation or an animation?+

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.

What is the ghost pendulum for?+

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.

Why is a double pendulum chaotic?+

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.

Does changing the masses and lengths matter?+

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.

Is it deterministic?+

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.

This tool is provided for informational and educational purposes only. All processing happens in your browser — no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results.