TExcelTAD
Home › Electromagnetic Theory: Maxwell's Equations to Waves › Gradient, Divergence, Curl and the Laplacian

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 (E=−∇V\mathbf{E} = -\nabla V), the divergence measures how much a field spreads out of a point (∇⋅D=ρv\nabla \cdot \mathbf{D} = \rho_v), and the curl measures how much it circulates around a point (∇×H=J\nabla \times \mathbf{H} = \mathbf{J}). 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

8 V 6 V 4 V 2 V grad V E = -grad V gradient rho_v > 0 divergence turns curl
  • Gradient of a scalar such as the potential VV: a vector that points in the direction in which VV rises fastest, with a magnitude equal to that rate of rise (volts per metre). It is perpendicular to the surfaces of constant VV. 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 D\mathbf{D}.
  • 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 E\mathbf{E} has no curl; H\mathbf{H} curls around currents.

The formulas

The operator ∇=x^ ∂x+y^ ∂y+z^ ∂z\nabla = \hat{\mathbf{x}}\,\partial_x + \hat{\mathbf{y}}\,\partial_y + \hat{\mathbf{z}}\,\partial_z works directly only in Cartesian coordinates:

∇V=∂V∂xx^+∂V∂yy^+∂V∂zz^,∇⋅A=∂Ax∂x+∂Ay∂y+∂Az∂z\nabla V = \frac{\partial V}{\partial x}\hat{\mathbf{x}} + \frac{\partial V}{\partial y}\hat{\mathbf{y}} + \frac{\partial V}{\partial z}\hat{\mathbf{z}}, \qquad \nabla \cdot \mathbf{A} = \frac{\partial A_x}{\partial x} + \frac{\partial A_y}{\partial y} + \frac{\partial A_z}{\partial z}
∇×A=(∂Az∂y−∂Ay∂z)x^+(∂Ax∂z−∂Az∂x)y^+(∂Ay∂x−∂Ax∂y)z^\nabla \times \mathbf{A} = \left(\frac{\partial A_z}{\partial y} - \frac{\partial A_y}{\partial z}\right)\hat{\mathbf{x}} + \left(\frac{\partial A_x}{\partial z} - \frac{\partial A_z}{\partial x}\right)\hat{\mathbf{y}} + \left(\frac{\partial A_y}{\partial x} - \frac{\partial A_x}{\partial y}\right)\hat{\mathbf{z}}

In cylindrical and spherical coordinates the scale factors ρ\rho, rr and rsin⁡θr\sin\theta enter, because the unit vectors and element sizes change with position. The forms used most often in this course are

∇V=∂V∂ρρ^+1ρ∂V∂ϕϕ^+∂V∂zz^,∇V=∂V∂rr^+1r∂V∂θθ^+1rsin⁡θ∂V∂ϕϕ^∇⋅A=1ρ∂(ρAρ)∂ρ+1ρ∂Aϕ∂ϕ+∂Az∂z,∇⋅A=1r2∂(r2Ar)∂r+1rsin⁡θ∂(sin⁡θ Aθ)∂θ+1rsin⁡θ∂Aϕ∂ϕ\begin{aligned} \nabla V &= \frac{\partial V}{\partial \rho}\hat{\boldsymbol{\rho}} + \frac{1}{\rho}\frac{\partial V}{\partial \phi}\hat{\boldsymbol{\phi}} + \frac{\partial V}{\partial z}\hat{\mathbf{z}}, & \nabla V &= \frac{\partial V}{\partial r}\hat{\mathbf{r}} + \frac{1}{r}\frac{\partial V}{\partial \theta}\hat{\boldsymbol{\theta}} + \frac{1}{r\sin\theta}\frac{\partial V}{\partial \phi}\hat{\boldsymbol{\phi}} \\ \nabla \cdot \mathbf{A} &= \frac{1}{\rho}\frac{\partial (\rho A_\rho)}{\partial \rho} + \frac{1}{\rho}\frac{\partial A_\phi}{\partial \phi} + \frac{\partial A_z}{\partial z}, & \nabla \cdot \mathbf{A} &= \frac{1}{r^2}\frac{\partial (r^2 A_r)}{\partial r} + \frac{1}{r\sin\theta}\frac{\partial (\sin\theta\, A_\theta)}{\partial \theta} + \frac{1}{r\sin\theta}\frac{\partial A_\phi}{\partial \phi} \end{aligned}

and, for a field that only circles the zz axis (A=Aϕ(ρ)ϕ^\mathbf{A} = A_\phi(\rho)\hat{\boldsymbol{\phi}}, the magnetic field of a wire), ∇×A=1ρd(ρAϕ)dρz^\nabla \times \mathbf{A} = \frac{1}{\rho}\frac{d(\rho A_\phi)}{d\rho}\hat{\mathbf{z}}. The full curl in curvilinear coordinates is on the formula sheet of Vector Calculus Summary.

The Laplacian is the divergence of the gradient, ∇2V=∇⋅∇V\nabla^2 V = \nabla \cdot \nabla V; in Cartesian coordinates ∂x2V+∂y2V+∂z2V\partial_x^2 V + \partial_y^2 V + \partial_z^2 V. It measures how much VV 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:

∇×(∇V)=0,∇⋅(∇×A)=0\nabla \times (\nabla V) = 0, \qquad \nabla \cdot (\nabla \times \mathbf{A}) = 0

The first says a field derived from a potential has no curl, which is why electrostatic E\mathbf{E} can be written as −∇V-\nabla V. The second says a field that is the curl of something has no divergence, which is why B=∇×A\mathbf{B} = \nabla \times \mathbf{A} has no sources (Magnetic Flux and the Vector Potential).

Worked example

Given: in a region of space the potential is V(x,y,z)=50x2y+20zV(x, y, z) = 50x^2y + 20z volts, with x,y,zx, y, z in metres.

Find: E\mathbf{E} and ∣E∣\lvert \mathbf{E} \rvert at P(1,−1,2) mP(1, -1, 2)\ \text{m}, the curl of E\mathbf{E}, and the charge density at PP (anticipating ρv=−ε0∇2V\rho_v = -\varepsilon_0 \nabla^2 V in free space).

Solve:

∇V=100xy x^+50x2 y^+20 z^ V/mE(P)=−∇V=100 x^−50 y^−20 z^ V/m,∣E∣=1002+502+202=113.6 V/m∇×E=(0−0)x^+(0−0)y^+(−100x+100x)z^=0∇2V=100y=−100 V/m2 at P,ρv=−ε0∇2V=8.854×10−12⋅100=8.85×10−10 C/m3\begin{aligned} \nabla V &= 100xy\,\hat{\mathbf{x}} + 50x^2\,\hat{\mathbf{y}} + 20\,\hat{\mathbf{z}}\ \text{V/m} \\ \mathbf{E}(P) &= -\nabla V = 100\,\hat{\mathbf{x}} - 50\,\hat{\mathbf{y}} - 20\,\hat{\mathbf{z}}\ \text{V/m}, \qquad \lvert \mathbf{E} \rvert = \sqrt{100^2 + 50^2 + 20^2} = 113.6\ \text{V/m} \\ \nabla \times \mathbf{E} &= \left(0 - 0\right)\hat{\mathbf{x}} + \left(0 - 0\right)\hat{\mathbf{y}} + \left(-100x + 100x\right)\hat{\mathbf{z}} = 0 \\ \nabla^2 V &= 100y = -100\ \text{V/m}^2 \text{ at } P, \qquad \rho_v = -\varepsilon_0\nabla^2 V = 8.854 \times 10^{-12} \cdot 100 = 8.85 \times 10^{-10}\ \text{C/m}^3 \end{aligned}

Check: the curl is zero as the first identity demands. Units: V/m2⋅F/m=C/m3\text{V/m}^2 \cdot \text{F/m} = \text{C/m}^3. The charge density is tiny, as it always is for everyday potentials: a nanocoulomb per cubic metre bends the potential by 100 V/m2100\ \text{V/m}^2.

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.

python · try it yourself
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 H\mathbf{H} inside the wire comes out as I/(πa2)I/(\pi a^2) along z^\hat{\mathbf{z}}: exactly the current density. That is Ampère's law in point form, ∇×H=J\nabla \times \mathbf{H} = \mathbf{J}, met properly in Ampère's Circuital Law: H and B. The divergence of D\mathbf{D} inside the charged cylinder is the charge density ρv0\rho_{v0}: Gauss's law in point form. Central differences reproduce the gradient of a quadratic exactly; for real data the error grows with h2h^2 and with noise.

Guided lab: a field from a potential

Hand calculation. Two point charges ±2 nC\pm 2\ \text{nC} sit at x=∓4 cmx = \mp 4\ \text{cm}. At (0,3) cm(0, 3)\ \text{cm} each is 5 cm5\ \text{cm} away. Each contributes kq/r2=8.988×109⋅2×10−9/0.052=7190 N/Ckq/r^2 = 8.988 \times 10^9 \cdot 2 \times 10^{-9}/0.05^2 = 7190\ \text{N/C}; the yy parts cancel and the xx parts add: E=2⋅7190⋅0.8=1.15×104 N/CE = 2 \cdot 7190 \cdot 0.8 = 1.15 \times 10^4\ \text{N/C} along +x+x. The gradient of V=kq/r1−kq/r2V = kq/r_1 - kq/r_2 gives the same, since E=−∇V\mathbf{E} = -\nabla V.

Simulation. In the lab the probe sits at (0,3) cm(0, 3)\ \text{cm}. It reads E=1.15×104 N/CE = 1.15 \times 10^4\ \text{N/C} at 0∘0^\circ (the lab uses k=9.0×109k = 9.0 \times 10^9, 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 ∇⋅E≠0\nabla \cdot \mathbf{E} \ne 0.

+−lines start on + and end on −E+q₀

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 00 and 10 V10\ \text{V} by a current-limited bench supply. Measure VV with a multimeter at two points Δs=10 mm\Delta s = 10\ \text{mm} apart along a line, and estimate E≈ΔV/ΔsE \approx \Delta V/\Delta s. With a ±1 mm\pm 1\ \text{mm} probe position error and ±0.01 V\pm 0.01\ \text{V} meter resolution, a 0.5 V0.5\ \text{V} difference gives E=50 V/m±10 %E = 50\ \text{V/m} \pm 10\ \%; 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 10 V10\ \text{V} with the current limit at 20 mA20\ \text{mA}; nothing else.

Pitfalls

  • Cartesian formulas in curvilinear coordinates. ∇⋅(Aρρ^)\nabla \cdot (A_\rho\hat{\boldsymbol{\rho}}) is 1ρ∂(ρAρ)∂ρ\frac{1}{\rho}\frac{\partial(\rho A_\rho)}{\partial\rho}, not ∂Aρ∂ρ\frac{\partial A_\rho}{\partial\rho}. The field ρ^/ρ\hat{\boldsymbol{\rho}}/\rho has zero divergence (away from the axis) even though AρA_\rho falls with ρ\rho.
  • Sign of the field. E=−∇V\mathbf{E} = -\nabla V points downhill, from high to low potential.
  • Divergence is a scalar, curl a vector. Writing ∇⋅A\nabla \cdot \mathbf{A} with a unit vector, or ∇×A\nabla \times \mathbf{A} 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

  1. Find ∇V\nabla V for V=10ρ2sin⁡ϕV = 10\rho^2\sin\phi (cylindrical).
  2. Find ∇⋅D\nabla \cdot \mathbf{D} for D=Q4πr2r^\mathbf{D} = \frac{Q}{4\pi r^2}\hat{\mathbf{r}}, r>0r > 0.
  3. Is F=yx^−xy^\mathbf{F} = y\hat{\mathbf{x}} - x\hat{\mathbf{y}} the gradient of any scalar? Compute its curl.
  4. Show that V=x2−y2V = x^2 - y^2 satisfies Laplace's equation.
Answer
  1. ∇V=20ρsin⁡ϕ ρ^+10ρcos⁡ϕ ϕ^\nabla V = 20\rho\sin\phi\,\hat{\boldsymbol{\rho}} + 10\rho\cos\phi\,\hat{\boldsymbol{\phi}}.
  2. 1r2∂∂r(r2Q4πr2)=0\frac{1}{r^2}\frac{\partial}{\partial r}\left(r^2 \frac{Q}{4\pi r^2}\right) = 0: no charge away from the point charge.
  3. ∇×F=(−1−1)z^=−2z^≠0\nabla \times \mathbf{F} = (-1 - 1)\hat{\mathbf{z}} = -2\hat{\mathbf{z}} \ne 0, so it is not a gradient (it circulates clockwise seen from +z+z).
  4. ∂x2V+∂y2V=2−2=0\partial_x^2 V + \partial_y^2 V = 2 - 2 = 0.

Test yourself

The gradient of the potential at a point is…

  1. parallel to the equipotential surface
  2. perpendicular to the equipotential surface, pointing towards higher VV
  3. perpendicular to the equipotential surface, pointing towards lower VV
  4. always zero in empty space

Which identity explains why a static electric field can be written as −∇V-\nabla V?

  1. ∇⋅(∇×A)=0\nabla \cdot (\nabla \times \mathbf{A}) = 0
  2. ∇×(∇V)=0\nabla \times (\nabla V) = 0
  3. ∇2V=0\nabla^2 V = 0
  4. ∇⋅D=ρv\nabla \cdot \mathbf{D} = \rho_v

For V=50x2y+20zV = 50x^2y + 20z (V, m), the electric field at (1,−1,2) m(1, -1, 2)\ \text{m} is…

  1. −100x^+50y^+20z^ V/m-100\hat{\mathbf{x}} + 50\hat{\mathbf{y}} + 20\hat{\mathbf{z}}\ \text{V/m}
  2. 100x^−50y^−20z^ V/m100\hat{\mathbf{x}} - 50\hat{\mathbf{y}} - 20\hat{\mathbf{z}}\ \text{V/m}
  3. 100x^+50y^−20z^ V/m100\hat{\mathbf{x}} + 50\hat{\mathbf{y}} - 20\hat{\mathbf{z}}\ \text{V/m}
  4. −100x^−50y^+20z^ V/m-100\hat{\mathbf{x}} - 50\hat{\mathbf{y}} + 20\hat{\mathbf{z}}\ \text{V/m}

In cylindrical coordinates, the divergence of A=1ρρ^\mathbf{A} = \frac{1}{\rho}\hat{\boldsymbol{\rho}} for ρ>0\rho > 0 is…

  1. −1/ρ2-1/\rho^2
  2. 00
  3. 1/ρ1/\rho
  4. 1/ρ21/\rho^2