Three Body

Math · chapter 11 of 13

So you step it

Nobody solves the three-body problem. Everybody steps it: work out the pulls, move everything a little, do it again. The skill is in knowing when your own arithmetic has started lying.

Here is the whole method, and it is old enough that Euler used it by hand. Where is everything? What is the pull on each? Move each one a little way at its current speed, change each speed a little by its current pull. Repeat a million times.

Done the obvious way — move, then change speed, with the same step — it is called Euler's method and it leaks. Energy climbs, orbits spiral outward, and nothing warns you. The fix is almost free: change the speed by half a step, move a whole step, change the speed by the other half. That is leapfrog, also called Verlet, and it belongs to a family called symplectic methods whose defining virtue is that they do not leak. The energy wobbles up and down with each orbit and comes back. Over a million orbits it is still wobbling around the same value.

That wobble is the audit. Total energy is a quantity that cannot change, so watching what your computer does to it tells you what your computer is doing to everything else. Every demo on this site prints it, and the demo on this page runs both methods side by side so the leak is visible.

Close passes are where stepping fails. When two bodies nearly touch, the pull goes up like the square of the closing distance and a step that was fine a second ago now throws a body across the screen. Two ways out. Softening — add a small constant under the square root, which rounds off the bottom of the well and is a lie you have chosen knowingly. Or regularisation — change variables so a collision stretches out into something smooth, which Levi-Civita did in 1903 and which is what serious codes use.

Burrau's problem from the chaos chapter is the worked example of all of this. At a fixed step it comes out with the energy wrong by a factor of about a thousand and the wrong body thrown out. Give it a step taken from the closest pair and the energy error drops to about a millionth and the lightest body leaves, which is the answer Szebehely and Peters got in 1967 with a change of variables. Same equations, same start, three different endings depending only on how the arithmetic was done.

Then there is the deeper problem the chaos chapter set up. A computer carries about sixteen digits. In a chaotic triple, the error in the sixteenth digit doubles its way up to the first one, and after a few dozen Lyapunov times the trajectory on the screen is a trajectory, not the trajectory. Boekholt and Portegies Zwart put a number on it in 2015 by running the same systems in arbitrary precision: a large share of chaotic triples are not reproducible at ordinary double precision. Their answer was Brutus, a code that carries as many digits as needed and slows down to whatever extent that takes.

So a picture of a three-body orbit is a claim about a calculation. The version of the claim worth printing comes with the method, the step size, and what the energy did.

Euler:  vv + a hrr + v h

Reading it: Change the speed by the pull times the step, then move at the new speed. One line, and it leaks energy.

Error per step proportional to h². The leak is systematic, not random, which is what makes it dangerous: the orbit drifts one way forever.

Leapfrog:  vv + a h2rr + vhaa(r),  vv + a h2

Reading it: Half a kick, a full drift, then the other half kick with the new pull. Four lines instead of two, and the energy stays put.

Symplectic and time-reversible: run it backwards and you land on the start. This is what runs the demos on this site, in the browser, and tools/physics.py, in Python.

hrminvmax × 1100

Reading it: Your step has to be a small fraction of the time the closest pair takes to cross its own separation.

A rule of thumb, not a theorem. Codes that mean business compute a step from the current configuration every time round, rather than fixing one in advance.

Try it. On the demo, put the step size up until the two curves part, then read the energy drift on each. Euler goes one way and keeps going; leapfrog wobbles. That difference is a hundred years of numerical analysis in one picture.

This one runs in the browser, with JavaScript on. The words above it stand on their own.

10-1610-1410-1210-1010-810-610-410-2100Eulerleapfrog0102030405060energy error, as a fraction

Both steppers on the figure eight, same step size, energy error against time. After sixty time units the leapfrog is out by 5.9e-07 and the obvious method by 2.9e-01 — and the second is still climbing.

Sources

← Crashes, and the kind of trouble that is not a crash What usually happens →