Gradient, Divergence, Curl and the Laplacian
Maxwell's equations are four statements about how fields change from point to point. They use three derivative operations, each with a physical meaning you will lean on for the rest of the course: the gradient turns a potential into a field (), the divergence measures how much a field spreads out of a point (), and the curl measures how much it circulates around a point (). The definitions and proofs are in Directional Derivatives and the Gradient and Curl and Divergence; this lesson gives them in the three coordinate systems of Vectors and Coordinate Systems for Fields and checks them with SymPy and finite differences.
Pictures first
- Gradient of a scalar such as the potential : a vector that points in the direction in which rises fastest, with a magnitude equal to that rate of rise (volts per metre). It is perpendicular to the surfaces of constant . The electric field points the other way, downhill.
- Divergence of a vector field: the net flux leaving a tiny volume, divided by the volume. Positive where field lines are born (positive charge), negative where they end, zero in empty space for .
- Curl of a vector field: the circulation around a tiny loop, divided by its area, as a vector along the loop's axis (right-hand rule). A paddle wheel put in the flow turns if the curl is not zero. A static has no curl; curls around currents.
The formulas
The operator works directly only in Cartesian coordinates:
In cylindrical and spherical coordinates the scale factors , and enter, because the unit vectors and element sizes change with position. The forms used most often in this course are
and, for a field that only circles the axis (, the magnetic field of a wire), . The full curl in curvilinear coordinates is on the formula sheet of Vector Calculus Summary.
The Laplacian is the divergence of the gradient, ; in Cartesian coordinates . It measures how much at a point differs from the average of its neighbours, and it is the operator of Poisson's and Laplace's equations (Poisson's and Laplace's Equations).
Two identities hold for any smooth fields and carry physics:
The first says a field derived from a potential has no curl, which is why electrostatic can be written as . The second says a field that is the curl of something has no divergence, which is why has no sources (Magnetic Flux and the Vector Potential).
Worked example
Given: in a region of space the potential is volts, with in metres.
Find: and at , the curl of , and the charge density at (anticipating in free space).
Solve:
Check: the curl is zero as the first identity demands. Units: . The charge density is tiny, as it always is for everyday potentials: a nanocoulomb per cubic metre bends the potential by .
In Python: SymPy and finite differences
sympy.vector knows the formulas in all three systems. The second half samples the same potential on a grid and differentiates numerically with np.gradient, which is how field solvers and measured data are handled.
import numpy as np
import sympy as sp
from sympy.vector import CoordSys3D, gradient, divergence, curl
C = CoordSys3D('C')
V = 50*C.x**2*C.y + 20*C.z
E = -gradient(V)
print("E =", E)
print("curl E =", curl(E))
print("laplacian V =", divergence(gradient(V)))
P = {C.x: 1, C.y: -1, C.z: 2}
Ep = [float(E.dot(u).subs(P)) for u in (C.i, C.j, C.k)]
print("E at P =", Ep, "V/m, |E| =", round(float(np.linalg.norm(Ep)), 1))
# cylindrical: the field of a uniformly charged cylinder and of a wire carrying current
Cy = CoordSys3D('Cy', transformation='cylindrical', variable_names=('rho', 'phi', 'z'))
rv0, I, a = sp.symbols('rho_v0 I a', positive=True)
D_in = rv0*Cy.rho/2*Cy.i # D inside a charged cylinder
H_in = I*Cy.rho/(2*sp.pi*a**2)*Cy.j # H inside a round wire
print("div D (cylinder) =", sp.simplify(divergence(D_in)))
print("curl H (wire) =", sp.simplify(curl(H_in)))
# numerical gradient on a 0.01 m grid around P
h = 0.01
x = np.arange(0.9, 1.1 + h/2, h); y = np.arange(-1.1, -0.9 + h/2, h); z = np.arange(1.9, 2.1 + h/2, h)
X, Y, Z = np.meshgrid(x, y, z, indexing='ij')
Vg = 50*X**2*Y + 20*Z
gx, gy, gz = np.gradient(Vg, h, h, h)
i = j = k = 10
print("numerical E at P =", [round(-float(g[i, j, k]), 3) for g in (gx, gy, gz)])
lap = sum(np.gradient(g, h, axis=ax)[i, j, k] for g, ax in ((gx, 0), (gy, 1), (gz, 2)))
print(f"numerical laplacian at P = {float(lap):.2f} V/m^2")E = (-100*C.x*C.y)*C.i + (-50*C.x**2)*C.j + (-20)*C.k
curl E = 0
laplacian V = 100*C.y
E at P = [100.0, -50.0, -20.0] V/m, |E| = 113.6
div D (cylinder) = rho_v0
curl H (wire) = (I/(pi*a**2))*Cy.k
numerical E at P = [100.0, -50.0, -20.0]
numerical laplacian at P = -100.00 V/m^2
The symbolic curl of inside the wire comes out as along : exactly the current density. That is Ampère's law in point form, , met properly in Ampère's Circuital Law: H and B. The divergence of inside the charged cylinder is the charge density : Gauss's law in point form. Central differences reproduce the gradient of a quadratic exactly; for real data the error grows with and with noise.
Guided lab: a field from a potential
Hand calculation. Two point charges sit at . At each is away. Each contributes ; the parts cancel and the parts add: along . The gradient of gives the same, since .
Simulation. In the lab the probe sits at . It reads at (the lab uses , which changes the third figure only). Drag the probe: the field arrow is always tangent to a line, and the lines only start and end on the charges, the only places where .
What you would measure. You cannot safely hold nanocoulombs still, but the same mathematics works for a current-carrying resistive sheet (conductive paper, or the resistive layer of an old touch panel) with two electrodes held at and by a current-limited bench supply. Measure with a multimeter at two points apart along a line, and estimate . With a probe position error and meter resolution, a difference gives ; the position error dominates. Repeat at right angles to get both components of the gradient. Mapping the whole sheet is the lab in Electric Potential and the Gradient Relation.
Hazards and safe setup. Bench supply at with the current limit at ; nothing else.
Pitfalls
- Cartesian formulas in curvilinear coordinates. is , not . The field has zero divergence (away from the axis) even though falls with .
- Sign of the field. points downhill, from high to low potential.
- Divergence is a scalar, curl a vector. Writing with a unit vector, or as a number, is a sign of a mix-up.
- Numerical derivatives of noisy data. Differentiation amplifies noise; differentiate twice (a Laplacian) and it gets much worse. Smooth or fit first.
Practice
- Find for (cylindrical).
- Find for , .
- Is the gradient of any scalar? Compute its curl.
- Show that satisfies Laplace's equation.
Answer
- .
- : no charge away from the point charge.
- , so it is not a gradient (it circulates clockwise seen from ).
- .
Test yourself
The gradient of the potential at a point is…
- parallel to the equipotential surface
- perpendicular to the equipotential surface, pointing towards higher
- perpendicular to the equipotential surface, pointing towards lower
- always zero in empty space
Which identity explains why a static electric field can be written as ?
For (V, m), the electric field at is…
In cylindrical coordinates, the divergence of for is…