Kreyszig, Chapters 9–10

Vector Calculus

Gradient, divergence, curl. The mathematics of fluid flow, electromagnetism, and heat transfer.

Prerequisites: Multivariable calculus (partial derivatives, multiple integrals), vectors.
10
Chapters
6+
Simulations
10
Quizzes

Chapter 0: Why Vector Fields?

A weather map shows wind speed and direction at every point. An ocean current carries water in different directions at different depths. The electric field around a charge pushes test charges in radial directions with varying strength.

All of these are vector fields: assignments of a vector to every point in space. Scalar fields (like temperature) assign just a number. Vector calculus gives us the tools to analyze both.

The three operators: Vector calculus has three fundamental differential operators: gradient (∇f, turns a scalar field into a vector field), divergence (∇·F, measures how much a vector field "spreads out"), and curl (∇×F, measures how much it "swirls"). Together they describe all of classical physics.

The symbol ∇ ("del" or "nabla") is the vector differential operator:

∇ = (∂/∂x, ∂/∂y, ∂/∂z)

Applied different ways, it gives gradient, divergence, and curl. Think of ∇ as a Swiss army knife for fields.

What is a vector field?

Chapter 1: The Gradient

Given a scalar field f(x, y, z) (like temperature), its gradient is the vector of partial derivatives:

∇f = (∂f/∂x, ∂f/∂y, ∂f/∂z)

The gradient points in the direction of steepest ascent of f. Its magnitude ||∇f|| is the rate of change in that direction. If you are standing on a mountain and want to go uphill as fast as possible, follow the gradient.

Key insight: The gradient is perpendicular to level curves (contour lines). If f(x,y) = c is a contour, then ∇f at any point on that contour points straight away from it. This is why water flows perpendicular to contour lines on a topographic map.

The directional derivative of f in the direction of a unit vector u is:

Duf = ∇f · u

This is the dot product of the gradient with the direction. Maximum when u points along ∇f. Zero when u is tangent to a level curve. Negative when u points downhill.

Gradient Field Visualizer

Contour lines of f(x,y) shown in teal. Gradient vectors (orange arrows) point perpendicular to contours, uphill. Choose a scalar field.

If f(x,y) = x2 + y2, what is ∇f at the point (1, 2)?

Chapter 2: Divergence

Given a vector field F = (F1, F2, F3), its divergence is the scalar:

∇ · F = ∂F1/∂x + ∂F2/∂y + ∂F3/∂z

The divergence measures the net outward flux per unit volume at each point. Think of it as measuring whether the field is a source (positive divergence, fluid spreading out) or a sink (negative divergence, fluid being sucked in).

Physical meaning: Imagine a tiny box in a flowing fluid. If more fluid leaves the box than enters, div F > 0 at that point (source). If more enters than leaves, div F < 0 (sink). If the flow is perfectly balanced, div F = 0 (incompressible flow).

Example: F = (x, y, 0). Then div F = 1 + 1 + 0 = 2. This is a uniform source everywhere — the field radiates outward uniformly.

Example: F = (−y, x, 0). Then div F = 0 + 0 + 0 = 0. This is pure rotation — no sources, no sinks. The field just swirls.

Divergence Visualizer

Vector field shown as arrows. Background color: orange = positive divergence (source), teal = negative (sink), dark = zero. Choose a field.

If F = (−y, x, 0), what is div F?

Chapter 3: Curl

The curl of a vector field measures its local rotation:

∇ × F = (∂F3/∂y − ∂F2/∂z, ∂F1/∂z − ∂F3/∂x, ∂F2/∂x − ∂F1/∂y)

The curl is a vector: its direction is the axis of rotation (right-hand rule), and its magnitude is twice the angular speed of rotation.

Analogy: Drop a tiny paddlewheel into a fluid flow. If it spins, curl F ≠ 0 at that point. The direction of the curl vector is the axis the paddlewheel spins around.

Example: F = (−y, x, 0). Curl F = (0, 0, 1 − (−1)) = (0, 0, 2). The field rotates counterclockwise around the z-axis.

Example: F = (x, y, 0). Curl F = (0, 0, 0). A radial outflow has no rotation.

Two key identities:
∇ × (∇f) = 0 — the curl of any gradient is zero. (Gradients do not swirl.)
∇ · (∇ × F) = 0 — the divergence of any curl is zero. (Curls have no net source.)
These are not just formulas; they encode deep structure about which fields can be gradients and which can be curls.

A field with curl = 0 everywhere is called irrotational (or conservative). A field with div = 0 is called solenoidal (or incompressible). Maxwell's equations are built on these concepts.

What does ∇ × (∇f) = 0 mean physically?

Chapter 4: Line Integrals

A line integral computes the cumulative effect of a field along a curve. For a vector field F along a curve C parameterized by r(t):

C F · dr = ∫ab F(r(t)) · r'(t) dt

This is the work done by force F along path C. At each point, we take the component of F along the curve direction and accumulate.

Conservative fields: If F = ∇f (a gradient), then ∫C F·dr = f(B) − f(A). The integral depends only on the endpoints, not the path. This is path independence, and f is the potential function. Gravity and electrostatics are conservative. Friction is not.

Test for conservative: In 2D, F = (P, Q) is conservative if and only if ∂P/∂y = ∂Q/∂x (equivalently, curl F = 0 in a simply connected domain). If so, the potential f satisfies ∂f/∂x = P and ∂f/∂y = Q.

Line Integral Explorer

A vector field (arrows) and a path (orange curve). The line integral sums F·dr along the path. For conservative fields, different paths give the same answer. Click to change path shape.

If F = ∇f and C is a closed loop, what is ∮C F·dr?

Chapter 5: Green's Theorem

Green's theorem connects a line integral around a closed curve to a double integral over the enclosed region:

C (P dx + Q dy) = &iint;D (∂Q/∂x − ∂P/∂y) dA

The left side is a circulation integral around the boundary C. The right side sums up the "curl" (∂Q/∂x − ∂P/∂y) over the interior D.

Why Green's theorem matters: It says the total circulation around a boundary equals the sum of all local rotation inside. A hard boundary integral becomes an easy area integral, or vice versa. It is the 2D version of a much deeper pattern (Stokes' theorem).

Special case — area formula: With P = −y/2 and Q = x/2, we get ∂Q/∂x − ∂P/∂y = 1, so:

Area = (1/2) ∮C (x dy − y dx)

This lets you compute the area of any region from its boundary parameterization. Surveyors use this formula (the shoelace formula for polygons is a discrete version).

What does Green's theorem relate?

Chapter 6: Surface Integrals

Just as line integrals integrate along curves, surface integrals integrate over surfaces in 3D. For a scalar function f over surface S:

&iint;S f dS = &iint;D f(r(u,v)) ||ru × rv|| du dv

For a vector field F, the flux integral measures how much of F passes through S:

&iint;S F · dS = &iint;S F · n dS

where n is the unit outward normal to the surface. The flux is the net rate at which the field passes through the surface.

Physical examples: The flux of an electric field through a closed surface gives the enclosed charge (Gauss's law). The flux of a velocity field through a surface is the volume flow rate. The flux of a heat flow field is the rate of heat transfer.

The cross product ru × rv of the partial derivatives of the parameterization gives a normal vector to the surface. Its magnitude ||ru × rv|| is the area element that accounts for how the surface stretches.

What does the flux integral &iint;S F·n dS measure?

Chapter 7: Stokes' & Gauss' Theorems

These are the crown jewels of vector calculus. They generalize Green's theorem to 3D.

Stokes' Theorem

C F · dr = &iint;S (∇ × F) · dS

The circulation of F around the boundary curve C equals the flux of curl F through any surface S bounded by C. Circulation around the edge = total rotation in the interior.

Divergence Theorem (Gauss)

&oiint;S F · dS = ∭V (∇ · F) dV

The total flux through a closed surface S equals the total divergence inside the volume V. What flows out through the boundary = what is produced inside.

The big picture: These theorems all say the same thing: the integral of a derivative over a region equals the integral of the function over the boundary. Green's, Stokes', and Gauss' theorems are all instances of the generalized Stokes theorem from differential forms.
TheoremDimensionBoundary ↔ Interior
Fund. Thm of Calculus1D∫f'dx = f(b) − f(a)
Green's Theorem2D∮ (P dx + Q dy) = &iint; (∂Q/∂x − ∂P/∂y) dA
Stokes' Theorem3D (surface)F·dr = &iint; (curl F)·dS
Divergence Theorem3D (volume)&oiint; F·dS = ∭ div F dV
The divergence theorem says that flux through a closed surface equals...

Chapter 8: Vector Field Lab

Explore 2D vector fields interactively. See gradient, divergence, and curl computed in real time. Drop particles and watch them trace streamlines.

Vector Field Explorer

Arrows show the field. Background heatmap shows divergence (orange = source, teal = sink). Click to drop particles that follow the flow. Watch how they concentrate (convergence) or spread (divergence).

Click on the field to drop a particle.
Maxwell's equations in one picture: Electric fields have divergence (from charges) but zero curl (in electrostatics). Magnetic fields have zero divergence (no monopoles) but nonzero curl (from currents). The divergence theorem and Stokes' theorem are the mathematical backbone of all electromagnetism.

Chapter 9: Connections

This lessonWhere it leads
GradientOptimization (gradient descent in ML), potential theory
DivergenceContinuity equation (fluid dynamics), Gauss's law (E&M)
CurlFaraday's law, Ampère's law, vorticity in fluids
Line integralsWork, circulation, conservative forces, potential energy
Green's theoremComplex analysis (Cauchy's theorem is Green's in disguise, Ch 7)
Stokes & GaussMaxwell's equations, general relativity, differential forms
The deep connection: Green's theorem, Stokes' theorem, and the divergence theorem are all special cases of the generalized Stokes theorem: ∫∂Ω ω = ∫Ω dω. The integral of a form over a boundary equals the integral of its exterior derivative over the interior. This single statement unifies all of vector calculus.

"The divergence theorem is the most important theorem in physics." — Richard Feynman

What is the one unifying idea behind Green's, Stokes', and the divergence theorem?