About the N-Body Simulator
What is the Three-Body Problem?
The three-body problem is one of the most famous challenges in classical physics and celestial mechanics. It asks: given the initial positions, masses, and velocities of three bodies in space, can we predict their future motion under mutual gravitational attraction?
Unlike the two-body problem (which has an exact analytical solution), the three-body problem has no general closed-form solution. This makes numerical simulation the primary tool for studying these complex gravitational systems.
N-Body Gravitational Simulation
This simulator uses Newton's law of universal gravitation to model the gravitational forces between every pair of bodies:
F = G × m₁ × m₂ / (r² + ε²)
Each body experiences the sum of all pairwise gravitational forces from every other body. For N bodies, this requires calculating N(N-1)/2 force pairs each timestep. The ε² term is a softening parameter that prevents numerical singularities when bodies pass very close together.
The simulation supports multiple integration methods. By default, it uses the Velocity Verlet integration method, a symplectic integrator that provides superior energy conservation compared to simpler methods like Euler integration. This makes it ideal for long-term orbital mechanics simulations.
Users can switch to the 4th-order Runge-Kutta (RK4) method in the Advanced Settings, which offers higher accuracy per timestep at the cost of more computational overhead. However, unlike Verlet, RK4 is not symplectic and can experience energy drift over long simulation times, making it better suited for short to medium duration simulations where high local accuracy is more important than long-term energy conservation.
Preset Configurations
The simulator includes several famous periodic three-body orbits discovered through numerical searches:
- Figure-8 choreography: Discovered by Cris Moore in 1993, where three equal masses chase each other along a figure-eight shaped path
- Lagrange triangular configuration: Equilateral triangle configuration with circular orbits.
- Butterfly, Broucke, Hénon, and Yarn: Periodic orbits from the Šuvakov-Dmitrašinović database of three-body choreographies, discovered through systematic numerical exploration of initial conditions
Features & Applications
- Real-time Physics: Experience gravitational dynamics in 3D with interactive controls
- Multiple Integration Methods: Choose between Velocity Verlet (energy-conserving) and RK4 (high accuracy).
- Exploration Platform: Experiment with different initial conditions and masses
- Timeline Playback: Scrub through simulation history to analyze orbital behavior
How to Use
Getting Started: Use the preset configurations (Figure-8 or Lagrange) to see stable three-body orbits, or generate random initial conditions to explore chaotic dynamics.
Controls: Adjust body masses, simulation speed, and physics parameters. Use the timeline to review and analyze orbital patterns. Drag bodies while paused to create custom configurations.
Sharing: Click "Share Configuration" to generate a URL that preserves your exact simulation initial state.
Technical Details
Built with Three.js for WebGL-accelerated 3D graphics and modern JavaScript. The physics engine implements N-body gravitational calculations with a configurable softening parameter to prevent numerical singularities during close encounters.
The simulator tracks up to 10,000 frames of history, allowing you to review and analyze the evolution of complex orbital systems. All simulations are deterministic and reproducible.