surface integrals in 3D explained
You have seen the Gauss and Stokes theorems on a circle in the plane. That was a flat shadow of the real shape, and the real stage is 3 dimensions. The divergence theorem is not a circle in the plane but a sphere in space, and the boundary is not a rim but a surface. The Stokes theorem is not a disk in the plane. It holds for any surface you cap onto the same loop. Turn the screen with a finger and see, in the solid, how a normal stands on a surface, how flux passes through a face, and how the sum inside comes to equal the boundary. The two lines memorized in the plane come alive again on a volume and a surface. High places are painted gold and low places blue, and that surface is the first face of this stage.
First see what a surface is, in the solid. A saddle sheet z = 0.4(x² − y²) floats on the screen, a saddle-like surface that rises one way and falls the perpendicular way. Drag the screen with a finger to turn it and what looked like a flat picture is really a 2-dimensional sheet floating in space. High places are painted gold and low places blue. At one point on the surface a normal arrow n̂ stands straight up. At every point it is the direction exactly perpendicular to the sheet there. Bend the saddle more with the slider and the normal tilts with it. A surface is a face, and you can stand one normal anywhere on it. That is the start of a surface integral.
Now set that surface in a flow. There is a field F = [0, 0, 1.4] flowing evenly upward, and a flat rectangular sheet floats in that flow. The sheet is painted green, the flow arrows are blue, and the outward normals on the sheet are gold. The surface flux ∫∫ F·n̂ dS is the total flow that passes out through this sheet. It is the sum, over every small patch of the face, of F·n̂ times the area of that patch. Tilt the sheet with the slider, from facing the flow to standing edge-on, and the difference shows. Facing the flow head-on the flux is largest, and standing sideways along the flow it falls to nearly 0. Drag the screen to turn it and the angle between the normal and the flow shows in the solid. Flux is, in the end, how squarely the face looks at the flow.
Now the real stage of the divergence theorem. The circle in the plane was really the shadow of a sphere. The field is F = [x, y, z], a flow reaching out from the origin in every direction, and the divergence is ∇·F = 3 everywhere. A translucent gold sphere floats on the screen, and gold outward normal arrows ring its surface. Grow and shrink the sphere with the radius slider and the two numbers follow together. Boundary = the total flux leaking out through the sphere surface ∮∮ F·n̂ dS, inside = the volume integral of the divergence through the ball ∭ ∇·F dV. The boundary number is gold, the inside number is blue, and when they agree a green almost-match appears. At every radius the two nearly agree, because both are 4πR³. Drag the screen to turn it and you see the arrows beyond the sphere as well. The same theorem, lifted one dimension, from a rim in the plane to a surface, and from an area to a volume.
The Stokes theorem shows its real strength in 3D. The field is F = [−y, x, 0], a swirl that turns counterclockwise in the plane, and the curl is ∇×F = (0, 0, 2). On the screen there is a closed circular loop in the plane z=0. The loop itself is blue, and the tangent arrows running around it are gold. Press a button and the capping surface on this loop switches between a flat disk and a dome raised up. The cap is painted gold. The point is that the two shapes are nothing alike and still share the same loop as boundary. Boundary = the circulation around the loop ∮ F·dr, surface = the curl flux through the cap ∫∫ (∇×F)·n̂ dS, and the two nearly agree, and the value stays the same whether you change the cap to a disk or to a dome. The boundary number is gold, the surface number is blue, and green appears when they agree. Grow the loop with the radius slider and drag the screen to turn it, and that is confirmed. The circulation is fixed by the boundary alone, and the sum of the curl is the same through any surface that closes that boundary.
Last, lay 2D and 3D on one screen. Buttons move between the two modes. Turn on 3D and a sphere ringed with outward normals, or a loop with a cap, floats in the solid. The Gauss surface is gold and the Stokes cap is blue. Turn on 2D and that flattens into the very picture seen in the plane. Gauss, a circle in the plane ringed with outward arrows, or Stokes, with tangent arrows running around. Another button switches Gauss and Stokes too. Drag the screen to turn it and the sphere and the loop that were solid tip onto their side and you see how they collapse into the plane picture. The 2D theorem in the plane was not wrong. It was the shadow of this 3D theorem looked down upon. ∮∮ F·n̂ dS = ∭ ∇·F dV and ∮ F·dr = ∫∫ (∇×F)·n̂ dS, two lines that close the whole of vector calculus.