The magnitude of the gravitational force is given by:
F_{g}  =  

We use the connection between force and potential energy to determine the gravitational potential energy:
F  =   
 → 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 = U_{f}  U_{i} = 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/R^{2} + GmM/R = GmMh/R^{2}
We showed previously that g = GM/R^{2}, so:
ΔU = mgh.