Bizarre gravitational energy equation

In "Electricity and magnetism" by Benjamin Crowell page 39 there is this:

Recall that the gravitational energy of two gravitationally interacting spheres is given by $PE = -Gm_1m_2/r$ where $r$ is the center-to-center distance.

Is this true? I think comes from the force by distance equation for energy where the force is $F_g = -Gm_1m_2/r^2$ and the distance is $r$ but that implies that the force is constant over the whole range of motion. We can only make such assumptions if the distance between the objects is a lot larger than the range of motion but here they are equal.

I can not just let this slide because we are supposed to make analogy from this about electromagnetic interactions which are referenced numerous times in the rest of the book and it makes appearances in example questions. Am I missing something?

The force is not constant, it is a function of $\dfrac{1}{r^2}$ (omitting constants for clarity). The integral of $\dfrac{1}{r^2}$ with $r$ going from $r$ to $\infty$ is:
$$\int_r^\infty \dfrac{1}{x^2}dx = -\dfrac{1}{r}$$
• Could you also distinguish between the inner and the outer $r$ in the integral? – Jasper Apr 5 '18 at 21:43