Gravitational potential energy of a body at a point is defined as the amount of work done in bringing the given body from infinity to that point against the gravitational force.
Let a body of mass m is placed at P in the gravitational field of a body of mass M. Let r be the distance of P from the centre O of the body of mass M, then the total work done(W) by the gravitational field when the body of mass m is moved from infinity to a distance r from O, is given by