Finding an Expression for the Universal Gravitational Potential Energy — with Calculus and Python

Image for post
Image for post
Photo: NASA. Apollo 11 Lunar Module
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
  • Pick some step size for the distance. Again, I’m just using my creativity for a value here — I’m feeling 100 meters. Maybe that won’t work — if that’s the case, I will pick something else.
  • Now I want to calculate the gravitational force on my 1 kg object at this distance and assume it’s constant over my step size. Use this value to calculate the work (done by a constant force over a straight line — the easiest kind of work).
  • Add this work to the total work (which started at 0 Joules).
  • Move to the next position and repeat.
  • Once I get to the final position, I can take the negative of this work (since the potential is the negative of work).
Image for post
Image for post
  • Lines 6–12 are really just constants and stuff. Nothing exciting.
  • Line 13 (U = 0) just sets up the potential sum so that I can add to it.
  • Line 15 is the loop.
  • Line 16, calculate the force.
  • Line 17–18, calculate the negative of the work and add it to the total potential.
  • The rest is boring.
Image for post
Image for post

Written by

Physics faculty, science blogger of all things geek. Technical Consultant for CBS MacGyver and MythBusters. Former WIRED blogger.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store