Solution (source code)

= Solution

For a thin spherical shell, the radial <pressure> force per unit <volume> is $-dP/dr$. By the <shell theorem>, the inward <gravitational acceleration> is $GM(r)/r^2$, because exterior spherical shells contribute no force. Balancing force densities in <hydrostatic equilibrium> gives
$$
\boxed{\frac{dP}{dr}=-\frac{GM(r)\rho(r)}{r^2},\qquad\frac{dM}{dr}=4\pi r^2\rho(r).}
$$
The second equation is <mass conservation>; it closes the pressure-support equation once an <equation of state> is supplied.