obOB STUDIO
← Back to blog
Physics

The Three-Body Problem, Explained by Watching Mine Fail

7 min readcosmic-gravity-sandbox

the setup

Two objects under gravity is a solved problem. Kepler and Newton handed us equations that will tell you where two bodies are at any point in the future or past, exactly, forever. It's why we can predict an eclipse to the second, decades out.

Add a third body and this doesn't get harder. It stops existing.

Poincaré proved in the 1880s that no general closed-form solution exists for three or more bodies. Not "we haven't found it". It isn't there. He was working on a prize problem set for the King of Sweden's birthday, which I think about a lot, because "happy birthday, I've proved this is impossible" is a bold gift.

what "chaotic" actually means

Chaos gets used loosely and it has a precise meaning here: sensitive dependence on initial conditions. Change the starting setup by a rounding error and the outcomes diverge completely.

It doesn't mean random. A three-body system is entirely deterministic. Run the same starting numbers twice and you get the same answer twice. It's just that the slightest difference in those numbers, far below anything you could measure in real life, leads somewhere else entirely.

That's the uncomfortable bit. You can have a system that is perfectly lawful and completely unpredictable at the same time, and those two things turn out not to be opposites at all.

the famous exception

Here's what makes this genuinely beautiful. Even though there's no general solution, specific exact solutions do exist. Lagrange found some in the 1700s. And in 1993 Cris Moore found (and in 2000 Chenciner and Montgomery proved stable) the figure-eight orbit: three equal masses chasing each other around a figure-eight path, forever, never colliding.

It's a genuinely lovely thing. Three objects, one loop, endlessly repeating. When I built my sandbox I very much wanted a button for it.

mine doesn't work

So I built the button. Three equal 3000-mass bodies, sat at x = −200, 0 and +200, with velocities I picked by eye and adjusted until it looked promising.

It is not the figure-eight orbit. It's three bodies having an argument.

The real solution needs exact initial conditions. Specific positions and specific velocity ratios, derived rather than guessed. Mine were guessed. And the whole point of a chaotic system is that guessed-close is not close at all.

I did get one part right, and it's the part that makes the failure legible. The momentum cancels:

const v = 2.5;
bodies.push(new Body(-200, 0,  v,    v,    m, 15, '#f783ac'));
bodies.push(new Body( 200, 0,  v,    v,    m, 15, '#4dabf7'));
bodies.push(new Body(   0, 0, -2*v, -2*v,  m, 15, '#ffe066'));

Two bodies going one way at speed v, one going the other way at 2v. It sums to zero, so the system as a whole isn't drifting anywhere. The centre-of-mass readout sits at (0, 0) and stays there no matter how violently things unfold inside it. Which is a nice demonstration in itself: momentum is conserved even when nothing else about your plan survives.

Run it forward and what happens is textbook three-body behaviour. Two of them capture each other into a tight pair, and the third gets slung out the far side and leaves. That's the single most common outcome for three gravitating bodies. A binary plus an ejection. The universe's preferred way of solving a three-body problem is to fire one of them into the distance until it's a two-body problem again.

i left it broken

I thought about fixing it. Looking up the proper Chenciner-Montgomery initial conditions is not hard.

I haven't, and the reason isn't laziness. Well, not only. Watching an orbit fail genuinely teaches more than being handed one that works. If the button did what the label promised, you'd watch a pretty shape for ten seconds and learn nothing about why it's remarkable. Watching it collapse into a binary and an ejection, every time, from conditions that look perfectly symmetrical and reasonable, tells you exactly how narrow that solution is.

The label on the button is a lie. The thing the button teaches is true. I've made my peace with it, and it's written on the project page too, so nobody's being fooled.

why everyone's talking about this

The three-body problem has had a cultural moment thanks to Liu Cixin's novel and the adaptations, where a planet in a chaotic three-star system suffers eras of unpredictable catastrophe.

The physics there is real, and slightly more real than the story needs. A planet in a genuinely chaotic three-star system wouldn't just get unpredictable weather. It would most likely get ejected, or dropped into a star, on a timescale far shorter than a civilisation. Stable configurations exist but they're rare and fussy. The book's setup is the sensible dramatic version of something that in practice tends to resolve itself rather abruptly.

go and break one yourself

The gravity sandbox has the figure-eight button, and I'd encourage you to press it and watch it not work. Then place a third star by hand somewhere near two orbiting ones and see how long it takes before somebody leaves.

The mechanics underneath are in how to simulate gravity in JavaScript, and if you want the wider context, what is an n-body simulation starts from the beginning.

ob

Written by Oliver

I build browser games and simulations on my own, everything here runs in a tab, with no installer and no account. The biggest is Oliver's Racers: procedural circuits in Godot 4, online multiplayer relayed by a Raspberry Pi in my room, and an Android build. Almost nothing here is imported artwork; the cars, trees and grandstands are built out of boxes and cylinders in code at load time.

More about me · See the projects