Barometric formula with variable gravity Recently, I have wondered about what would be the atmospheric pressure as a function of altitude in a planet that only consists of gas. The equation that does just that is the barometric formula (see https://en.wikipedia.org/wiki/Barometric_formula) but the gravitational acceleration is usually considered to be constant, which is certainly not the case in this thought experiment. I've tried to solve the differential equations, but I didn't managed to make it.
The gravitational acceleration as a function of altitude $d$ (from the center of the planet) is:
$$g(d)=\frac{4 \pi G}{d^2}\int_{0}^{d}R^2 \rho(R) \mathrm{d}R$$
Where $\rho(R)$ is the density of air at a distance $R$ from the center of the planet
 A: The below is taken from section 3 of J. Patrick Harrington's Notes on Hydrostatic Equilibrium, which I recommend reading for more detail.
For a spherical distribution of gas where the gravitational force is due to the gas itself, the equation of hydrostatic equilibrium is
$$
\frac{dP}{dr}=-\frac{GM_r\rho}{r^2}, \tag{1}
$$
where $M_r$ is the mass of gas contained within a sphere of radius $r$.
The variation of $M_r$ with radius is given by
$$
\frac{dM_r}{dr}=4\pi r^2\rho \tag{2}.
$$
Thus, after differentiating (1) and use of (2) we get
$$
\frac{1}{r^2}\frac{d}{dr}\left[\frac{r^2}{\rho}\frac{dP}{dr}\right]=-4\pi G\rho. \tag{3}
$$
In general, $P=P(\rho,T)$, so we need to know the variation of $T$ with $r$ to achieve closure. If we assume that the gas is isothermal and ideal, then $P=c_i^2\rho$, where $c_i$ is the constant isothermal speed of sound, and (3) becomes
$$
\frac{c_i^2}{r^2}\frac{d}{dr}\left[\frac{r^2}{\rho}\frac{d\rho}{dr}\right]=-4\pi G\rho. \tag{4}
$$
In general, equation (4) does not have an analytic solution for our boundary conditions and indeed is badly behaved at $r=0$, necessitating a series solution from $r=0.01$, say, to start a numerical integration.
However, there is an analytic solution if we let $\rho(0)\to\infty$. In this case, called the 'singular isothermal sphere',
$$
\rho(r)=\frac{c_i^2}{2\pi G}\frac{1}{r^2}.
$$
There's a load of interesting discussion and further exploration of the problem in the notes I linked.
