# Derivation of pressure gradient stellar equation [duplicate]

I am trying to understand how to derive the following formula:

$$\frac{dP(r)}{dr}=-\frac{GM(r_<)\rho(r)}{r^2}$$

The notes are as follow:

Consider a star with COM and a shell:

$$P_1 - P_2 = -{\large\frac{dP}{dr}}\,dr$$

$${\large\frac{dP}{dr}} + g\rho = 0$$ ( My main issue with the derivation is unsure where this comes from.)

Then if we take $$g = {\large\frac{Gm}{r^2}}$$ and substitute into the above equation, we get the expected result.

If anyone could explain this derivation to me or an alternative one, it would be much appreciated.

• Commented Jul 2 at 8:21

If we suppose hydrostatic equilibrium, then \begin{align} \sum \vec{F}_i=0 \end{align}The forces acting come from: $$1$$) Pressure difference $$2$$) Gravity. I'll suppose all forces are radial and then just equal them.

Let's calculate the forces. First \begin{align}[P(r)-P(r+dr)]\,dA=dP\,dA \end{align} Then we need force due to the mass enclosed by $$dA\,dr$$: \begin{align} F_g= dm\, g &= \rho\,g\,dV &\\ &= \rho g\,dA dr\\&=\rho \frac{GM_r}{r^2} \,dAdr \end{align}

As those forces must be equal:

\begin{align} \require{cancel}-\rho G \frac{M_r}{r^2} \cancel{dA}\,dr &=dP\,\cancel{dA}\\ -\rho G \frac{M_r}{r^2} &=\frac{dP}{dr}\end{align} The minus sign come from a simple reasoning they point in opposite direction. $$M_r$$ is the mass enclosed by a surface of radius $$r

• First when I saw the problem, I tried to approach it by calculating the net force from outer layers of sphere acting on a shell element, and then divided it by the element's area. Indeed it must be wrong but I couldn't understand why? Commented Sep 24, 2021 at 16:56

It comes from:

$$F = ma = mg$$

$$F(r) = m(r)g(r)$$

Where the force to support the mass at $$r$$ is the pressure gradient:

$$F(r) = \frac{dP}{dr}$$

and is equal to the weight (mass times gravity)

$$w= g\rho(r)$$

with the gravity from Gauss's law (the enclosed mass for spherical symmetry):

$$g = -G\frac{M(