N-Body Gravitational Interaction Estimator

Compute gravitational forces, accelerations, and potential energy for 2 or 3 bodies using Newton's universal law of gravitation.

⚛️ N-Body Gravitational Interaction Estimator
Body 1 Mass
Body 2 Mass
Separation r₁₂
Body 1 Mass (leftmost)
Body 2 Mass (middle)
Body 3 Mass (rightmost)
Separation r₁₂ (Body 1 to Body 2)
Separation r₂₃ (Body 2 to Body 3)
Gravitational Force F₁₂
Acceleration of Body 1
Acceleration of Body 2
Gravitational Potential Energy
Escape vel. from B2 gravity at r
Escape vel. from B1 gravity at r
Force F₁₂ (Body 1 – Body 2)
Force F₂₃ (Body 2 – Body 3)
Force F₁₃ (Body 1 – Body 3)
Net Acceleration Body 1
Net Acceleration Body 2
Net Acceleration Body 3
Total Gravitational Potential Energy

⚛️ What is the N-Body Gravitational Interaction Estimator?

Gravitational interaction between two or more bodies is governed by Newton's law of universal gravitation: every mass attracts every other mass with a force proportional to the product of the masses and inversely proportional to the square of the distance between them. This estimator computes the instantaneous gravitational forces, accelerations, and potential energy for systems of 2 or 3 bodies, giving you numerical values at a snapshot in time rather than a full orbital trajectory.

In the two-body mode, you get the mutual gravitational force, the acceleration each body experiences, the gravitational potential energy of the pair, and the escape velocity from each body's gravitational field at the given separation. This is directly applicable to planet-star systems, binary stars, satellite-planet pairs, and any two-mass problem in celestial mechanics. Classic examples include the Earth-Sun pair (force ~3.54 × 1022 N) and the Earth-Moon pair (force ~1.98 × 1020 N).

The three-body collinear mode extends the calculation to three bodies arranged in a straight line. It computes all three pairwise forces (F12, F23, F13), the net acceleration on each body from the combined pull of the other two, and the total gravitational potential energy of the system. This configuration approximates many real astrophysical situations, including the Sun-planet-moon system, a star-planet-companion arrangement, and tidal perturbation problems.

The tool uses G = 6.674 × 10−11 m3 kg−1 s−2 (CODATA 2018 value) and accepts masses in Solar masses, Jupiter masses, Earth masses, and kilograms, and distances in AU, km, m, light-years, and parsecs. Results are displayed in SI units in scientific notation.

📐 Formula

F = G × m₁ × m₂ / r²
F = gravitational force between the two bodies (N)
G = gravitational constant = 6.674 × 10−11 m³ kg−1 s−2
m₁, m₂ = masses of the two bodies (kg)
r = center-to-center separation (m)
a₁ = F / m₁  —  acceleration of Body 1 (m/s²)
a₂ = F / m₂  —  acceleration of Body 2 (m/s²)
U = −G m₁ m₂ / r  —  gravitational potential energy (J)
vesc = √(2GM/r)  —  escape velocity from mass M at distance r (m/s)
Three-body net forces: Fnet,1 = F12 + F13  |  Fnet,2 = −F12 + F23  |  Fnet,3 = −(F23 + F13)
Example: Earth (5.972 × 1024 kg) and Sun (1.989 × 1030 kg) at 1 AU (1.496 × 1011 m): F = 3.54 × 1022 N

📖 How to Use This Calculator

Steps

1
Choose the number of bodies using the tabs at the top. Select 2 Bodies for a two-body interaction or 3 Bodies (Collinear) for three bodies in a line where Body 2 is between Body 1 and Body 3.
2
Enter masses with units for each body. Use Solar masses for stars, Jupiter masses for gas giants, Earth masses for rocky planets, or kg for any other object. The dropdown converts automatically.
3
Enter the separation distance. For two bodies, enter r₁₂ between their centers. For three bodies, also enter r₂₃. Choose AU for planetary scales, km for close encounters, or m for laboratory-scale separations.
4
Click Calculate to see all results in SI scientific notation. Two-body mode shows force, both accelerations, potential energy, and escape velocities. Three-body mode shows all pairwise forces, net accelerations, and total potential energy.

💡 Example Calculations

Example 1 — Earth and Sun at 1 AU (Two-Body)

Sun (1 M☉) and Earth (1 M⊕) separated by 1 AU

1
Masses: m1 = 1.989 × 1030 kg (Sun), m2 = 5.972 × 1024 kg (Earth). Separation: r = 1.496 × 1011 m (1 AU).
2
Force: F = 6.674 × 10−11 × 1.989 × 1030 × 5.972 × 1024 / (1.496 × 1011)² = 3.542 × 1022 N.
3
Sun acceleration: a₁ = F / MSun = 1.781 × 10−8 m/s². Earth acceleration: a₂ = F / MEarth = 5.931 × 10−3 m/s².
4
Escape velocity from Sun's gravity at 1 AU: vesc = √(2GMSun/r) = 4.213 × 104 m/s (42.1 km/s). This is why solar escape requires a large velocity.
Gravitational force = 3.542 × 1022 N | Potential energy = −5.299 × 1033 J
Try this example →

Example 2 — Earth and Moon (Two-Body)

Earth (1 M⊕) and Moon (0.01230 M⊕) at 384,400 km

1
Masses: m1 = 5.972 × 1024 kg (Earth), m2 = 7.342 × 1022 kg (Moon). Separation: r = 3.844 × 108 m (384,400 km).
2
Force: F = 6.674 × 10−11 × 5.972 × 1024 × 7.342 × 1022 / (3.844 × 108)² = 1.980 × 1020 N.
3
Moon acceleration: aMoon = 1.980 × 1020 / 7.342 × 1022 = 2.697 × 10−3 m/s² toward Earth. This centripetal acceleration keeps the Moon in its orbit.
Gravitational force = 1.980 × 1020 N | Potential energy = −7.613 × 1028 J
Try this example →

Example 3 — Sun-Earth-Moon Collinear (Three-Body)

Sun (1 M☉), Earth (1 M⊕), Moon (0.01230 M⊕) in a line: r₁₂ = 1 AU, r₂₃ = 384,400 km

1
F12 (Sun-Earth) = G MSun MEarth / (1 AU)² = 3.542 × 1022 N, which dominates the system.
2
F23 (Earth-Moon) = 1.980 × 1020 N. F13 (Sun-Moon) = G MSun MMoon / r13² = 4.333 × 1020 N (Sun pulls Moon more strongly than Earth does).
3
Net Moon acceleration = (F23 + F13) / MMoon = (1.980 × 1020 + 4.333 × 1020) / 7.342 × 1022 = 8.598 × 10−3 m/s² toward Earth and Sun.
F₁₂ = 3.542 × 1022 N | F₂₃ = 1.980 × 1020 N | F₁₃ = 4.333 × 1020 N
Try this example →

❓ Frequently Asked Questions

What is the N-body gravitational interaction problem in astrophysics?+
The N-body problem asks how N point masses move under their mutual gravitational attraction. For N = 2, exact analytical solutions (Kepler orbits) exist. For N = 3 or more, no general closed-form solution exists and long-term behavior is typically chaotic. This estimator computes instantaneous forces and accelerations at a single moment in time, not orbital evolution over time.
How does gravitational force change with the distance between two bodies?+
Gravitational force follows an inverse-square law: F = Gm1m2/r². Doubling the separation reduces the force by a factor of four. Tripling it reduces the force by a factor of nine. This rapid falloff explains why the Moon's tidal influence on Earth is far stronger than the Sun's, even though the Sun is 27 million times more massive.
Why is gravitational potential energy always a negative number?+
Gravitational potential energy U = -Gm1m2/r is defined to be zero when the bodies are at infinite separation. Since gravity is attractive, energy is released as bodies approach each other, so U decreases below zero. A more negative value means the pair is more tightly gravitationally bound. To separate them completely to infinity would require supplying energy equal to |U|.
What does the escape velocity result in the two-body mode represent?+
The escape velocity is the minimum speed a test mass would need at the given separation r to escape the gravitational pull of the other body to infinity. It equals sqrt(2GM/r). For example, the escape velocity from the Sun's gravity at 1 AU is about 42.1 km/s. This is why spacecraft heading out of the solar system need enormous velocities provided by planetary gravity assists.
Why is the three-body problem considered chaotic and unpredictable?+
In a three-body gravitational system, tiny differences in initial conditions grow exponentially with time. Even a position error of one millimeter can lead to completely different orbital configurations after a few hundred orbital periods. This sensitive dependence on initial conditions (deterministic chaos) makes long-term prediction impossible without precise numerical integration, and even then errors accumulate.
How strong is the gravitational force between Earth and the Moon?+
The gravitational force between Earth (5.972 x 10^24 kg) and the Moon (7.342 x 10^22 kg) at their average separation of 384,400 km is approximately 1.98 x 10^20 N. This enormous force keeps the Moon in orbit and drives Earth's ocean tides. It gives the Moon a centripetal acceleration toward Earth of about 2.70 x 10^-3 m/s^2.
What mass units should I use for different types of astronomical objects?+
Solar masses (M_sun = 1.989 x 10^30 kg) work best for stars. Jupiter masses (1 M_Jup = 1.898 x 10^27 kg) are convenient for gas giants and brown dwarfs. Earth masses (1 M_Earth = 5.972 x 10^24 kg) suit rocky planets, super-Earths, and large moons. For comets, asteroids, or small moons, input the mass directly in kilograms.
Can this calculator predict whether an orbit will be stable?+
No. This tool gives instantaneous force and acceleration magnitudes at a single snapshot. It does not integrate the equations of motion over time, so it cannot determine orbital stability, eccentricity, or long-term behavior. For full trajectory simulation, use REBOUND, Mercury6, or similar N-body integration codes designed for orbital mechanics.
How does the mass ratio between two bodies affect their accelerations?+
Both bodies experience the same force magnitude F, but acceleration = F/m, so the lighter body accelerates much more. For the Earth-Sun pair, Earth accelerates at 5.93 x 10^-3 m/s^2 while the Sun accelerates at only 1.78 x 10^-8 m/s^2. Their acceleration ratio equals the inverse mass ratio: a_Earth/a_Sun = M_Sun/M_Earth = 333,000.
What does total gravitational potential energy mean in the three-body mode?+
The three-body mode sums all three pairwise potential energies: U_total = U_12 + U_23 + U_13, where each U_ij = -G*mi*mj/rij. This total is the energy that must be supplied to disperse all three bodies to infinite mutual separation while at rest. It does not include kinetic energy, so it is not the total mechanical energy of the dynamical system.
In the three-body collinear mode, why is the Sun-Moon gravitational force stronger than the Earth-Moon force?+
The Sun is approximately 27 million times more massive than Earth. Even though the Sun is about 390 times farther from the Moon than Earth is, the mass advantage wins the inverse-square competition: F_Sun-Moon / F_Earth-Moon = (M_Sun / M_Earth) x (r_Earth-Moon / r_Sun-Moon)^2 = 27,000,000 / (390)^2 = 2.19. The Sun's gravitational pull on the Moon is actually stronger than Earth's pull, which is why the Moon's orbit is always concave toward the Sun.

What is the N-body gravitational interaction problem in astrophysics?

The N-body problem asks how N point masses move under their mutual gravitational attraction. For N = 2, an exact analytical solution exists (Kepler orbits). For N = 3 or more, no general closed-form solution exists and the system is typically chaotic. This calculator computes the instantaneous forces and accelerations at a snapshot in time, not the full orbital evolution.

How does gravitational force change with the distance between two bodies?

Gravitational force follows an inverse-square law: F = Gm1m2/r^2. Doubling the separation reduces the force by a factor of four. Tripling it reduces the force by a factor of nine. This rapid falloff explains why the Moon's tidal effect on Earth is far stronger than the Sun's, even though the Sun is far more massive.

Why is gravitational potential energy always negative?

Gravitational potential energy U = -Gm1m2/r is defined to be zero when the bodies are at infinite separation. Because gravity is attractive, energy is released as the bodies approach each other, so U decreases below zero. A more negative U means the bodies are more tightly bound. The total mechanical energy of a bound orbit is negative.

What does escape velocity mean in the two-body results?

Escape velocity is the minimum speed a small test mass would need at the given separation to escape the gravitational pull of the larger body to infinity. It equals sqrt(2GM/r). For Earth's gravity at 1 AU from the Sun, the escape velocity from the Sun is about 42 km/s, which is why spacecraft leaving the solar system need a large velocity kick.

Why is the three-body problem considered chaotic?

In a three-body system, tiny differences in initial conditions grow exponentially over time, making long-term prediction impossible without numerical integration. Even small rounding errors in the starting positions lead to completely different trajectories after a few orbital periods. This sensitive dependence on initial conditions is the hallmark of deterministic chaos.

How strong is the gravitational force between Earth and Moon?

The gravitational force between Earth (5.972 x 10^24 kg) and the Moon (7.342 x 10^22 kg) at their average separation of 384,400 km is about 1.98 x 10^20 N. This force is what keeps the Moon in orbit and drives Earth's ocean tides. It accelerates the Moon toward Earth at about 2.70 mm/s^2.

What units should I use for masses when entering planetary values?

Solar masses work best for stars. Jupiter masses (1 Mjup = 1.898 x 10^27 kg) are convenient for gas giants. Earth masses (1 Mearth = 5.972 x 10^24 kg) suit rocky planets and large moons. For sub-lunar bodies, switch to kilograms directly. The unit dropdown converts automatically to SI internally.

Can this calculator predict orbital trajectories or stability?

No. This tool computes instantaneous force magnitudes and accelerations at a single snapshot. It does not integrate the equations of motion over time, so it cannot tell you whether an orbit is stable, circular, or elliptical. For full trajectory simulation use REBOUND, N-body Gravity Simulator, or similar codes.

How does the mass ratio affect accelerations in a two-body system?

Newton's second law gives a = F/m. Both bodies experience the same force magnitude, but the lighter body accelerates far more. For the Earth-Sun pair, the Sun accelerates at 1.78 x 10^-8 m/s^2 while Earth accelerates at 5.93 x 10^-3 m/s^2. The ratio equals the inverse mass ratio: a_Earth/a_Sun = Msun/Mearth = 333,000.

What is the difference between gravitational force and gravitational acceleration?

Force F = Gm1m2/r^2 depends on both masses. Acceleration a = GM/r^2 (the gravitational field) depends only on the source mass M and distance r. A feather and a cannonball experience the same gravitational acceleration in free fall even though the cannonball experiences a far larger force, because it also has far more inertia.

What does the total gravitational potential energy in the three-body mode represent?

The three-body mode sums all three pairwise potential energies: U_total = U12 + U23 + U13, where each U_ij = -Gmi*mj/rij. This total is the energy that would need to be supplied to move all three bodies to infinite mutual separation. It does not include kinetic energy, so it is not the total mechanical energy of the system.