Divergence theorem

"A novice might find a proof easier to follow if we greatly restrict the conditions of the theorem, but carefully explain each step. For that reason, we prove the divergence theorem for a rectangular box, using a vector field that depends on only one variable. " - - The Divergence (Gauss-Ostrogradsky) theorem relates the integral over a volume, $$\mathsf V$$, of the divergence of a vector function, $$\mathbf \vec F$$, and the integral of that same function over the the volume's surface:
 * See Divergence theorem for more rigorous proofs.
 * See the subpage, Divergence theorem/Proof for another proof.

Special case of a field that depends on only one variable:
Figure 2 shows a vector field using red arrows to denote the field's direction and magnitude. The field occupies all three dimensions, but is only directed in the x or y directions. And, the field varies only along the x-axis. In other words, $$\mathbf \vec F$$ is of the form,

where $$F_x$$ and $$F_y$$ are arbitrary "smooth" functions of only the variable $$x.$$ A z-component, $$F_z(x)$$, could be included in (2) without adding any complexity to the proof, except that the third component could not easily be depicted in Figure    2.

Volume integral
Our first task is to use the fundamental theorem of calculus to perform this integral over the volume of the box. Despite the fact that the vector field points in two directions, the divergence operator $$\mathbf\vec\nabla$$ removes any involvement of the y-component, since the field does not depend on $$y$$:

Integrals over three-dimensional boxes are easy to perform:

Since $$\partial F_x /\partial x$$ does not depend on $$y$$ or $$z,$$ the partial derivative may be treated as a constant with regard to those to variables. The integrations in (4) are structured so that they may be performed in any order, which permits us to write:

where $$A=(y_2-y_1)(z_2-z_1)$$ is the area of the two sides at $$x=x_1$$ and $$x=x_2$$ as shown in Figure 2.

Surface integrals
Now we calculate the surface integral and verify that it yields the same result as (5). The surface integral over the box involves six rectangles. One way to define a two-dimensional surface in three-dimensions is to state one equation involving the three variables. The six surfaces of the box in Figure 2 can be labeled by the set of six (infinite) planes: $$ \{x=x_1, x=x_2, y=y_1, y=y_2, z=z_1, z=z_2\}$$. In contrast with one-dimensional integrals, surface and volume integrals require much more than simply stating the two endpoints associated with a one dimensional integral. Each of the six surfaces must be integrated separately, and the integral over the entire surface equals the sum of the six individual integrals. A common shorthand for surface integrals is, $$\hat \mathbf n\, d\mathbf S = d\vec A$$, where $$\hat\mathbf n$$ the outward unit normal, and $$d\mathbf S=\left|d \vec A\right|.$$

Integration over x-pair surfaces
The two most important surfaces are the pair already discussed, with area $$A$$, and outward unit normals in the x-direction, shown as the left and right ends of the box shown in Figure 2. Since $$x$$ is constant over each of these two surfaces, the the surface integral of anything that depends only on $$\mathbf \vec F(x)$$ is trivial, and depends only on the area, which is the same area, $$A$$, shown in Figure 2 and also at (5). The algebra for the surface at $$x=x_1$$ is:

To understand how $$\mathbf{\vec F}\cdot\mathbf{\hat{n}}$$ was evaluated in (7), recall that the outward unit normal points in the negative x direction on that side. Also, when a vector is dotted with a unit vector, only one component of the vector survives:

since, $$\mathbf\hat n =-\mathbf\hat i$$, at $$x=x_1.$$ On the other side, $$\mathbf\hat n $$ points in the opposite direction, so that combining (5) with (7) establishes that (1) is true, but only if we can establish that the other four surface integrals vanish.

Integration over the y-pair and z-pair surfaces
We begin with the y-pair of surfaces, i.e., those that occupy a portion of the $$y=y_1$$ or the $$y=y_2$$ planes. Since the vector field $$\mathbf\vec F(x,y,z)$$ depends on the $$x$$-variable, the integral is not trivial. By the reasoning used at (7) and (8), we only need integrate the $$y$$-component, $$F_y$$, because the unit vector points in the $$\pm\mathbf\hat j$$ direction. Fortunately, the absence of a $$y$$-dependence of our vector field ensures that the following two integrals are equal:

Since the outward unit normals, $$\mathbf\hat n = \pm \mathbf\hat j,$$ are equal and opposite on both sides, the pair of surface integrals at (9) cancel. The same argument can be the $$z$$-pair of surfaces.

Conclusion
Although we have proven the divergence theorem on a rectangular box for a small subset of all possible differentiable vector fields $$\vec F(\vec r)$$, we have established the essential role played by the fundamental theorem of calculus in one-dimension. Essentially, we have placed the two endpoints of segment along the x-axis by the six surfaces that form the boundary of a three-dimensional box. Also, the reader who can grasp this proof is probably capable of developing a proof for any vector field $$\vec F(\vec r)$$ for which the divergence is well defined. It just takes a lot of algebra.