Lesson 15 of 15

Newton's Law of Gravitation

Universal Gravitation

Every mass attracts every other mass. Newton's law of universal gravitation:

F=Gm1m2r2F = \frac{G m_1 m_2}{r^2}

  • G=6.674×1011G = 6.674 \times 10^{-11} N·m²/kg² — the gravitational constant
  • m1,m2m_1, m_2 — masses in kg
  • rr — distance between centres in metres
  • FF — attractive force in Newtons

The Inverse-Square Law

Force falls off as 1/r21/r^2. Double the distance \to one quarter the force. This is why the Moon orbits Earth rather than flying away — gravity weakens with distance, but never reaches zero.

Relation to g=9.81g = 9.81 m/s²

At Earth's surface (r=6.371×106r = 6.371 \times 10^6 m, MEarth=5.972×1024M_{\text{Earth}} = 5.972 \times 10^{24} kg):

g=GMEarthr29.81 m/s2g = \frac{G M_{\text{Earth}}}{r^2} \approx 9.81 \ \text{m/s}^2

The familiar constant gg is just Newton's law applied at Earth's surface.

Examples (using m1=m2=1010m_1 = m_2 = 10^{10} kg)

rr (m)FF (N)
16.6740
21.6685
100.0667

Your Task

Implement gravForce(m1, m2, r) returning the gravitational force in Newtons.

TCC compiler loading...
Loading...
Click "Run" to execute your code.