[Physics] Inconsistency between two formulas for Gravitational Potential Energy that don’t yield the same result

newtonian-gravitypotentialpotential energyvirial-theorem

According to this site the general form of the Gravitational Potential Energy of mass $m$ is

$$U=-\frac{GMm}{r}\tag{1}$$
where $G$ is the gravitation constant, $M$ is the mass of the attracting body, and $r$ is the distance between their centre's.

However, I am learning Astrophysics at the moment and in the derivation of the Virial Theorem I came across this alternate definition of the Gravitational Potential Energy $\Omega$

$$\Omega=-\int_{m=0}^M \frac{Gm}{r}\mathrm{d}m\tag{2}$$


So my question is as follows:

If I go ahead and integrate $(2)$ I find that
$$\Omega=-\left[\frac{Gm^2}{2r}\right]_{m=0}^{m=M}=-\frac{GM^2}{2r}\ne U$$

But unless I'm mistaken, $\Omega$ must be equal to $U$.

Why are equations $(1)$ and $(2)$ apparently inconsistent due to giving different results?

I tried searching the internet for an explanation but all sites I found give the same result, like this one on page 6.

Therefore, could someone please explain to me why I am finding that $U\ne\Omega\,$?

Best Answer

There are two problems with the manipulations you've done.

First, the variables in equation (2) are ambiguously named. Equation (2) calculates the potential energy between a single mass $m$ and a mass distribution with total mass $M$. Then the equation should actually read $$\Omega = - Gm \int \frac{dM}{R}.$$ If we instead write the differential as $dm$, it looks like $m$ is being integrated as well. This results in a meaningless extra factor of $1/2$ when the integration is performed.

Next, the integral over $dM$ shouldn't be naively performed as if $R$ is constant, $$\int \frac{dM}{R} \neq \frac{M}{R}$$ in general. The issue is that every piece of mass $dM$ has its own radius $R$, so $R$ should be thought of as a function of $M$. If this doesn't make sense, just think about the discrete case, $$\sum_i \frac{m_i}{R_i}$$ where a radius $R_i$ is associated with every bit of mass $m_i$.


In your particular case, where we're thinking about two point masses separated by a distance $R$, the quantity $R$ in the integrand really is constant, so we can pull it out for $$\Omega = - \frac{Gm}{R} \int dM = -\frac{GMm}{R}$$ as expected. For a more general configuration, we would parametrize the masses and radii somehow to get a concrete integral, e.g. we could use the chain rule for $$\int \frac{dM}{R} = \int \frac{dM}{dR} \frac{dR}{R}$$ where $dM/dR$ tells us the amount of mass in thin spherical shells of radius $R$. I explain how to do this kind of integral a bit more in this answer.