N-Body Gravitational Simulation
Every mass pulls every other mass. Two bodies produce elegant ellipses. Three bodies produce chaos. Click to place bodies, drag to set velocity, scroll to adjust mass, and watch the gravitational dance unfold.
The N-body problem
Newton solved the two-body problem completely: two masses orbiting their common center of mass trace eternal ellipses. But add a third body and the system becomes chaotic — no general closed-form solution exists. Henri Poincaré proved this in 1889, launching the modern study of dynamical systems.
This simulation uses Velocity Verlet integration with softened gravity (F = Gm₁m₂ / (r² + ε²)) to prevent singularities when bodies pass close together. The energy tracker shows how well conservation holds — numerical integration always drifts, but symplectic integrators like Verlet keep the drift bounded.