Loading the engineShared by all simulations, so the next one opens instantly.
The physics

Three bodies under gravity have no general closed-form solution, and most starting conditions end in chaos, with one body thrown out sooner or later. This page collects starts that behave differently: a periodic orbit, an exact solution that does not survive, and a hierarchical system that holds together. All use G=1 and unit masses unless noted.

What you see

Three bodies, labeled Body A, B and C and drawn in red, teal and yellow, leave pale trails behind them. Arrows on a grid show the gravitational field; switch them off with Force field. Each preset sets its own time step, softening and zoom, and every start is shifted into the center-of-mass frame, with zero total momentum, so the center of mass stays at the center of the view. Without a preset, the page starts with the figure-eight.

Governing equation

𝐫¨i=G∑j≠imj(𝐫j−𝐫i)(|𝐫j−𝐫i|2+ε2)3/2

The softening length ε removes the singularity at zero distance. Energy, momentum and angular momentum are conserved, and the default leapfrog integrator keeps the energy error bounded.

Presets

Figure-8: the choreography that Cristopher Moore found numerically in 1993 and Alain Chenciner and Richard Montgomery proved to exist in 2000. Bodies A and B start at (−0.97000,0.24309) and (0.97000,−0.24309), both with velocity (0.46620,0.43237); Body C starts at the origin with (−0.93241,−0.86473), so the total momentum is zero. The three masses then chase each other around one figure-eight curve, a third of a period apart, with period T≈6.33. The orbit is linearly stable and keeps its shape over many periods.

Lagrange triangle: three equal masses at the corners of an equilateral triangle of side 3, each moving at speed 3−1/4≈0.7598 so that the triangle rotates rigidly. Lagrange showed in 1772 that this is an exact solution for any three masses. Gascheau found in 1843 that it is linearly stable only if 27(m1m2+m2m3+m3m1)<(m1+m2+m3)2, which requires one body to dominate; for equal masses the left side is 81 and the right side 9. The rounding of the starting values is enough to break it: within two or three turns the triangle distorts, and the bodies fall into a chaotic exchange.

Figure-8, chaotic: the figure-eight start with Body C made 50 percent heavier (mass 1.5). Within about one period a close encounter flings the bodies apart. The view is zoomed out to 3 units from the center.

The two chaotic presets, Lagrange triangle and Figure-8, chaotic, run with dt=0.001, 32 substeps per frame and ε=0.1. Their bodies pass very close to each other, and with a coarser step or a smaller softening the integrator cannot follow those passes: the total energy jumps at each one, and bodies fly apart on energy the simulation made up. At these settings the energy stays within half a percent, so the exchanges and ejections are the system’s own.

Hierarchical triple: a tight binary, two unit masses 0.4 apart on a circular orbit, with a third unit mass starting 3 units away. The outer body moves on an eccentric orbit while the inner pair goes round about ten times per outer orbit, and the wide separation keeps both orbits intact. Stable triple stars in nature are built like this.

Perturbed figure-8 (stable): the figure-eight with Body A moved 0.001 to the right. In a chaotic orbit such an offset would grow exponentially, |δ𝐫(t)|≈|δ𝐫0|eλt with a positive Lyapunov exponent λ. The figure-eight is linearly stable, so the offset stays small and the curve only wobbles around the original; compare Figure-8, chaotic, where the disturbance is large.

Parameters

Time step dt: the integration step, 0.0005 to 0.04 (default 0.005); the presets use 0.001 to 0.005. Steps per frame (1 to 32, default 8) is the number of steps per drawn frame.

Integrator: leapfrog (velocity Verlet) by default; yoshida4, rk4, rk2 and euler are the alternatives. Close encounters need small steps with any of them.

Softening ε: default 10−4; Hierarchical triple uses 10−2, Lagrange triangle and Figure-8, chaotic 0.1.

The other controls change only the drawing: trails, labels, the center-of-mass marker, a view locked to the center of mass, velocity arrows and the field overlays.