Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 49 · Vector Calculus and Electrostatics

Gradient, divergence and curl

Learn the three derivatives of vector calculus with intuitive pictures, worked examples, the divergence and Stokes theorems, and code that computes them.

Single-variable calculus has one derivative. A field in three dimensions has several: a scalar can change in different directions, and a vector can spread out, rotate or both. Vector calculus packages those changes into three operators built from one symbol, the del operator ∇ = (∂/∂x, ∂/∂y, ∂/∂z). Learn them once, with pictures, and every equation in electrodynamics reads like plain language.

Three arrow grids: a uniform field, a spreading radial field and a rotating field with their divergence and curl values
Caption: A uniform field has no divergence or curl, a radial field has divergence, and a rotational field has curl.

What you will learn

  • What the gradient of a scalar, the divergence of a vector and the curl of a vector measure.
  • How to compute each in Cartesian coordinates and check results with simple fields.
  • The divergence theorem and Stokes' theorem, and why they matter physically.
  • Two identities that always hold: ∇×(∇f) = 0 and ∇·(∇×F) = 0.

Key terms

  • Gradient ∇f: vector pointing in the direction of steepest increase of f, with magnitude equal to that slope.
  • Divergence ∇·F: a scalar giving net outflow of F per unit volume.
  • Curl ∇×F: a vector giving circulation of F per unit area, pointing along the axis of rotation.
  • Flux: ∫ F·dA, the amount of field crossing a surface.
  • Circulation: ∮ F·dl, the field summed along a closed loop.

Gradient: the slope of a scalar

For a scalar function f(x, y, z), the gradient is

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

It points in the direction in which f increases fastest, and its length is the rate of increase in that direction. The rate of change along any other direction n̂ is the directional derivative n̂·∇f. A hiker on a hill sees this: the gradient points straight uphill and is perpendicular to the contour lines (curves of constant f).

Example. For f = x²y, ∇f = (2xy, x²). At (1, 2) the gradient is (4, 1): moving along +x increases f four units per unit length, along +y one unit.

The fundamental theorem for gradients says ∫ₐᵇ ∇f · dl = f(b) − f(a), independent of the path. It will turn into "work done by an electrostatic force depends only on the endpoints".

Divergence: spreading out

For a vector field F = (Fx, Fy, Fz):

∇·F = ∂Fx/∂x + ∂Fy/∂y + ∂Fz/∂z

Picture water flowing. A faucet is a source (positive divergence), a drain is a sink (negative divergence), and a pipe of steady flow has zero divergence. For F = (x, y, z), pointing radially outward and growing with distance, ∇·F = 1 + 1 + 1 = 3: every point is a source with the same strength.

The divergence theorem connects the local property to a global one:

∮ F · dA = ∫ (∇·F) dV

The total flux out of a closed surface equals the sum of the sources inside. This is the mathematical heart of Gauss's law.

Curl: swirling

The curl is a vector:

∇×F = (∂Fz/∂y − ∂Fy/∂z, ∂Fx/∂z − ∂Fz/∂x, ∂Fy/∂x − ∂Fx/∂y)

Imagine a tiny paddle wheel in a fluid. It spins if the flow is faster on one side than the other. The curl points along the axis of the spin by the right-hand rule, and its magnitude is twice the angular speed. For F = (−y, x, 0) (rigid rotation about the z axis), ∇×F = (0, 0, 2) and ∇·F = 0.

Stokes' theorem links curl to circulation:

∮ F · dl = ∫ (∇×F) · dA

where the loop is the boundary of the surface. If the curl is zero everywhere, the circulation around every loop is zero and the field is conservative: F = ∇f for some scalar f.

Two identities

  • ∇×(∇f) = 0. A gradient field has no curl. Mixed partial derivatives commute, so the terms cancel in pairs.
  • ∇·(∇×F) = 0. A curl field has no divergence. This will explain why the magnetic field can be written as a curl, and why ∇·B = 0.

Why electrodynamics needs them

Look ahead: ∇·E = ρ/ε₀ says charges are sources of E. ∇×E = 0 says electrostatic fields do not circulate. These two statements are about local behavior, yet through the two theorems they give global results: flux out of a closed surface (Gauss) and zero work around any closed loop (potential exists).

A word on the point charge: the field E = k Q r̂ / r² has zero divergence everywhere except the origin, yet the flux through any sphere around it is Q/ε₀. The divergence is concentrated at the origin: ∇·(r̂/r²) = 4π δ³(r), with δ³ the Dirac delta function. This is a precise way to say that all the source sits at a point.

Common misconceptions

  • "∇ is a vector, so ∇·F is just a dot product." It is an operator: order matters. F·∇ is different from ∇·F.
  • "Zero divergence means the field is zero." A uniform field or a circulating field can have no divergence yet be strong.
  • "Curl is only for rotating fluids." Curl is a property of any vector field, including static fields with no motion at all, like the magnetic field of a wire.

Try it

The first demonstration draws the three example fields and computes their divergence and curl symbolically. The second checks the divergence theorem on a cube by adding up the flux through the six faces numerically.

Python Plot three fields and compute div and curl

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Divergence theorem on a unit cube

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check · 5 questions

of 5 answered You scored / 5 · perfect!

  1. 1. What is the gradient of f = x² + y² at the point (1, 1)?

    ∇f = (2x, 2y), which is (2, 2) at (1, 1). The gradient is a vector, not a number.
  2. 2. What is the divergence of F = (x², 0, 0) at x = 3?

    ∇·F = ∂(x²)/∂x = 2x = 6 at x = 3.
  3. 3. The curl of F = (−y, x, 0) is

    ∂Fy/∂x − ∂Fx/∂y = 1 − (−1) = 2 along z.
  4. 4. Which identity is always true?

    The curl of a gradient vanishes. (∇·∇f is the Laplacian, not zero in general.)
  5. 5. The divergence theorem relates

    ∮F·dA = ∫∇·F dV. The line-to-surface relation is Stokes' theorem.

Summary

  • ∇f points uphill with magnitude equal to the slope; ∇·F measures outflow; ∇×F measures circulation.
  • Divergence theorem: ∮F·dA = ∫∇·F dV. Stokes' theorem: ∮F·dl = ∫(∇×F)·dA.
  • ∇×(∇f) = 0 and ∇·(∇×F) = 0 hold for any smooth fields.
  • The field of a point charge has divergence concentrated at the charge: ∇·(r̂/r²) = 4πδ³(r).

Next: Gauss's law