Divergence of gravitational field

Intuitively, why is the divergence of the gravitational field zero outside a planet but non-zero inside it? Outside it feels 'obvious' but when I actually think about it I don't really get it.

I think the most intuitive way of understanding it is using $\textbf{Gauss Law}$ for the physical part and $\textbf{Gauss Theorem}$ for the mathematical part. If you integrate the divergence of the gravitational field over a certain volume V, because of Gauss Theorem, you get what we call the gravitational flux $\phi_G$ over the surface S that encapsulates V: $$\int\int\int_{V} \vec{\nabla} \cdot \vec{g} \ d\vec{r}^3 = \int \int_{S} \vec{g} \cdot d\vec{A} \equiv \phi_G$$ And the gravitational flux is, according to Gauss Law, given by: $$\phi_G = 4 \pi G \rho(\vec{r})$$ where $\rho(\vec{r})$ is a $\textbf{density mass along the volume V}$. Since this is valid for any volume V we have: $$\vec{\nabla} \cdot \vec{g} = 4 \pi G \rho(\vec{r})$$ Therefore if in a certain volume we have no mass at all, the mass density is zero and therefore the divergence of the gravitational field is zero. That's why it is zero outside planets and not zero inside them.
Another way of thinking it is by having the mental picture of $\phi_G$ as ''several arrows with different lengths and directions (which represent $\vec{g}$) crossing a certain surface S''. If this surface (for example, a sphere or an spheroid) encapsulates a certain mass distribution (i.e, a planet), which generates these 'arrows', the total arrows crossing the surface will give a net non zero value for $\phi_G$, and therefore a non-zero $\vec{\nabla} \cdot \vec{g}$ because of Gauss Theorem. But if this surface doesn't contain any mass distribution (we are outise the planet) then this will generate arrows that cross the surface two times each one, as we see in this picture:
It results that all the contributions coming from the arrows entering the surface exactly cancel all the contributions coming the arrows leaving the surface, so $\phi_G=0$ and therefore $\vec{\nabla} \cdot \vec{g} =0$.
This was the intuitive explanation for Gauss Law, but we can also have an intuitive explanation for Gauss Theorem. Gauss Theorem connects always what we have inside a volume with its boundaries. The diveregence is an scalar quantity formed by derivatives, so we can think of $\vec{\nabla} \cdot \vec{g}$ as the spatial variation of the grav. field trough all space. If there's a gravitational field crossing a surface S(think as a fluid leaving out a volume V of boundary S, this is a flux), it's obvious there's a variation of the gravitational field in this volume, i.e., a non zero divergence. But this will only happen in presence of mass, which is always the origin of $\vec{g}$, so in absence of mass $\vec{\nabla} \cdot \vec{g}=0$.
• In the picture $\vec{E}$ would represent the grav. field $\vec{g}$. Actually $\vec{E}$ represents the electric field, but Gauss Law is true for both gravitational and electric field. Apr 27, 2017 at 22:56