Skip to content

Vector Calculus

Gradients, Divergence, Curl, and the theorems that bind them together

1. Building Intuition

Regular calculus asks: how fast is a single number changing? Vector calculus asks the same question about quantities that live in 2D or 3D space — temperature, wind speed, electric field, fluid velocity. These quantities have both magnitude and direction at every point, forming a vector field.

The three fundamental operations of vector calculus each answer a different question:

  • Gradient (∇f) — Given a scalar field (e.g. temperature), in which direction is it increasing fastest? The gradient is a vector pointing uphill, perpendicular to contour lines.
  • Divergence (∇·F) — Is the vector field spreading out or converging at this point? Positive divergence means a source (fluid gushing out); negative means a sink (fluid draining in).
  • Curl (∇×F) — Is the field rotating locally? Curl measures the tendency of the field to spin a tiny paddle wheel placed at that point. Zero curl means the field is irrotational.

All three are built from the same differential operator del (∇) — the vector of partial derivatives. This unifying notation is why Maxwell's equations for electromagnetism can be written in just four lines.

A vector field assigns a direction and magnitude to every point in space. In fluid mechanics this could be velocity; in electrostatics, the electric force on a test charge.

2. The Mathematics

The del operator (nabla) is the key notation. It packages the partial derivatives into a vector-like symbol that can act on scalars (giving gradient) or on vectors (giving divergence or curl):

Del Operator

Gradient

Applied to a scalar function f(x,y,z), del gives the gradient — a vector field pointing in the direction of maximum increase of f. The magnitude |∇f| is the rate of increase in that direction. Contour lines / level surfaces are always perpendicular to the gradient.

Gradient

Elliptic contours of f(x,y) = x² + 0.5y². The yellow arrow (gradient) always points perpendicular to the contour through that point — the direction of steepest uphill climb.

Divergence

The dot product of ∇ with a vector field F measures how much the field spreads out from a point. If you imagine fluid flowing with velocity field F, then ∇·F > 0 means fluid is being created (source), ∇·F < 0 means it's being destroyed (sink), and ∇·F = 0 means the fluid is incompressible.

Divergence

Curl

The cross product of ∇ with F measures the field's local rotation. If you place a tiny paddle wheel in a flowing fluid, curl tells you how fast and in which axis it spins. Conservative fields (like gravity) have zero curl everywhere.

Curl

Left: F = (x, y) — arrows point outward, ∇·F = 2 (source). Right: F = (-y, x) — arrows rotate, ∇×F = 2k (pure rotation, zero divergence).

The Great Theorems

Three theorems generalize the Fundamental Theorem of Calculus to higher dimensions. Each says: a global quantity (integral over a region) equals a boundary quantity (integral on the edge).

Gradient Theorem (Line Integral)

The line integral of a gradient only depends on endpoints — work done by a conservative force is path-independent.

Stokes' Theorem (Surface Integral)

The flux of curl through a surface equals the circulation around its boundary edge. Ampere's law (electromagnetism) is an application of Stokes' theorem.

Divergence Theorem (Volume Integral)

The total divergence inside a volume equals the net flux through its closed surface. Gauss's law (electrostatics) is an application of the Divergence Theorem.

Surface integrals, and the other two coordinate systems

A flux integral needs a surface, not just a field. Parametrize the surface by r(u, v). The patch area points along the cross product of the two partial derivatives, and the flux is the field dotted into that vector:

Parametrized surface

The divergence theorem makes the unit sphere easy. For F = (x, y, z), div F = 3, and the unit ball has volume 4π/3, so the outward flux is 3 · 4π/3 = 4π. Computing the sphere parametrization directly gives the same 4π, which is a good check that the normal was oriented outward.

Cartesian div and curl are the wrong shapes for a pipe or a planet. In cylindrical coordinates (r, θ, z) and spherical coordinates (ρ, φ, θ) the divergence picks up the scale factors of the volume element:

Divergence in cylindrical coordinates

The extra r inside the radial derivative is why a source that falls off as 1/r² in three dimensions, or 1/r in two, can still be divergence-free everywhere except the origin. Forgetting it is the usual mistake when a flux “does not add up.”

3. Applications

Maxwell's Equations

All of electromagnetism compressed into four equations using ∇· and ∇×. Gauss's law (∇·E = ρ/ε₀), no magnetic monopoles (∇·B = 0), Faraday's law (∇×E = -∂B/∂t), Ampere-Maxwell law (∇×B = μ₀J + μ₀ε₀∂E/∂t).

Fluid Dynamics

The Navier-Stokes equations use divergence (incompressibility: ∇·v = 0) and the gradient of pressure as the driving force. Curl of velocity gives vorticity — the spinning of fluid parcels in turbulence.

Machine Learning & Optimization

Gradient descent uses ∇L (gradient of the loss function) to find the steepest downhill direction in parameter space. Every backpropagation step computes a high-dimensional gradient.

Heat & Mass Transfer

Fourier's heat law: heat flux = -k∇T. Divergence of heat flux = heat generated. Combined with the time derivative gives the heat equation ∂T/∂t = α∇²T.

4. Worked Examples

Example 1: Gradient of a Scalar Field

Let f(x, y, z) = x²y + yz³. Find ∇f and evaluate at the point (1, 2, 1).

Compute each partial derivative:

Gradient

At (1, 2, 1): ∇f = (4, 2, 6). The steepest ascent direction is (4, 2, 6), normalized: (4, 2, 6) / √(16+4+36) ≈ (0.53, 0.27, 0.80). The rate of change in that direction is |∇f| = √56 ≈ 7.48.

Example 2: Divergence and Curl of F = (xy, yz, zx)

Divergence

The divergence varies by position — regions where x+y+z > 0 are sources, < 0 are sinks.

Curl

The non-zero curl confirms this field rotates locally — it is not conservative (no potential function exists).

Example 3: Divergence Theorem — Flux Through a Sphere

Calculate the outward flux of F = (x, y, z) through the unit sphere x²+y²+z² = 1.

Direct surface integration is tedious. Instead, apply the Divergence Theorem:

Compute the divergence: ∇·F = ∂x/∂x + ∂y/∂y + ∂z/∂z = 3. Since the divergence is constant, the volume integral is just 3 × (volume of unit sphere):

Result

The Divergence Theorem turned a hard surface integral into a trivial multiplication. This is the same reasoning behind Gauss's law: the electric flux through any closed surface equals the total charge enclosed divided by ε₀.

5. Resources

Site soundtrack