2.1 Partial derivatives and the gradient

Once a quantity depends on more than one variable — pressure p(x,y,z,t)p(x, y, z, t), velocity v(x,y,z,t)\mathbf{v}(x, y, z, t), temperature in a metal bar T(x,y,z,t)T(x, y, z, t) — we need partial derivatives. The single-variable derivative from Foundations 1.1 generalises naturally: differentiate with respect to one variable while holding the others fixed. The vector of all such partial derivatives is the gradient, the first vector operator we need.

This lesson develops partial derivatives, the total differential, the gradient, and the directional derivative that ties the gradient to a geometric “steepest ascent” interpretation.

Partial derivatives

A partial derivative measures the rate of change of a multivariate function with respect to one variable while holding the others fixed:

fx  =  limh0f(x+h,y,z,t)f(x,y,z,t)h.\frac{\partial f}{\partial x} \;=\; \lim_{h \to 0} \frac{f(x+h, y, z, t) - f(x, y, z, t)}{h}.

The notation \partial (instead of dd) is a reminder that other variables are sitting still — the partial derivative differs from the total derivative when those other variables themselves depend on xx through some implicit relation. For most of physics the distinction is mainly bookkeeping; you write \partial when there’s any possibility of confusion.

Mixed partials commute for smooth ff:

2fxy  =  2fyx.\frac{\partial^2 f}{\partial x \partial y} \;=\; \frac{\partial^2 f}{\partial y \partial x}.

(Strictly: this holds for ff with continuous second derivatives. Almost every physical field satisfies the condition, and we will use the identity without worrying.) Commutativity matters: it is the algebraic fact that drives the ×(ϕ)=0\nabla \times (\nabla\phi) = 0 identity in the next lesson, and it underlies the existence of energy and entropy as state functions in thermodynamics.

Visualising vector fields

Before getting to the gradient, an interactive that lets you build intuition for the four canonical 2-D vector fields we’ll see throughout this chapter.

at probe (0.60, 0.30):

F(0.60, 0.30)
∇·F2.00
(∇×F)z0.00

Every point flows outward from the origin. Divergence = 2 everywhere (source). Curl = 0 (irrotational).

field:

The interactive demonstrates the three first-order vector operators on four canonical 2-D fields. Pick a field, slide the probe to any point, and read off the values of F\mathbf{F}, F\nabla \cdot \mathbf{F}, and (×F)z(\nabla \times \mathbf{F})_z there. The visual signature of each operator is worth absorbing:

We develop divergence and curl properly in 2.2; for now, focus on the gradient arrow, which is the topic of this lesson.

Small increments: the total differential

A first-order Taylor expansion (Foundations 1.3) of a multivariate function around a base point reads

df  =  fxdx  +  fydy  +  fzdz  +  ftdt.df \;=\; \frac{\partial f}{\partial x}\, dx \;+\; \frac{\partial f}{\partial y}\, dy \;+\; \frac{\partial f}{\partial z}\, dz \;+\; \frac{\partial f}{\partial t}\, dt.

This is the total differential — the linear approximation to how ff changes when all its inputs change by infinitesimal amounts. It is the multivariate analogue of df=f(x)dxdf = f'(x)\, dx from single-variable calculus.

This identity is doing real work throughout the Sound book whenever we linearise an equation around equilibrium. For instance, the speed of sound emerges from dp=(p/ρ)sdρdp = (\partial p / \partial \rho)_s\, d\rho — a one-line Taylor expansion of pressure-as-a-function-of-density at constant entropy. The wave equation’s adiabatic equation of state (Sound 4.4) is exactly this small-increment statement.

The gradient

φ = x² + y²
field:

∇φ = (1.60, 0.80), |∇φ| = 1.79 — the gradient arrow is *perpendicular to the local contour* and points in the direction of steepest ascent.

The interactive shows a scalar field φ(x,y)\varphi(x, y) as a contour plot, with the gradient φ\nabla\varphi drawn as a red arrow at a movable probe point. Two things to absorb:

For a scalar field ϕ(r)\phi(\mathbf{r}), the gradient is the vector of partial derivatives:

  ϕ  =  (ϕx,  ϕy,  ϕz).  \boxed{\;\nabla \phi \;=\; \left( \frac{\partial \phi}{\partial x},\; \frac{\partial \phi}{\partial y},\; \frac{\partial \phi}{\partial z} \right).\;}

It points in the direction of steepest increase of ϕ\phi; its magnitude is the rate of increase in that direction. Physically: the gradient of pressure points from high to low pressure (with a minus sign supplied by the dynamics), and that gradient is the force per unit volume on a fluid element.

The operator =(x,y,z)\nabla = (\partial_x, \partial_y, \partial_z) on its own is called del or nabla. Acting on a scalar field it produces a vector (the gradient). Acting on a vector field via the dot product, it produces a scalar (the divergence — next lesson). Acting via the cross product, it produces a vector (the curl — next lesson). The same operator, three different operations.

Directional derivative

The gradient encodes more than just “steepest ascent.” It also tells you the rate of change in any chosen direction.

The directional derivative of ϕ\phi at a point r\mathbf{r} in direction u^\hat{\mathbf{u}} (a unit vector) is

Du^ϕ  =  ϕu^  =  ϕcosθ,D_{\hat u}\, \phi \;=\; \nabla \phi \cdot \hat{\mathbf{u}} \;=\; |\nabla\phi|\, \cos\theta,

where θ\theta is the angle between u^\hat{\mathbf{u}} and ϕ\nabla\phi. Three things follow:

∇fûf(x, y) = x² + y²∇f direction∇f · û as û rotates180°360°∇f = (2.00, 1.00), |∇f| = 2.24, ∇f·û = 2.23
field:

The directional derivative of f at a point r in direction û is Dûf = ∇f · û = |∇f| cos φ, where φ is the angle between ∇f and û. Drag the black probe to choose a point; slide θ to rotate the blue direction arrow. The right panel plots ∇f · û as a function of θ — a cosine of amplitude |∇f|, peaked at the gradient direction (red dashed line) and zero perpendicular. This is what "the gradient points in the direction of steepest ascent" means quantitatively: among all unit directions, the gradient gives the largest directional derivative.

Pick a scalar field, drag the probe to a point, and slide the angle θ\theta. The blue arrow is the unit direction u^\hat{\mathbf{u}}; the red arrow is the gradient ϕ\nabla\phi at that point. The right panel plots ϕu^\nabla\phi \cdot \hat{\mathbf{u}} as a function of θ\theta — a cosine of amplitude ϕ|\nabla\phi|, peaked at the gradient direction (red dashed) and zero perpendicular. The whole “gradient is steepest ascent” claim is exactly this cosine.

What’s next

The next lesson, 2.2 — Divergence and curl, develops the two operators that act on vector fields (rather than scalar). Divergence measures outflow per unit volume; curl measures local rotation. Both are essential to fluid dynamics and electromagnetism — and to the wave equation that comes out of them.