Home / Articles / Advanced Topics
Advanced Topics · 5 min read

Vector Calculus: Gradient, Divergence and Curl

Master gradient, divergence and curl with clear physical meanings, the del operator, key identities and fully worked examples including the divergence theorem.

Gradient, divergence and curl are the three main operations of vector calculus. They describe how quantities like temperature, fluid flow and electric fields change in space, and they appear in every course on electromagnetism, fluid mechanics and engineering mathematics. This article explains what each one means physically and how to calculate it, with fully worked examples.

Scalar Fields and Vector Fields

A scalar field assigns a single number to each point in space, for example temperature \( T(x, y, z) \) in a room or height \( h(x, y) \) on a map.

A vector field assigns a vector to each point, for example the velocity \( \mathbf{v}(x, y, z) \) of water in a river or the electric field \( \mathbf{E} \) around a charge. We write

$$ \mathbf{F} = P\,\mathbf{i} + Q\,\mathbf{j} + R\,\mathbf{k} $$

where \( P, Q, R \) are functions of \( x, y, z \).

The Del Operator

All three operations use the vector differential operator del (or nabla):

$$ \nabla = \mathbf{i}\frac{\partial}{\partial x} + \mathbf{j}\frac{\partial}{\partial y} + \mathbf{k}\frac{\partial}{\partial z} $$

Combine it with fields in three ways:

Operation Acts on Formula Result
Gradient Scalar \( f \) \( \nabla f \) Vector
Divergence Vector \( \mathbf{F} \) \( \nabla \cdot \mathbf{F} \) Scalar
Curl Vector \( \mathbf{F} \) \( \nabla \times \mathbf{F} \) Vector

Gradient: The Direction of Steepest Climb

For a scalar field \( f \),

$$ \nabla f = \frac{\partial f}{\partial x}\mathbf{i} + \frac{\partial f}{\partial y}\mathbf{j} + \frac{\partial f}{\partial z}\mathbf{k} $$

Meaning: \( \nabla f \) points in the direction in which \( f \) increases fastest, and its magnitude is that maximum rate of increase. It is always perpendicular to the level surfaces (contours) of \( f \). On a hill, the gradient of height points straight uphill.

The rate of change in the direction of a unit vector \( \hat{\mathbf{u}} \) is the directional derivative \( D_{\hat{\mathbf{u}}} f = \nabla f \cdot \hat{\mathbf{u}} \).

Worked Example 1: Gradient and directional derivative

Problem: Let \( f(x, y, z) = x^2 y + yz \). Find \( \nabla f \) at \( (1, 2, 3) \), the maximum rate of increase there, and the rate of change in the direction of \( \mathbf{a} = 2\mathbf{i} + \mathbf{j} + 2\mathbf{k} \).

Step 1. Partial derivatives:

$$ \frac{\partial f}{\partial x} = 2xy, \qquad \frac{\partial f}{\partial y} = x^2 + z, \qquad \frac{\partial f}{\partial z} = y $$

Step 2. Substitute \( (1, 2, 3) \):

$$ \nabla f = 2(1)(2)\,\mathbf{i} + (1 + 3)\,\mathbf{j} + 2\,\mathbf{k} = 4\mathbf{i} + 4\mathbf{j} + 2\mathbf{k} $$

Step 3. Maximum rate of increase:

$$ |\nabla f| = \sqrt{16 + 16 + 4} = \sqrt{36} = 6 $$

Step 4. Unit vector along \( \mathbf{a} \): \( |\mathbf{a}| = \sqrt{4 + 1 + 4} = 3 \), so \( \hat{\mathbf{u}} = \tfrac{1}{3}(2, 1, 2) \).

Step 5. Directional derivative:

$$ D_{\hat{\mathbf{u}}} f = (4, 4, 2) \cdot \tfrac{1}{3}(2, 1, 2) = \tfrac{1}{3}(8 + 4 + 4) = \tfrac{16}{3} \approx 5.33 $$

Check: \( 5.33 < 6 \), as it must be, since no direction beats the gradient direction.

Divergence: Sources and Sinks

For \( \mathbf{F} = P\mathbf{i} + Q\mathbf{j} + R\mathbf{k} \),

$$ \nabla \cdot \mathbf{F} = \frac{\partial P}{\partial x} + \frac{\partial Q}{\partial y} + \frac{\partial R}{\partial z} $$

Meaning: divergence measures how much a field spreads out from a point, the net outflow per unit volume. If \( \mathbf{F} \) is fluid velocity:

  • \( \nabla \cdot \mathbf{F} > 0 \): a source (fluid is being created or expanding, like air heated in a balloon).
  • \( \nabla \cdot \mathbf{F} < 0 \): a sink (fluid is draining or compressing).
  • \( \nabla \cdot \mathbf{F} = 0 \): the field is incompressible or solenoidal, like water flowing in a pipe.

Gauss's law in electromagnetism, \( \nabla \cdot \mathbf{E} = \rho / \varepsilon_0 \), says electric charges are the sources of the electric field.

Curl: Rotation in a Field

$$ \nabla \times \mathbf{F} = \begin{vmatrix} \mathbf{i} & \mathbf{j} & \mathbf{k} \\ \dfrac{\partial}{\partial x} & \dfrac{\partial}{\partial y} & \dfrac{\partial}{\partial z} \\ P & Q & R \end{vmatrix} = \left(\frac{\partial R}{\partial y} - \frac{\partial Q}{\partial z}\right)\mathbf{i} - \left(\frac{\partial R}{\partial x} - \frac{\partial P}{\partial z}\right)\mathbf{j} + \left(\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}\right)\mathbf{k} $$

Meaning: curl measures the local spinning of a field. Place a tiny paddle wheel in a flowing fluid: the curl's direction is the wheel's axis (by the right-hand rule) and its magnitude is twice the wheel's angular velocity. A field with zero curl is called irrotational.

Worked Example 2: Divergence and curl of two fields

Problem: Find the divergence and curl of (a) \( \mathbf{F} = x^2\mathbf{i} + xy\,\mathbf{j} + z\,\mathbf{k} \), and (b) \( \mathbf{G} = -y\,\mathbf{i} + x\,\mathbf{j} \).

(a) Step 1, divergence.

$$ \nabla \cdot \mathbf{F} = \frac{\partial (x^2)}{\partial x} + \frac{\partial (xy)}{\partial y} + \frac{\partial z}{\partial z} = 2x + x + 1 = 3x + 1 $$

At \( (1, 1, 1) \) this is 4, so that point acts as a source.

(a) Step 2, curl. With \( P = x^2,\ Q = xy,\ R = z \):

  • \( \mathbf{i} \): \( \frac{\partial z}{\partial y} - \frac{\partial (xy)}{\partial z} = 0 - 0 = 0 \)
  • \( \mathbf{j} \): \( -\left(\frac{\partial z}{\partial x} - \frac{\partial (x^2)}{\partial z}\right) = -(0 - 0) = 0 \)
  • \( \mathbf{k} \): \( \frac{\partial (xy)}{\partial x} - \frac{\partial (x^2)}{\partial y} = y - 0 = y \)

$$ \nabla \times \mathbf{F} = y\,\mathbf{k} $$

(b) Step 1, divergence.

$$ \nabla \cdot \mathbf{G} = \frac{\partial (-y)}{\partial x} + \frac{\partial x}{\partial y} + 0 = 0 $$

(b) Step 2, curl. Only the \( \mathbf{k} \) component survives:

$$ \nabla \times \mathbf{G} = \left(\frac{\partial x}{\partial x} - \frac{\partial (-y)}{\partial y}\right)\mathbf{k} = (1 + 1)\mathbf{k} = 2\mathbf{k} $$

Interpretation: \( \mathbf{G} \) describes rigid anticlockwise rotation with angular velocity 1 rad/s about the \( z \)-axis. It has no sources (divergence 0) and uniform spin (curl \( 2\mathbf{k} \), twice the angular velocity), exactly as the paddle-wheel picture predicts.

Two Essential Identities

For any smooth scalar \( f \) and vector field \( \mathbf{F} \):

$$ \nabla \times (\nabla f) = \mathbf{0}, \qquad \nabla \cdot (\nabla \times \mathbf{F}) = 0 $$

The first says gradient fields never rotate, which is why conservative forces like gravity have zero curl. The second says a curl field has no sources, which is why magnetic fields, written \( \mathbf{B} = \nabla \times \mathbf{A} \), satisfy \( \nabla \cdot \mathbf{B} = 0 \). Also, \( \nabla \cdot (\nabla f) = \nabla^2 f \) is the Laplacian, central to heat flow and wave equations.

Worked Example 3: Verifying the Divergence Theorem

The divergence theorem (Gauss's theorem) states that the total outward flux through a closed surface equals the integral of the divergence inside:

$$ \iint_S \mathbf{F} \cdot \hat{\mathbf{n}}\,dS = \iiint_V \nabla \cdot \mathbf{F}\,dV $$

Problem: Verify it for \( \mathbf{F} = x\mathbf{i} + y\mathbf{j} + z\mathbf{k} \) over the sphere of radius 1 centred at the origin.

Step 1 (volume side). \( \nabla \cdot \mathbf{F} = 1 + 1 + 1 = 3 \), a constant. So

$$ \iiint_V 3\,dV = 3 \times \frac{4}{3}\pi(1)^3 = 4\pi $$

Step 2 (surface side). On the unit sphere the outward normal is \( \hat{\mathbf{n}} = (x, y, z) \), so \( \mathbf{F} \cdot \hat{\mathbf{n}} = x^2 + y^2 + z^2 = 1 \). Then

$$ \iint_S 1\,dS = \text{surface area} = 4\pi(1)^2 = 4\pi $$

Step 3. Both sides equal \( 4\pi \approx 12.57 \). The theorem checks out.

Where You Will Use These Ideas

  • Heat transfer: heat flows down the temperature gradient, \( \mathbf{q} = -k\nabla T \), which is Fourier's law.
  • Fluid mechanics: conservation of mass for an incompressible fluid is simply \( \nabla \cdot \mathbf{v} = 0 \), and the curl of velocity, called vorticity, describes whirlpools and wingtip vortices.
  • Electromagnetism: all four of Maxwell's equations are statements about the divergence and curl of \( \mathbf{E} \) and \( \mathbf{B} \).
  • Machine learning: gradient descent trains neural networks by repeatedly stepping opposite to the gradient of an error function.

Did You Know?

  • The symbol \( \nabla \) was named "nabla" after a Greek-Phoenician harp of a similar shape; the name was suggested in the 1870s and used by Peter Guthrie Tait.
  • Josiah Willard Gibbs and Oliver Heaviside developed modern vector notation in the 1880s, rewriting Maxwell's equations into the four compact forms engineers use today.
  • Stokes' theorem, relating curl to circulation around a loop, first appeared as a Cambridge exam question set by George Stokes in 1854.

Key Takeaways

  • The gradient \( \nabla f \) points in the direction of steepest increase of a scalar field, with magnitude equal to that rate.
  • Divergence \( \nabla \cdot \mathbf{F} \) measures the net outflow per unit volume: positive for sources, negative for sinks.
  • Curl \( \nabla \times \mathbf{F} \) measures local rotation; rigid rotation at angular velocity \( \omega \) has curl \( 2\omega \).
  • The curl of a gradient is zero and the divergence of a curl is zero.
  • The divergence theorem links surface flux to volume integrals of divergence.

Struggling with vector calculus, Maxwell's equations or fluid mechanics assignments? Amathify's experts and PhD scholars provide step-by-step solutions, contact us on WhatsApp or through the Ask a Question form.

Stuck on a problem or assignment?

Our experts and PhD scholars solve maths, physics and chemistry — step by step.

WhatsApp usAsk a question

Related articles