The magnitude of the gravitational force is given by:
We use the connection between force and potential energy to determine the gravitational potential energy:
|→   U = - ∫ F dr|
|This gives: U||= -||
if we define the potential energy to be zero at r = ∞.
Important: the potential energy is negative!
A negative potential energy is consistent with mgh for potential energy near the surface of the Earth. If you lift an object a height h from the ground, the potential energy change is:
ΔU = Uf - Ui = -GmM/(R+h) - ( -GmM/R ) .
Now use the approximation (from Taylor's theorem):
1/(R+h) = 1/[R(1+h/R)] ≈ (1/R)*(1 - h/R)
when h is small compared to R.
Substituting this in the expression for Δ U gives:
ΔU = -GmM/R + GmMh/R2 + GmM/R = GmMh/R2
We showed previously that g = GM/R2, so:
ΔU = mgh.