The gravitational
potential energy (

) of an object, from some reference point - such as the surface of the earth, is defined as the amount of work required to move the object from the reference point to its position.
The force of gravity is given by:
where

is the distance of the object from the reference point. Example: the distance of a satellite from the earth's surface.
If you make a graph of force versus distance

you would see it begin at

and decrease exponentially towards zero as

increases.
If you marked the horizontal axis for the reference point and the distance of the object, the gravitational potential energy would be represented by the area bounded by the graph and the horizontal axis, between the two marked points. You can calculate this with the integral:
where

is the reference point and

is the position of the object.
If you solve this you end up with:
However, the forumula you find in physics books is this:
where
I remember my physics teacher saying that the latter formula is used to make things simpler - when

.
I can't figure out how they managed to get from the first formula to the second one, to me they don't seem to be interchangeable...

...???