Advanced N-Body Simulator Calculator

Explore orbital dynamics from simple to chaotic systems. Compare Euler, Leapfrog, and RK4 side-by-side here. Track energy drift, momentum conservation, and close encounters live.

Inputs

Use dimensionless units, or set real units consistently.
Smaller dt improves accuracy but increases runtime.
Capped at 20000 to keep output manageable.
Leapfrog is often best for long-term orbital stability.
Avoids singular forces during close approaches.
Larger values reduce CSV size.
CSV always includes all sampled rows.

Bodies

Enter masses, positions, and velocities. Up to 12 bodies are supported.
# m x y z vx vy vz
0
1
2
Clear
If the system explodes numerically, reduce dt, increase ε, or choose Leapfrog.

Formula used

Each body experiences the vector acceleration:

aᵢ = Σⱼ≠ᵢ G mⱼ (rⱼ − rᵢ) / (|rⱼ − rᵢ|² + ε²)^{3/2}

  • ε is the softening length to prevent singular forces.
  • Total energy E = K + U with K = Σ ½ mᵢ|vᵢ|².
  • Potential U = −Σ_{i<j} G mᵢ mⱼ / √(|rᵢ−rⱼ|²+ε²).
  • Momentum P = Σ mᵢ vᵢ, angular momentum L = Σ rᵢ × (mᵢ vᵢ).

How to use this calculator

  1. Choose consistent units for G, mass, distance, and time.
  2. Pick an integrator: Leapfrog for long runs, RK4 for precision.
  3. Set dt small enough to resolve the fastest orbit.
  4. Use ε to stabilize near-collisions and tight passes.
  5. Enter bodies, then press Simulate to view results above.
  6. Download CSV for full trajectories, PDF for compact summaries.

Example data table

You can load these values instantly using “Load example”.
# m x y z vx vy vz
01-0.970004360.2430875300.4662036850.432365730
110.97000436-0.2430875300.4662036850.432365730
21000-0.93240737-0.864731460
Note: This simulator uses an O(N²) force loop. For large-N astrophysical runs, consider Barnes–Hut or fast multipole methods.

Related Calculators

markov chain monte carlometropolis monte carlokinetic monte carlodiscrete element methodconjugate heat transferquantum monte carlomultibody dynamicsstiff ode solveradaptive mesh refinementparticle in cell

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.