# Find the density of the sphere, $\rho(r)$

If the field vector $$\hat{g}$$ is independent of the radial distance withing the sphere, find the function describing the density $$\rho$$ of the sphere, $$\rho(r)$$.

In spherical coordinates, the divergence of a vector field, or in this case the divergence of $$\hat{g}$$ is given as $$\nabla \cdot \hat{g}=\frac{1}{r^2}\partial_r(r^2g_r)+\frac{1}{\sin\theta}\partial_{\theta}(g_{\theta}\sin{\theta})+\frac{1}{r\sin{\theta}}+\partial_{\phi}g_{\phi}$$

and by Gauss's law for gravity this is equal to $$-4\pi G \rho$$. Since the only variable in the function $$\hat{g}$$ is the radius $$r$$, the equation becomes the following ( the other partials equal zero ) $$\frac{1}{r^2}\partial_r(r^2g_r)=-4\pi G\rho$$

What does it mean to be independent of radial distance? I think it means $$g$$ and all its components are constant with respect to the variable $$r$$. Apply this to the equation and $$\frac{2}{r}C=-4\pi G\rho$$

this is an equation we could solve for the density. But the sign will be wrong. Could anyone take a look at this?

• $g_r<0$, since the radial component of the gravitational field points towards the center, then $C$ is also negative.
– AFG
Mar 14, 2021 at 15:21
• @variations There is a discussion about the same problem here Mar 14, 2021 at 15:30

Gauss's law for gravity acts pretty much the same as for a negative electric charge. Inside a thin spherical shell of uniform density, the field is zero. If you step outside, the field gets stronger. Only a zero field (and density) can be constant inside of a sphere. (Note that your formula predicts an infinite density at r = 0.) On second thought, it occurs to me that the field from a density inside a shell decrease with an increasing radius and this might offset the increase that occurs when you step out. We can check your result. If we assume that ρ = C/r where C can have any value, then g = GM/$$R^2$$ where M is the interior mass (the integral of ρ4π$$r^2$$dr from 0 to R: = 4πC$$R^2$$/2) at any R. Putting this M in the expression for g yields: g = 2πGC (a constant).