Showing that gravitational flux remains constant. Let the vector field
$$\vec{F}(x,y,z)=\frac{GM}{(x^2+y^2+z^2)^\frac32}
\begin{pmatrix}
x \\
y\\
z\\
\end{pmatrix}$$
Where $G$ is the universal gravitational constant and $M$ the mass of earth. I must demonstrate that the flux of this vector field is constant throughout all 7 atmosphere layers at a distance $R_1, R_1,...,R_7$ from Earth.
I tried hard, but could someone please help me get started with this? The whole demonstration is supposed to take a single line.
Thanks a lot !
 A: HINT:
For $\vec r\ne 0$, $\nabla \cdot \vec F=0$.  Now use the Divergence Theorem for any spherical shell (i.e., $0<r_1<r<r_2$ for any $0<r_1<r_2$) and show that the net flux is zero.
SPOILER ALERT:  CLICK ON THE SHADED AREA TO SEE ANSWER

For $r>0$, we have $\nabla \cdot \vec F=0$.  Then, using the Divergence Theorem we observe that for $0<r_1<r_2$,$$\begin{align}\int_{0}^{2\pi}\int_0^{\pi}\int_{r_1}^{r_2}\nabla \cdot \vec F(\vec r)\,r^2\,dr\,\sin \theta\,d\theta\,d\phi&=\int_0^{2\pi}\int_0^{\pi}\vec F(r_2,\theta,\phi)\cdot \hat r\,r_2^2\,\sin \theta\,d\theta\,d\phi\\\\&-\int_0^{2\pi}\int_0^{\pi}\vec F(r_1,\theta,\phi)\cdot \hat r\,r_1^2\,\sin \theta\,d\theta\,d\phi\\\\&=0\end{align}$$This implies that$$\int_0^{2\pi}\int_0^{\pi}\vec F(r_2,\theta,\phi)\cdot \hat r\,r_2^2\,\sin \theta\,d\theta\,d\phi=\int_0^{2\pi}\int_0^{\pi}\vec F(r_1,\theta,\phi)\cdot \hat r\,r_1^2\,\sin \theta\,d\theta\,d\phi\\\\$$ 
and therefore the flux is invariant.

A: I will go into a little more detail then Batominovski but take a similar approach by not using the divergence theorem and having to deal with the divergence of this field. I will using spherical coordinates, in these coordinates
$$\vec{F}=\frac{GM}{r^{2}}\hat{r}$$
$$d\vec{A}=r^{2}\hat{r}sin(\phi)d\phi d\theta$$
$$d\Phi=\vec{F}\cdot d\vec{A}=GMsin(\phi)d\phi d\theta$$
$$\Phi=\int d\Phi=GM\int_{0}^{2\pi}\int_{0}^{\pi}sin(\phi)d\phi d\theta$$
$$\Phi=4\pi GM$$
This flux is independent of the nonzero radius that we take.
A: A non-Calculus Approach:
Consider a solid angle $\delta\Omega$ at the center of the Earth.  The area subtending this solid angle at radius $r$ from the center of the Earth is $r^2\,\delta\Omega$.  The gravitational force is radial and its strength at radius $r$ is given by $-\frac{GM}{r^2}$ (the minus sign means that the force is directed inwards to the center of the Earth).  This means the gravitational flux through this area is $$-\frac{GM}{r^2}\cdot r^2\,\delta\Omega=-GM\,\delta\Omega\,.$$  Hence, the flux through any area subtended by this solid angle does not depend on the radius $r$.  In fact, the total flux can be calculated by taking $\delta\Omega=4\pi$, which gives $-4\pi GM$.
A: Some notes on the question.
It is better to write $\vec{g}$ and the sign should be negative as the field points TOWARDS the Earth. So better to write

$$
\vec{g} = - G M \frac{ x \hat{x} + y \hat{y} + z \hat{z} }{r^3}. \tag 1
$$


By definition we have

$$
\textrm{Flux} = \int_S \vec{g} \cdot d\vec{A}.\tag {2a}
$$

We have the divergence theorem

$$
\int_V \vec{\nabla} \cdot \vec{g} dV = \int_S \vec{g} \cdot d\vec{A}.\tag {2b}
$$

And we have Poisson's equation

$$
\vec{\nabla} \cdot \vec{g} = - 4 \pi G \rho. \tag {2c}
$$

Combine them and we get

$$
\textrm{Flux} = - 4\pi G \int_V \rho dV. \tag 3
$$

Thus

$$
\textrm{Flux} = - 4\pi G m_V. \tag 4
$$

where $m_V$ is the mass INSIDE the volume $V$.
Consider volumes as spheres with radius $R$ and let $R_0$ be the radius of the Earth and let $M_0$ be the mass of the Earth.
NOTE that all layers have mass as well!
The mass inside the sphere $R_n$ is then given by

$$
\sum_{k=0}^n M_k. \tag 5
$$

So the flux between $R_n$ and $R_{n+1}$ is given by

$$
- 4 \pi G \sum_{k=0}^n M_k. \tag 6
$$

So
$$
\bbox[16px,border:2px solid #800000] { \textrm{The flux is NOT constant.} }
$$
But as $M_k << M_0$ for $k > 0$, it is almost constant.
