 For the computation of the potential energy, we can integrate the gravitational force, whose magnitude is given by Newton's law of gravitation, with respect to the distance "r" between the two bodies.Using that definition, the gravitational potential energy of a system of masses "m"1 and "M"2 at a distance "r" using gravitational constant "G" is

where "K" is an arbitrary constant dependent on the choice of datum from which potential is measured.Choosing the convention that "K"=0 (i.e.