Three-Body Simulator

2026-10-13·
XIETU
XIETU
· 7 min read · 阅读量 次

m1 Specific Energy Bound
E₁ = --
½|v|² + U/m
m2 Specific Energy Bound
E₂ = --
½|v|² + U/m
m3 Specific Energy Bound
E₃ = --
½|v|² + U/m
1.0×
Center (0.00, 0.00)
t = 0.00
0.005
⚙ Initial Conditions Position, velocity, mass (dimensionless units)
Body 1
m₁ = mass; x₁,y₁ = position; vx₁,vy₁ = velocity
Body 2
m₂ = mass; x₂,y₂ = position; vx₂,vy₂ = velocity
Body 3
m₃ = mass; x₃,y₃ = position; vx₃,vy₃ = velocity
m1 m2 m3 ✧ m1×m2 ✧ m2×m3 ✧ m1×m3 ★ Strict Concurrence ⚠ Escape
Computing…

🌌 Three-Body Problem Handbook

From Initial Values to Chaos · From Concurrence to Escape

📌 1. Initial Values

In the 2D three-body problem, each body has 4 degrees of freedom: position (x, y) and velocity (vx, vy). Three bodies give 12 initial values, plus 3 masses = 15 parameters.

1.1 Position (x, y)

Coordinates in the 2D plane. In this simulation, 1 unit ≈ 200 pixels on the canvas.

  • Center of mass: weighted average of positions. If Σ mᵢ·rᵢ = 0, the center of mass is at the origin.
  • Figure-8 solution: center of mass at origin, so the system as a whole does not translate.

1.2 Velocity (vx, vy)

Velocity components in x and y. Affects trajectory shape and total energy.

  • Zero total momentum: Σ mᵢ·vᵢ = 0 makes the center of mass stationary — a necessary condition for the figure-8 solution.
  • Zero total angular momentum: Σ mᵢ·(rᵢ × vᵢ) = 0 prevents overall rotation.

1.3 Mass (m)

The gravitational "charge" of a body. Larger mass = stronger gravity.

  • Equal masses (1:1:1): prerequisite for the figure-8 and Lagrange solutions.
  • Extreme mass ratio (e.g., 10:1:1): approximates a "binary + planet" system, more stable.
  • Normalize total mass = 3: rescale all masses proportionally so their sum is 3.
💡 Physics of the Figure-8 Solution
Discovered by Moore (1993) and Chenciner-Montgomery (2000). Three equal-mass bodies chase each other along a single figure-8 curve, with period T ≈ 6.325.

⚛ 2. Physics

2.1 Specific Energy

Energy per unit mass of each body — the key indicator for escape:

Eᵢ = ½|vᵢ|² + Uᵢ/mᵢ = ½|vᵢ|² − G·Σⱼ≠ᵢ (mⱼ / rᵢⱼ)
Note: the simulation introduces a softening parameter SOFTENING = 0.02. In practice rᵢⱼ = √(Δx² + Δy² + SOFTENING²) to avoid numerical singularities at close encounters.
  • Eᵢ < 0: Bound. The body lacks enough energy to escape.
  • Eᵢ > 0: Escaped. The body's speed exceeds the local escape velocity and it flies to infinity.
  • Eᵢ = 0: Critical. The body just reaches infinity with zero speed.

2.2 Total Force

Body i experiences the vector sum of gravitational pulls from the other two:

Fᵢ = Σⱼ≠ᵢ G·mᵢ·mⱼ·(rⱼ − rᵢ) / |rⱼ − rᵢ|³

2.3 Gravity Field and Equipotential Lines

The three-body gravitational potential is:

Φ_total = −G·(m₁/r₁ + m₂/r₂ + m₃/r₃)

Equipotential lines (Gravity Field toggle) are extracted via Marching Squares. Deeper potential wells produce denser, brighter contours.

🪐 3. Known Periodic Solutions

3.1 Lagrange Equilateral Solution (1772)

Three bodies always form an equilateral triangle rotating about their common center of mass.

  • Stability: depends on mass ratio. For equal masses it is unstable!
  • Routh (1875) showed stability requires β < √2. For equal masses β = √3 ≈ 1.732 > 1.414, hence unstable.

3.2 Euler Collinear Solution (1767)

Three bodies always remain collinear, rotating about the center of mass.

  • Unstable: collinearity is a "needle-tip balance" — any perpendicular offset creates a transverse force that grows.

3.3 Figure-8 Solution (2000)

Three equal-mass bodies chase each other along the same figure-8 curve.

  • Unstable, but the instability rate is slower than the previous two (characteristic exponent λ ≈ 0.01~0.05).

✧ 4. Concurrence Theorem for Three Gravity Lines

4.1 Definition

The reverse extension of each body's net force direction is called its "gravity line." Do the three lines meet at a single point?

4.2 Mathematical Result

In general, the three gravity lines do NOT concur.
They do so only when:
[d₁₂, F₂]·[F₁, F₃] = [d₁₃, F₃]·[F₁, F₂]

4.3 When Do They Concur?

  • Collinear configuration: the three lines coincide (degenerate concurrence).
  • Lagrange equilateral solution: all three lines pass through the center of mass.
  • Figure-8 at specific phases: discrete concurrence 2–3 times per period.
⚠ About "Approximate Concurrence"
Because F₁ + F₂ + F₃ = 0 (net force is zero), the three gravity lines statistically point toward some interior region. The three intersections are usually close together, but strict concurrence occurs only in the cases above.

🚀 5. Key Factors for Escape

5.1 Core Mechanism: Energy Redistribution

The fundamental cause of escape in a three-body system is energy redistribution via gravitational interaction:

During a close encounter, one body loses energy and is "slowed," while the other gains energy and is "kicked out."

Total energy is conserved, but individual energies are not — gravitational work transfers energy among bodies.

5.2 Three Escape Mechanisms

MechanismDescriptionTimescale
Gravitational SlingshotA binary transfers energy to a single star, which escapesSingle encounter
Chaotic AmplificationTiny initial differences amplify exponentially, randomly falling into escape regionsSeveral characteristic times
Resonance PumpingPeriodic resonances accumulate energyMultiple encounters
Numerical Error (non-physical)False escape (caused by accumulated integration error, not real physics)Depends on precision

5.3 Ultimate Fate

Three-Body → Binary + Escaped Single Star

For the vast majority of initial conditions, the system eventually disintegrates into a binary plus one escaped star.

5.4 Escape Detection in This Simulation

The specific-energy panel shows Eᵢ in real time:

  • Bound: green energy bar, labeled "Bound"
  • Escaped: card turns red and blinks; the body turns red with a pulsing halo and "⚠ Escape" text
  • Hysteresis: E must remain above threshold for several frames before escape is confirmed, avoiding jitter during close encounters

🌪 6. Chaos and Stability

6.1 What Does "Unstable" Mean?

Stability of a dynamical system is quantified by the Lyapunov exponent λ:

  • λ < 0: Stable. Perturbations decay.
  • λ = 0: Neutral. Perturbations persist.
  • λ > 0: Unstable. Perturbations grow exponentially: δ(t) ~ δ(0)·e^(λt).

6.2 The Chaotic Nature of the Three-Body Problem

All known periodic solutions of the equal-mass three-body problem are Lyapunov-unstable.
This is the fundamental reason the three-body problem is called "chaotic."

6.3 Stability Comparison

SolutionLyapunov exponentVisual instability time
Euler collinearλ ≈ 0.1~0.5Disintegrates within a few periods
Lagrange equilateralλ ≈ 0.1~0.3Disintegrates within tens of periods
Figure-8λ ≈ 0.01~0.05Disintegrates after hundreds of periods

🎮 7. Usage Guide

7.1 Canvas Controls

  • Drag: pan the view
  • Scroll / Pinch: zoom
  • Auto Fit: adjusts the view to all three bodies (smooth follow, exits when you interact)
  • Reset View: back to initial zoom and center

7.2 Display Toggles

ToggleShows
Gravity FieldPotential-well halos + equipotential lines (computed in physical coordinates)
Body TrailsRecent trajectories (solid lines, no glow)
Body History TrailsFull trajectory history (dashed lines, persistent)
Intersection TrailsRecent intersection paths (yellow solid lines)
Intersection HistoryFull intersection history (yellow dashed lines, persistent)
Intersection MarkersIntersection dots + strict-concurrence ★
Force Arrows & Gravity LinesNet force vectors + forward extension dashes for each body

7.3 Initial Values

  • Mass (m₁, m₂, m₃): golden input fields, change the gravitational strength
  • Position (x, y): body coordinates
  • Velocity (vx, vy): velocity components
  • Presets: Figure-8, Lagrange Equilateral, Euler Collinear, Random Perturbation
  • Normalize Total Mass: rescale masses so their sum = 3
  • Apply & Reset: restart with the new initial conditions

7.4 Observation Tips

Watching an escape:
1. Select the "Lagrange Equilateral" preset
2. Watch the specific-energy panel: all E values start negative
3. At the instability moment, one E jumps positive (hysteresis prevents false positives)
4. That body turns red on the canvas with a pulsing ring
5. Use "Auto Fit" to zoom out and track the escaping body
Experiencing chaos:
1. Click the "Random Perturbation" preset
2. Each click produces slightly different initial values
3. Watch how completely different the trajectories become — that's sensitivity to initial conditions
🌌 Three-Body Problem · A Symphony of Chaos and Order
Φ_total = −G·Σ mᵢ/rᵢ · F = m·a · E = ½|v|² + U

XIETU
Authors
Architect with 20+ years experience
Instead of lamenting the difficult road, it’s better to start the journey.