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

• 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).
• 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.

Written by