The flux $\phi$ through a surface (or the integral of the vector flux density **g** over a closed surface) equals the divergence of the flux density integrated over the volume contained by the surface:

$\phi =\iint {\textbf {g}}\cdot d{\textbf {s}}=\iiint \nabla \cdot {\textbf {g}}\;dxdydz$.
Commonly called **Gauss's theorem**.

## Generalization to arbitrary dimensions

The divergence theorem is a general mathematical result that may be applied in arbitrary dimensions.

If we have an integral over the volume $D$ in $R^{m}$ bounded by $\partial D$ in $R^{m-1}$ then the following relation holds

$\int _{D}\mathbf {\nabla } \cdot \mathbf {Q} \;dV=\int _{\partial D}\mathbf {\hat {n}} \cdot \mathbf {Q} \;dS.$
Here, $Q$ is a vector field and the integrand of the (hyper-)volume integral is an exact divergence of that vector field. The quantity $\mathbf {\hat {n}} =({\bar {n}}_{1},{\bar {n}}_{2},...{\bar {n}}_{m}),$ is the outward-pointing
normal vector to the (hyper-) surface $\partial D.$ Each ${\bar {n}}_{k}$ is the respective direction cosine
obtained by forming the inner product of the normal to the boundary $\partial D$ with the respective ${\hat {x}}_{k}$ coordinate axis unit vector.

Because we are in arbitrary dimensions $\mathbf {x} =(x_{1},x_{2},...,x_{m})$ and $\nabla \equiv \left({\frac {\partial }{\partial x_{1}}},{\frac {\partial }{\partial x_{2}}},...,{\frac {\partial }{\partial x_{m}}}\right)$.

### Proof^{[1]}

Consider the case when $m=3$ and $D$ is a three-dimensional volume bounded by the two-dimensional
boundary $\partial D$. The volume integral may be written in three terms, one for each coordinate direction

$\int _{D}\mathbf {\nabla } \cdot \mathbf {Q} \;dV=\int _{D}{\frac {\partial Q_{1}}{\partial x_{1}}}\;dV+\int _{D}{\frac {\partial Q_{2}}{\partial x_{2}}}\;dV+\int _{D}{\frac {\partial Q_{3}}{\partial x_{3}}}\;dV.$
If we concentrate on the $x_{1}$ volume integral and apply the fundamental theorem of calculus we obtain

$\int _{D}{\frac {\partial Q_{1}}{\partial x_{1}}}dV=\int _{X_{2}^{-}(x_{1},x_{3})}^{X_{2}^{+}(x_{1},x_{3})}\int _{X_{3}^{-}(x_{1},x_{2})}^{X_{3}^{+}(x_{1},x_{2})}\int _{X_{1}^{-}(x_{2},x_{3})}^{X_{1}^{+}(x_{2},x_{3})}{\frac {\partial Q_{1}}{\partial x_{1}}}\;dx_{1}dx_{2}dx_{3}$

$=\int _{X_{2}^{-}(X_{1}^{-},x_{3})}^{x_{2}^{+}(X_{1}^{+},x_{3})}\int _{X_{3}^{-}(X_{1}^{-},x_{2})}^{X_{3}^{+}(X_{1}^{+},x_{2})}\left[Q_{1}(X_{1}^{+},x_{2},x_{3})-Q_{1}(X_{1}^{-},x_{2},x_{3})\right]\;dx_{2}dx_{3}.$

Here, the functions $X_{k}^{+}$ and $X_{k}^{-}$ define points on $\partial D$ of greater
$x_{k}$ and lesser $x_{k},$ respectively.

Now, if we consider the surface integral

$\int _{\partial D}\mathbf {\hat {n}} \cdot \mathbf {Q} \;dS.=\int _{\partial D}\left[{\bar {n}}_{1}Q_{1}+{\bar {n}}_{2}Q_{2}+{\bar {n}}_{3}Q_{3}\right]\;dS$
and concentrate on the $x_{1}$ term

$\int _{\partial D}{\bar {n}}_{1}Q_{1}\;dS=\int _{X_{2}^{-}(X_{1}^{-},x_{3})}^{X_{2}^{+}(X_{1}^{+},x_{3})}\int _{X_{3}^{-}(X_{1}^{-},x_{2})}^{X_{3}^{+}(X_{1}^{+},x_{2})}{\bar {n}}_{1}Q_{1}(x_{1},x_{2},x_{3})\;dS.$
On the part of $\partial D$ that is of greater $x_{1}$ the values of $Q_{1}=Q_{1}(X_{1}^{+},x_{2},x_{3})$
and ${\bar {n}}_{1}dS=dx_{2}dx_{3}$. On the part of the surface that of lesser values of $x_{1}$ the values of $Q_{1}=Q_{1}(X_{1}^{-},x_{2},x_{3})$ and ${\bar {n}}_{1}dS=-dx_{2}dx_{3}$. Here ${\bar {n}}_{1}\equiv \pm {\hat {x}}_{1}\cdot \mathbf {\hat {n}}$ on the respective portion of the surface.

Thus, the surface integral for the $Q_{1}$ is the same as the volume integral of the $\partial Q_{1}/\partial x_{1}$
term:

$\int _{\partial D}{\bar {n_{1}}}Q_{1}\;dS=\int _{X_{2}^{-}(X_{1}^{-},x_{3})}^{X_{2}^{+}(X_{1}^{+},x_{3})}\int _{X_{3}^{-}(X_{1}^{-},x_{2})}^{X_{3}^{+}(X_{1}^{+},x_{2})}\left[Q_{1}(X_{1}^{+},x_{2},x_{3})-Q_{1}(X_{1}^{-},x_{2},x_{3})\right]\;dx_{2}dx_{3}.$
Here $X_{1}^{\pm }=X_{1}^{\pm }(x_{2},x_{3}).$

Similar results may be found for the $Q_{2}$ and $Q_{3}$, proving the divergence theorem
for 3 dimensions.

This same method generalizes for the case of $m>3$ dimensions, proving the theorem for the arbitrary case.

## References

- ↑ Greenspan, H. P., Benney, D. J., & Turner, J. E. (1986). Calculus: an introduction to applied mathematics. McGraw-Hill Ryerson Ltd.