All three panels start from the exact same initial positions, velocities and masses and feel the same real pairwise gravity, F = G·m₁·m₂ / (r² + ε²) (ε is a small softening term so close encounters don't blow up numerically). Only the integrator — the rule used to advance position and velocity each sub-step — differs:
- Forward (explicit) Euler — advances position with the old velocity, then updates velocity:
x' = x + v·dt; v' = v + a·dt. It is not symplectic, so it systematically pumps energy into the system — orbits visibly spiral outward, faster as Δt grows.
- Symplectic (semi-implicit) Euler — updates velocity first, then advances position with the new velocity:
v' = v + a·dt; x' = x + v'·dt. One line of code different from forward Euler, but it conserves a shadow Hamiltonian, so energy oscillates in a bounded band instead of drifting away — the same trick used by the 3D N-body original.
- Velocity Verlet (leapfrog) — second-order accurate and also symplectic:
x' = x + v·dt + ½a·dt², recompute acceleration at the new position, then v' = v + ½(a+a')·dt. It holds the tightest energy band of the three, especially at larger Δt.
F = G·m1·m2 / (r² + ε²)
E = Σ ½mᵢvᵢ² − Σ_{i<j} G·mᵢmⱼ / √(rᵢⱼ² + ε²)
Push the Δt slider up and watch the drift readouts: forward Euler's percentage grows almost immediately, symplectic Euler's oscillates but stays roughly flat on average, and Verlet's stays smallest of all — a direct, visible demonstration of why real orbital-mechanics codes use symplectic integrators instead of naive Euler.