Home / Mechanics / Gravity Simulator

Gravity Simulator: Orbits & N-Body Motion

JEEWBJEE
Bodies: 0 Total energy: 0 Energy drift: 0 —

How this gravity simulator works

Newton's law of gravitation says every mass attracts every other mass with a force that falls off as the inverse square of the distance. In this simulator that force is calculated between every pair of bodies at every time step, so you are watching real N-body motion and not a pre-drawn path.

Force between two masses: F = G m₁ m₂ / r²
Circular orbital speed: v = √(GM / r)
Escape speed: v_e = √(2GM / r) = √2 × v
Orbital period: T = 2π √(r³ / GM)
Energy of a circular orbit: E = −GMm / 2r

Try the scenarios in order. With one planet you get a closed orbit. With three planets the inner one clearly moves faster, as T² ∝ r³ predicts. The binary star shows that two bodies really orbit their common centre of mass, and the figure-eight is a rare periodic solution of the three-body problem found numerically by Chenciner and Montgomery in 2000. In the sandbox, a slow drag gives a plunging orbit, a medium drag a bound ellipse and a fast drag a planet that escapes.

Exam tip: the speed of a satellite in a circular orbit does not depend on the satellite's own mass. Only M (the body being orbited) and r matter, so a heavier satellite at the same height has the same speed and the same period.

Sample data: orbital speed and escape speed in the Solar System

For a circular orbit around the Sun, v = √(GM/r) with GM = 1.327 × 10²⁰ m³/s². The escape speed from the Sun at the same distance is √2 times larger.

PlanetOrbit radius rOrbital speed vEscape speed √2 v
Mercury5.79 × 10¹⁰ m47.9 km/s67.7 km/s
Venus1.082 × 10¹¹ m35.0 km/s49.5 km/s
Earth1.496 × 10¹¹ m29.8 km/s42.1 km/s
Mars2.279 × 10¹¹ m24.1 km/s34.1 km/s
Jupiter7.785 × 10¹¹ m13.1 km/s18.5 km/s
Saturn1.434 × 10¹² m9.6 km/s13.6 km/s
Neptune4.495 × 10¹² m5.4 km/s7.7 km/s

Conditions: near-circular orbits, planetary masses ignored compared with the Sun, G = 6.674 × 10⁻¹¹ N m²/kg².

Notice: farther planets move slower. Mercury at 47.9 km/s is almost nine times faster than Neptune at 5.4 km/s, although Neptune is about 78 times farther away. Because v ∝ 1/√r, a planet 4 times farther out moves at half the speed.

Quick answers

What is the formula for gravitational force?
F = G m₁ m₂ / r², with G = 6.674 × 10⁻¹¹ N m²/kg². The force is always attractive and acts along the line joining the two masses.
What is the speed of a satellite in a circular orbit?
v = √(GM/r). For the ISS at 400 km height this is about 7.67 km/s, and for a geostationary satellite at 35,786 km height it is about 3.07 km/s.
What is the three-body problem?
Predicting the motion of three masses that attract each other. Unlike the two-body problem, it has no general closed-form solution, so it is solved numerically, as this simulator does.
Why does a binary star system orbit a centre of mass?
Each star pulls on the other with an equal and opposite force, so both move around the point where m₁r₁ = m₂r₂. For equal masses that point is exactly halfway between them.

Related simulations: Kepler orbits and escape velocity. Full guide: Gravitation, orbital and escape velocity explained

🎯 Practice Zone

Puzzle 1. 🌍 The Earth pulls the Moon with a force of about 2 × 10²⁰ N. How large is the force with which the Moon pulls the Earth?

The same, 2 × 10²⁰ N, in the opposite direction. Newton's third law holds for gravity. The Earth moves much less only because its mass is about 81 times larger, so its acceleration is 81 times smaller. Both really orbit a common centre of mass, which lies inside the Earth.

Puzzle 2. 🛰️ An astronaut floats inside the ISS. Is gravity switched off up there?

No. At 400 km height, g is still about 8.7 m/s², roughly 89 % of its value at the surface. The astronaut floats because the station and the astronaut are both in free fall around the Earth, falling together at the same rate, so there is no contact force between them.

Puzzle 3. 🪐 In the sandbox, you launch a planet from rest. What path does it take?

A straight line into the star. With zero starting velocity there is no sideways motion, so nothing keeps it away from the centre. Give it even a small sideways velocity and the path bends into a very narrow ellipse that swings close to the star.

Puzzle 4. ⚖️ Two stars of mass M and 3M orbit each other. Which one moves on the bigger circle?

The lighter one. The centre of mass satisfies M r₁ = 3M r₂, so r₁ = 3 r₂. The lighter star travels on a circle three times larger and therefore moves three times faster, while both have the same orbital period.

Puzzle 5. 🔁 Why can we write the orbit of Earth around the Sun exactly, but not the orbits of three equal stars?

With two bodies, the equations reduce to one central-force problem that has an exact solution, which gives Kepler's ellipses. With three bodies there are not enough conserved quantities to reduce the problem, so in general the motion is chaotic and must be computed step by step, as in this simulator.

Problem 1 (NEET level). 📘 Find the gravitational force between the Earth (5.972 × 10²⁴ kg) and the Moon (7.348 × 10²² kg) at a distance of 3.844 × 10⁸ m.

F = G M m / r² = (6.674 × 10⁻¹¹)(5.972 × 10²⁴)(7.348 × 10²²) / (3.844 × 10⁸)²
F = 1.98 × 10²⁰ N

Problem 2 (CBSE Class 11 level). 📕 At what height above the Earth's surface is the acceleration due to gravity one quarter of its surface value? (Take R = 6371 km.)

g' = g R² / (R + h)² = g/4, so (R + h) = 2R
h = R = 6371 km (and g' = 9.8 / 4 = 2.45 m/s²)

Problem 3 (WBJEE level). 📙 Find the height of a geostationary satellite above the Earth's surface. (T = 86164 s, GM = 3.986 × 10¹⁴ m³/s², R = 6371 km.)

r³ = GM T² / 4π², so r = 4.216 × 10⁷ m
h = r − R = 35,786 km, with orbital speed v = √(GM/r) = 3.07 km/s

Problem 4 (JEE Main level). 📗 Two stars, each of one solar mass (1.989 × 10³⁰ kg), orbit each other in circles, always 1 AU (1.496 × 10¹¹ m) apart. Find the orbital period.

For the pair, T = 2π √(d³ / G(M₁ + M₂)) = 2π √((1.496 × 10¹¹)³ / (6.674 × 10⁻¹¹ × 3.978 × 10³⁰))
T = 2.23 × 10⁷ s = 0.707 years, about 258 days

Problem 5 (JEE Advanced style). 📓 Cavendish used two lead spheres of 1 kg each with centres 0.1 m apart. Estimate the force between them, and compare with the weight of 1 kg.

F = G m₁m₂ / r² = 6.674 × 10⁻¹¹ × 1 × 1 / (0.1)² = 6.67 × 10⁻⁹ N
The weight of 1 kg is 9.8 N, about 1.5 × 10⁹ times larger, which is why the force is so hard to measure.
🍎
1687

Isaac Newton publishes the Principia with the law of universal gravitation, showing that the force that pulls an apple is the same one that holds the Moon in its orbit.

🔬
1798

Henry Cavendish measures the tiny attraction between lead spheres with a torsion balance. From it, the value of G and the mass of the Earth can be worked out, so he is said to have weighed the Earth.

🔭
1846

Urbain Le Verrier predicts the position of an unseen planet from its pull on Uranus. Johann Galle finds Neptune within one degree of that position, a triumph of Newtonian gravity.

🌀
1890

Henri Poincaré shows that the general three-body problem has no simple solution and can behave chaotically, which became one of the seeds of chaos theory.

∞
2000

Alain Chenciner and Richard Montgomery prove that three equal masses can chase each other along a single figure-eight path. The orbit was first found numerically by Cristopher Moore in 1993, and it is one of the presets here.