MATH-209 · Lesson 5 of 5 · 40 min

Divergence and Stokes' theorems

The fundamental theorem of calculus says that integrating a derivative over an interval gives the difference of the function's values at the two ends: the inside is summarized by the boundary. This chapter presents its three big multivariable cousins, Green's theorem, the divergence theorem and Stokes' theorem. Each says that adding up a derivative of a field over a region equals adding up the field itself around the region's boundary.

These theorems are not just elegant mathematics. They are how the conservation laws of engineering are written. The equation of continuity in fluid mechanics, Gauss's and Ampère's laws in electromagnetics, and the heat equation all come from them. The chapter starts with the two derivatives involved, divergence and curl, and what they mean physically, then states and applies each theorem.

Divergence: sources and sinks

The divergence of a vector field \(\mathbf{F} = (P, Q, R)\) is the scalar

\[\nabla \cdot \mathbf{F} = \frac{\partial P}{\partial x} + \frac{\partial Q}{\partial y} + \frac{\partial R}{\partial z}\]

Physically, divergence measures the net outflow per unit volume at a point. If \(\mathbf{F}\) is the velocity of a fluid, positive divergence means fluid is spreading out from the point (a source, or a gas expanding); negative divergence means it is converging (a sink, or a gas being compressed). Zero divergence means whatever flows into a small box flows out again.

For a liquid, which is very nearly incompressible, conservation of mass requires \(\nabla \cdot \mathbf{v} = 0\) everywhere except at real sources and drains. This is the continuity equation for incompressible flow, the first equation every fluid mechanics course writes down.

Three small vector field sketches. A source with arrows pointing outward from a point: positive divergence, zero curl. A sink with arrows pointing inward: negative divergence. A swirl with arrows circling a point and a small paddle wheel that would spin: zero divergence, nonzero curl.
Divergence measures spreading out; curl measures rotation, the spin a tiny paddle wheel would pick up.

Curl: rotation

The curl of \(\mathbf{F}\) is the vector

\[\nabla \times \mathbf{F} = \begin{vmatrix} \mathbf{i} & \mathbf{j} & \mathbf{k} \\ \partial_x & \partial_y & \partial_z \\ P & Q & R \end{vmatrix} = \left( R_y - Q_z,\; P_z - R_x,\; Q_x - P_y \right)\]

Curl measures local rotation. Imagine a tiny paddle wheel placed in a flowing fluid: the curl points along the axis about which it spins fastest (by the right-hand rule), and its magnitude is twice the wheel's angular velocity. A field with zero curl everywhere is called irrotational, and on a region without holes it is exactly a conservative (gradient) field, the 3D version of the test \(P_y = Q_x\) from Lesson 4. Indeed, the z-component of the curl, \(Q_x - P_y\), is precisely that 2D test.

Worked problem

Computing divergence and curl

For \(\mathbf{F} = (x^2y,\; yz,\; xz)\), find \(\nabla \cdot \mathbf{F}\) and \(\nabla \times \mathbf{F}\).

Show solution
  1. Divergence: \(\partial(x^2y)/\partial x + \partial(yz)/\partial y + \partial(xz)/\partial z = 2xy + z + x\).
  2. Curl, component by component:
  3. i: \(R_y - Q_z = 0 - y = -y\). j: \(P_z - R_x = 0 - z = -z\). k: \(Q_x - P_y = 0 - x^2 = -x^2\).

Answer: ∇ · F = 2xy + z + x; ∇ × F = (−y, −z, −x²)

Worked problem

A spinning disk

The velocity of a disk rotating at angular velocity \(\omega\) about the z-axis is \(\mathbf{v} = (-\omega y, \omega x, 0)\). Find its divergence and curl.

Show solution
  1. \(\nabla \cdot \mathbf{v} = 0 + 0 + 0 = 0\).
  2. \(\nabla \times \mathbf{v} = (0, 0, \omega - (-\omega)) = (0, 0, 2\omega)\).

Answer: Divergence 0 (a rigid body neither expands nor compresses) and curl (0, 0, 2ω): twice the angular velocity, along the rotation axis. In fluid mechanics, the curl of velocity is called the vorticity

Two identities are worth remembering: the curl of a gradient is always zero, \(\nabla \times (\nabla f) = \mathbf{0}\), and the divergence of a curl is always zero, \(\nabla \cdot (\nabla \times \mathbf{F}) = 0\). Both follow from the equality of mixed partial derivatives. A third combination, the divergence of a gradient, gives the Laplacian, \(\nabla^2 f = f_{xx} + f_{yy} + f_{zz}\), which appears in the heat, wave and Laplace equations.

Green's theorem

Green's theorem connects a line integral around a closed curve C in the plane to a double integral over the region D it encloses. With C traversed counterclockwise (the region on the left):

\[\oint_C P\,dx + Q\,dy = \iint_D \left( \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y} \right) dA\]

The integrand on the right is the z-component of the curl. So Green's theorem says: the total circulation around the boundary equals the total rotation inside. The picture explains why. Divide the region into tiny cells and add up the circulation around each one. Along every interior edge, the two neighboring cells traverse it in opposite directions, so those contributions cancel, and only the outer boundary survives.

A region D bounded by a closed curve C traversed counterclockwise. The region is divided into a grid of small square cells, each with a small counterclockwise circulation arrow. Interior edges have opposing arrows that cancel; only the outer boundary arrows remain.
Why Green's theorem works: circulations around small cells cancel on shared edges, leaving only the boundary.

Worked problem

Checking against Lesson 4

Use Green's theorem to find the circulation of \(\mathbf{F} = (-y, x)\) around a circle of radius R.

Show solution
  1. \(Q_x - P_y = 1 - (-1) = 2\).
  2. \(\oint_C = \iint_D 2\,dA = 2 \times \pi R^2\).

Answer: 2πR², which is 2π for the unit circle, exactly the value computed directly in Lesson 4

Worked problem

An integral that would be miserable directly

Evaluate \(\oint_C (3y - e^{\sin x})\,dx + (7x + \sqrt{y^4 + 1})\,dy\), where C is the circle \(x^2 + y^2 = 9\), counterclockwise.

Show solution
  1. \(P = 3y - e^{\sin x}\), \(Q = 7x + \sqrt{y^4 + 1}\).
  2. \(Q_x - P_y = 7 - 3 = 4\). The awkward terms vanish because \(e^{\sin x}\) has no y and \(\sqrt{y^4 + 1}\) has no x.
  3. \(\oint_C = \iint_D 4\,dA = 4 \times 9\pi = 36\pi\).

Answer: 36π ≈ 113.1. A numerical evaluation of the line integral confirms it

Area from a boundary

Choosing \(P = -y/2\), \(Q = x/2\) makes \(Q_x - P_y = 1\), so

\[A = \frac{1}{2}\oint_C (x\,dy - y\,dx)\]

The area of a region can be found by walking around its boundary. For an ellipse \(x = a\cos t\), \(y = b\sin t\): \(\tfrac{1}{2}\int_0^{2\pi}(ab\cos^2 t + ab\sin^2 t)\,dt = \pi ab\). This is the principle of the planimeter, a mechanical instrument once used to measure areas on maps and indicator diagrams by tracing their outlines, and of the shoelace formula for polygons (MATH-125) used by surveying software today.

The divergence theorem

The divergence theorem (Gauss's theorem) is the 3D statement of conservation. For a solid region E with closed boundary surface S and outward normal \(\mathbf{n}\):

\[\iint_{S} \mathbf{F} \cdot \mathbf{n}\,dS = \iiint_E \nabla \cdot \mathbf{F}\,dV\]

Here S is closed, so the surface integral covers the whole boundary. In words: the total flux out through the boundary equals the total of all the sources inside. Again, adjacent small boxes share faces where their fluxes cancel, leaving only the outer surface.

A closed box-shaped region with outward normal arrows on each face and flux arrows leaving. Inside, small source symbols. A label states that flux out of the surface equals the integral of divergence over the volume.
The divergence theorem: what flows out of a closed surface equals what is produced inside.

Worked problem

The sphere again

In Lesson 4, the outward flux of \(\mathbf{F} = (x, y, z)\) through a sphere of radius R was \(4\pi R^3\). Explain this with the divergence theorem.

Show solution
  1. \(\nabla \cdot \mathbf{F} = 1 + 1 + 1 = 3\).
  2. \(\iiint_E 3\,dV = 3 \times \tfrac{4}{3}\pi R^3 = 4\pi R^3\).

Answer: 4πR³: three times the volume, because the divergence is 3 everywhere

Worked problem

Flux out of a cube

Find the outward flux of \(\mathbf{F} = (x^2, y^2, z^2)\) through the surface of the unit cube \([0, 1]^3\).

Show solution
  1. Directly, you would need six surface integrals. Instead: \(\nabla \cdot \mathbf{F} = 2x + 2y + 2z\).
  2. \[\iiint_E (2x + 2y + 2z)\,dV = 3 \times \int_0^1 2x\,dx = 3 \times 1 = 3\]

Answer: 3. (By symmetry each of the three terms integrates to 1 over the cube.) One volume integral replaced six surface integrals

Worked problem

Is this flow incompressible?

Near the nose of a body in a stream, the flow is approximately \(\mathbf{v} = (ax, -ay, 0)\) (a stagnation-point flow). Is it consistent with an incompressible liquid?

Show solution
  1. \(\nabla \cdot \mathbf{v} = a - a + 0 = 0\).
  2. By the divergence theorem, the net flux out of any closed surface is zero: as much water enters as leaves.

Answer: Yes. Fluid arriving along the x-direction is turned and leaves along the y-direction at the same total rate. Checking ∇ · v = 0 is a first test of any proposed liquid flow field

Gauss's law

For the electric field of a point charge, \(\mathbf{E} = \dfrac{q}{4\pi\varepsilon_0}\dfrac{\mathbf{r}}{|\mathbf{r}|^3}\), a direct calculation gives \(\nabla \cdot \mathbf{E} = 0\) everywhere except at the charge itself, and the flux through any sphere around the charge is \(q/\varepsilon_0\). Combining these with the divergence theorem shows that the flux through any closed surface that encloses the charge is \(q/\varepsilon_0\), whatever its shape: Gauss's law from PHYS-131. In differential form, \(\nabla \cdot \mathbf{E} = \rho/\varepsilon_0\).

Stokes' theorem

Stokes' theorem lifts Green's theorem off the plane. For an oriented surface S with boundary curve C, traversed so that the surface is on the left when you walk along C with your head in the direction of \(\mathbf{n}\) (the right-hand rule):

\[\oint_C \mathbf{F} \cdot d\mathbf{r} = \iint_S (\nabla \times \mathbf{F}) \cdot \mathbf{n}\,dS\]

The circulation around the edge equals the total flux of curl through any surface spanning it. A remarkable consequence: every surface with the same boundary gives the same answer, so you can choose the simplest one.

A hemisphere sitting on the xy-plane with its boundary the unit circle traversed counterclockwise when seen from above. Outward normals point away from the hemisphere. Beside it, the flat unit disk with upward normal spans the same circle.
Any two surfaces with the same boundary curve, such as a hemisphere and a flat disk, give the same flux of curl.

Worked problem

Choosing the easy surface

Find \(\iint_S (\nabla \times \mathbf{F}) \cdot \mathbf{n}\,dS\) for \(\mathbf{F} = (-y, x, z)\) over the upper hemisphere \(x^2 + y^2 + z^2 = 1\), \(z \ge 0\), with outward (upward) normal.

Show solution
  1. The boundary is the unit circle in the xy-plane, counterclockwise seen from above.
  2. By Stokes, the answer equals \(\oint_C \mathbf{F} \cdot d\mathbf{r}\). On the circle, \(z = 0\) and \(\mathbf{F} = (-y, x, 0)\), whose circulation is \(2\pi\) (Lesson 4).
  3. Check with the flat disk instead: \(\nabla \times \mathbf{F} = (0, 0, 2)\) and \(\mathbf{n} = \mathbf{k}\), so the flux is \(2 \times \pi = 2\pi\).

Answer: 2π, found three ways without ever integrating over the curved hemisphere

Ampère's law

Stokes' theorem converts Ampère's law, \(\oint_C \mathbf{B} \cdot d\mathbf{r} = \mu_0 I_{enc}\), into its differential form, \(\nabla \times \mathbf{B} = \mu_0\mathbf{J}\) (for steady currents): circulation of the magnetic field around a loop equals \(\mu_0\) times the current passing through any surface bounded by the loop. Together with Gauss's law and Faraday's law, these are Maxwell's equations, the foundation of electrical engineering.

The big picture: conservation laws

Here is how the divergence theorem turns a physical balance into a differential equation, the template for many of the governing equations of engineering. Consider heat in a solid with density \(\rho\), specific heat \(c\), conductivity \(k\) and temperature \(T\). For any region E, the rate of increase of thermal energy inside equals the rate heat flows in through the boundary. Heat flux is \(\mathbf{q} = -k\nabla T\) (Fourier's law), so

\[\iiint_E \rho c\frac{\partial T}{\partial t}\,dV = -\iint_{S} \mathbf{q} \cdot \mathbf{n}\,dS = -\iiint_E \nabla \cdot (-k\nabla T)\,dV\]

Because this holds for every region E, the integrands must be equal:

\[\frac{\partial T}{\partial t} = \alpha\,\nabla^2 T, \qquad \alpha = \frac{k}{\rho c}\]

This is the heat equation, solved in heat transfer courses and in every thermal simulation program. Replace heat by mass and you get the continuity equation; by momentum, the Navier-Stokes equations of fluid flow; by charge, Maxwell's equations. Multivariable calculus is the common language of all of them.

A table relating the theorems. Fundamental theorem of calculus: integral of f prime over an interval equals f at the end points. Line integrals: integral of grad phi along a curve equals phi at the end points. Green: double integral of the curl component over a region equals circulation around its boundary curve. Stokes: flux of curl through a surface equals circulation around its boundary curve. Divergence: triple integral of divergence over a solid equals flux through its boundary surface.
One idea, five forms: the integral of a derivative over a region equals the function integrated over the region's boundary.

Common mistakes

  • MistakeConfusing divergence (a scalar) with curl (a vector).

    Instead∇ · F adds diagonal partials and gives a number; ∇ × F is a determinant and gives a vector.

  • MistakeGetting a sign wrong in a curl component.

    InsteadUse (R_y − Q_z, P_z − R_x, Q_x − P_y), or expand the determinant carefully.

  • MistakeTraversing the boundary clockwise in Green's theorem.

    InsteadThe region must be on your left: counterclockwise for the outer boundary.

  • MistakeApplying the divergence theorem to a surface that is not closed.

    InsteadIt needs a closed surface enclosing a solid; close an open surface with a cap and subtract the cap's flux.

  • MistakeIgnoring points where the field is undefined (such as the location of a point charge).

    InsteadThe theorems need the field to be smooth throughout the region; exclude singular points with a small surface around them.

  • MistakeMismatching the normal and the boundary direction in Stokes' theorem.

    InsteadUse the right-hand rule: thumb along n, fingers curl in the direction of C.

Summary and key terms

  • Divergence ∇ · F = Pₓ + Q_y + R_z measures net outflow per unit volume; incompressible flow has ∇ · v = 0.
  • Curl ∇ × F = (R_y − Q_z, P_z − R_x, Q_x − P_y) measures rotation; irrotational fields on simply connected regions are conservative.
  • curl(grad f) = 0 and div(curl F) = 0; div(grad f) is the Laplacian ∇²f.
  • Green: ∮_C P dx + Q dy = ∬_D (Qₓ − P_y) dA, with C counterclockwise; it also gives area from the boundary.
  • Divergence theorem: outward flux through a closed surface equals the volume integral of the divergence.
  • Stokes: circulation around a boundary curve equals the flux of curl through any surface spanning it.
  • These theorems turn balance laws into the governing equations of engineering: continuity, heat, Gauss, Ampère.
Divergence
The scalar ∇ · F, the net outflow per unit volume.
Curl
The vector ∇ × F, measuring local rotation.
Irrotational
Having zero curl.
Incompressible
Having zero divergence of velocity.
Vorticity
The curl of a fluid's velocity field.
Laplacian
∇²f = fₓₓ + f_yy + f_zz, the divergence of the gradient.
Green's theorem
Relates circulation around a plane curve to a double integral over the region inside.
Divergence theorem
Relates flux out of a closed surface to the volume integral of divergence.
Stokes' theorem
Relates circulation around a curve to the flux of curl through a surface bounded by it.
Continuity equation
The mass conservation law; ∇ · v = 0 for incompressible flow.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Find the divergence and curl of \(\mathbf{F} = (xy, yz, zx)\).

    Show answer

    div = y + z + x. curl = (0 − y, 0 − z, 0 − x) = (−y, −z, −x).

  2. Show that \(\mathbf{F} = (2x, 2y, 2z)\) is irrotational and find its divergence.

    Show answer

    curl = (0, 0, 0). div = 6. It is the gradient of x² + y² + z².

  3. Verify that div(curl F) = 0 for \(\mathbf{F} = (x^2y, yz, xz)\).

    Show answer

    curl F = (−y, −z, −x²); its divergence is 0 + 0 + 0 = 0.

  4. Use Green's theorem to evaluate \(\oint_C x^2\,dy\) around the unit square [0, 1]², counterclockwise.

    Show answer

    P = 0, Q = x²: ∬2x dA = 1.

  5. Use the area formula to find the area enclosed by \(x = \cos^3 t\), \(y = \sin^3 t\) (an astroid).

    Show answer

    A = ½∫(x y′ − y x′) dt = ½∫₀^{2π} 3 sin²t cos²t dt = 3π/8.

  6. Find the outward flux of \(\mathbf{F} = (x, 2y, 3z)\) through the sphere of radius 1.

    Show answer

    div F = 6. Flux = 6 × (4/3)π = 8π.

  7. Find the outward flux of \(\mathbf{F} = (y, z, x)\) through any closed surface.

    Show answer

    div F = 0, so the flux is 0.

  8. Is \(\mathbf{v} = (y, x, 0)\) a possible incompressible flow? Is it irrotational?

    Show answer

    div = 0: incompressible. curl = (0, 0, 1 − 1) = 0: irrotational.

  9. Use Stokes' theorem to find the circulation of \(\mathbf{F} = (z, x, y)\) around the unit circle in the xy-plane, counterclockwise.

    Show answer

    curl F = (1, 1, 1). Through the unit disk with n = k: flux = 1 × π = π.

  10. Explain why the heat equation for steady conditions with no heat sources reduces to Laplace's equation.

    Show answer

    Steady means ∂T/∂t = 0, so α∇²T = 0, i.e. ∇²T = 0.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz