Directional Derivatives and Gradients

⚡ Key Takeaways

The directional derivative DufD_{\mathbf{u}}f measures the instantaneous rate of change of a scalar field ff as you move in a specified unit direction u\mathbf{u}. The gradient ∇f\nabla f is the vector of partial derivatives; it packages all directional rates at once, points in the direction of steepest ascent, and equals the maximum directional derivative in magnitude. Used everywhere in multivariable calculus, optimization, physics (potentials, fields), and machine learning. Formalized in the 19th century by Hamilton, Maxwell, and Gibbs.

💡 The Core Insight

The gradient is the linear map "rate of change" written as a vector. The directional derivative in any direction is just the projection of the gradient onto that direction. So the gradient is not one rate — it is the encoding of all rates simultaneously, and the geometry (steepest ascent, perpendicularity to level sets) falls out of the dot product ∇f⋅u=∣∇f∣cos⁡θ\nabla f\cdot\mathbf{u}=|\nabla f|\cos\theta.

Formal Statement

DefinitionDirectional Derivative

Let f:Rn→Rf:\mathbb{R}^n\to\mathbb{R} and let u∈Rn\mathbf{u}\in\mathbb{R}^n be a unit vector (∣u∣=1|\mathbf{u}|=1). The directional derivative of ff at the point a\mathbf{a} in the direction u\mathbf{u} is

1
Duf(a)  =  lim⁡h→0f(a+hu)−f(a)h.\quad D_{\mathbf{u}}f(\mathbf{a}) \;=\; \lim_{h\to 0}\frac{f(\mathbf{a}+h\mathbf{u})-f(\mathbf{a})}{h}.

Derivation hint: This is the ordinary single-variable derivative of the restriction g(h)=f(a+hu)g(h)=f(\mathbf{a}+h\mathbf{u}) evaluated at h=0h=0; the path is the straight line through a\mathbf{a} with velocity u\mathbf{u}. Here a=(a1,…,an)\mathbf{a}=(a_1,\dots,a_n) is the base point, hh is a scalar step size, and u=(u1,…,un)\mathbf{u}=(u_1,\dots,u_n) specifies the direction. The result is a scalar: a rate of change of ff-value per unit distance traveled.

⚠️ Common mistake

The unit-length requirement on u\mathbf{u} is not cosmetic. If u\mathbf{u} is not normalized, the limit in [1][1] scales by ∣u∣|\mathbf{u}| and no longer measures "rate per unit distance." Some texts define DvfD_{\mathbf{v}}f for arbitrary v\mathbf{v} as ∇f⋅v\nabla f\cdot\mathbf{v} (the "Gâteaux" convention); this is linear in v\mathbf{v} but only equals geometric rate-of-change when ∣v∣=1|\mathbf{v}|=1. Always check the convention.

DefinitionGradient

The gradient of a differentiable function f:Rn→Rf:\mathbb{R}^n\to\mathbb{R} at a\mathbf{a} is the vector of first-order partial derivatives:

2
∇f(a)  =  (∂f∂x1(a), ∂f∂x2(a), …, ∂f∂xn(a)).\quad \nabla f(\mathbf{a}) \;=\; \left(\frac{\partial f}{\partial x_1}(\mathbf{a}),\,\frac{\partial f}{\partial x_2}(\mathbf{a}),\,\dots,\,\frac{\partial f}{\partial x_n}(\mathbf{a})\right).

Derivation hint: Each component is the directional derivative along a standard basis vector ei\mathbf{e}_i, i.e. ∂f/∂xi=Deif\partial f/\partial x_i = D_{\mathbf{e}_i}f. The symbol ∇\nabla ("nabla" or "del") is the formal operator ∇=(∂∂x1,…,∂∂xn)\nabla=\left(\tfrac{\partial}{\partial x_1},\dots,\tfrac{\partial}{\partial x_n}\right). The gradient is a vector field: at each point it returns a vector.

TheoremGradient Formula for the Directional Derivative

If ff is differentiable at a\mathbf{a}, then for every unit vector u\mathbf{u},

3
Duf(a)  =  ∇f(a)⋅u  =  ∑i=1n∂f∂xi(a) ui.\quad D_{\mathbf{u}}f(\mathbf{a}) \;=\; \nabla f(\mathbf{a})\cdot\mathbf{u} \;=\; \sum_{i=1}^{n}\frac{\partial f}{\partial x_i}(\mathbf{a})\,u_i.

Derivation hint: Apply the multivariable chain rule to g(h)=f(a+hu)g(h)=f(\mathbf{a}+h\mathbf{u}); differentiability guarantees the linear approximation is exact in the limit.

TheoremSteepest Ascent & Level-Set Orthogonality

Writing θ\theta for the angle between ∇f(a)\nabla f(\mathbf{a}) and u\mathbf{u},

4
Duf(a)  =  ∣∇f(a)∣ cos⁡θ.\quad D_{\mathbf{u}}f(\mathbf{a}) \;=\; |\nabla f(\mathbf{a})|\,\cos\theta.

Derivation hint: Expand the dot product in [3][3] using a⋅b=∣a∣∣b∣cos⁡θ\mathbf{a}\cdot\mathbf{b}=|\mathbf{a}||\mathbf{b}|\cos\theta and ∣u∣=1|\mathbf{u}|=1. Consequences: (i) the maximum value ∣∇f∣|\nabla f| occurs at θ=0\theta=0, so ∇f\nabla f points in the direction of steepest ascent; (ii) the minimum −∣∇f∣-|\nabla f| occurs at θ=π\theta=\pi (steepest descent); (iii) Duf=0D_{\mathbf{u}}f=0 when θ=π/2\theta=\pi/2, so ∇f\nabla f is orthogonal to the level set {f=c}\{f=c\} through a\mathbf{a}.

Why It Holds / Derivation

ProofThe Gradient Formula via the Chain Rule

We prove equation [3][3] for ff differentiable at a\mathbf{a}.

Step 1. Define the single-variable function g(h)=f(a+hu)g(h)=f(\mathbf{a}+h\mathbf{u}), a parametrization of the line through a\mathbf{a} with direction u\mathbf{u}. By [1][1], Duf(a)=g′(0)D_{\mathbf{u}}f(\mathbf{a})=g'(0).

Step 2. The components of the path are xi(h)=ai+huix_i(h)=a_i+h u_i, so dxidh=ui\dfrac{dx_i}{dh}=u_i.

Step 3. Because ff is differentiable at a\mathbf{a}, the multivariable chain rule applies:

5
g′(h)=∑i=1n∂f∂xi(a+hu) dxidh=∑i=1n∂f∂xi(a+hu) ui.\quad g'(h)=\sum_{i=1}^{n}\frac{\partial f}{\partial x_i}\big(\mathbf{a}+h\mathbf{u}\big)\,\frac{dx_i}{dh}=\sum_{i=1}^{n}\frac{\partial f}{\partial x_i}\big(\mathbf{a}+h\mathbf{u}\big)\,u_i.

Derivation hint: This is the chain rule for f∘γf\circ\boldsymbol{\gamma} with γ(h)=a+hu\boldsymbol{\gamma}(h)=\mathbf{a}+h\mathbf{u}; valid precisely because differentiability gives a single good linear approximation.

Step 4. Evaluate at h=0h=0:

6
g′(0)=∑i=1n∂f∂xi(a) ui=∇f(a)⋅u.\quad g'(0)=\sum_{i=1}^{n}\frac{\partial f}{\partial x_i}(\mathbf{a})\,u_i=\nabla f(\mathbf{a})\cdot\mathbf{u}.

Derivation hint: Set h=0h=0 so a+hu=a\mathbf{a}+h\mathbf{u}=\mathbf{a}; recognize the sum as a dot product. This is exactly [3][3]. ■\blacksquare

∎
⚠️ Common mistake

The proof requires differentiability, not merely existence of partial derivatives. A function can have all partial derivatives (even all directional derivatives) at a point yet fail to be differentiable, in which case formula [3][3] can be false. See the counterexample below.

JW
Josiah Willard Gibbs
1839–1903

The American mathematical physicist J. W. Gibbs, working at Yale, developed modern vector analysis in the 1880s in his privately printed lecture notes Elements of Vector Analysis. He (alongside Oliver Heaviside) extracted the practical "del" operator and the gradient/divergence/curl trio from Hamilton's heavier quaternion machinery, giving the gradient its present notation and dot-product interpretation. His student E. B. Wilson popularized it in the textbook Vector Analysis (1901), which is essentially the form taught today.

Building Intuition

🧠 Intuition

Picture ff as the elevation of a hilly landscape, with (x,y)(x,y) the map coordinates and f(x,y)f(x,y) the height. Standing at a point, you can face any compass direction u\mathbf{u} and ask "how steep is the slope if I walk this way?" — that number is DufD_{\mathbf{u}}f. Now the magic: there is one special direction in which the ground rises fastest. That direction is ∇f\nabla f, and its length tells you how steep that fastest climb is. Walk at right angles to ∇f\nabla f and you stay at the same elevation — you're walking along a contour line (a level set). Walk directly opposite to ∇f\nabla f and you descend fastest. Every other direction gives a slope equal to the steepest slope times cos⁡θ\cos\theta, the cosine "shadow" of full steepness — exactly equation [4][4]. This is why hiking trails zig-zag: walking perpendicular-ish to the gradient gives a gentle grade.

Figure
Gradient points to steepest ascent and is perpendicular to level curves
P ∇f u (Dᵤf=0) arbitrary u, θ Contours = level sets {f = c}; ∇f ⟂ contour, into rising terrain.

Worked Examples

ExampleDirectional Derivative of a Paraboloid

Given: f(x,y)=x2+3xy+y2f(x,y)=x^2+3xy+y^2, at the point a=(1,2)\mathbf{a}=(1,2), in the direction toward (4,6)(4,6).

Step 1 — Gradient. ∂f∂x=2x+3y\dfrac{\partial f}{\partial x}=2x+3y, ∂f∂y=3x+2y\dfrac{\partial f}{\partial y}=3x+2y. At (1,2)(1,2):

7
∇f(1,2)=(2(1)+3(2), 3(1)+2(2))=(8, 7).\quad \nabla f(1,2)=(2(1)+3(2),\,3(1)+2(2))=(8,\,7).

Derivation hint: Apply [2][2]; differentiate treating the other variable as constant.

Step 2 — Unit direction. Displacement (4,6)−(1,2)=(3,4)(4,6)-(1,2)=(3,4), length 32+42=5\sqrt{3^2+4^2}=5, so u=(3/5, 4/5)\mathbf{u}=(3/5,\,4/5).

Step 3 — Dot product (apply [3][3]).

8
Duf(1,2)=(8,7)⋅(35,45)=245+285=525.\quad D_{\mathbf{u}}f(1,2)=(8,7)\cdot\left(\tfrac35,\tfrac45\right)=\frac{24}{5}+\frac{28}{5}=\frac{52}{5}.

Derivation hint: Multiply componentwise and sum; this is the gradient formula in action.

Answer: Duf(1,2)=525=10.4 (units of f per unit length)\boxed{D_{\mathbf{u}}f(1,2)=\dfrac{52}{5}=10.4 \text{ (units of } f \text{ per unit length)}}

ExampleSteepest Ascent and Maximum Rate

Given: Temperature field T(x,y,z)=100 e−(x2+2y2+3z2)T(x,y,z)=100\,e^{-(x^2+2y^2+3z^2)} (°C), find the direction of fastest temperature increase at a=(1,1,0)\mathbf{a}=(1,1,0) and that maximum rate.

Step 1 — Gradient. Using chain rule, ∇T=100 e−(x2+2y2+3z2) (−2x, −4y, −6z)\nabla T=100\,e^{-(x^2+2y^2+3z^2)}\,(-2x,\,-4y,\,-6z).

Step 2 — Evaluate. At (1,1,0)(1,1,0), the exponent is −(1+2+0)=−3-(1+2+0)=-3, so e−3≈0.049787e^{-3}\approx0.049787:

9
∇T(1,1,0)=100 e−3 (−2, −4, 0)≈(−9.957, −19.915, 0) °C/unit.\quad \nabla T(1,1,0)=100\,e^{-3}\,(-2,\,-4,\,0)\approx(-9.957,\,-19.915,\,0)\ \text{°C/unit}.

Derivation hint: Multiply the scalar prefactor 100e−3100e^{-3} into each bracketed component.

Step 3 — Direction of steepest ascent is ∇T\nabla T itself; normalize: ∣∇T∣=100e−34+16=100e−320|\nabla T|=100e^{-3}\sqrt{4+16}=100e^{-3}\sqrt{20}.

10
∣∇T(1,1,0)∣=100e−3⋅25≈22.26 °C per unit length.\quad |\nabla T(1,1,0)|=100e^{-3}\cdot 2\sqrt5\approx 22.26\ \text{°C per unit length}.

Derivation hint: By [4][4], the maximum directional derivative equals the gradient's magnitude (take cos⁡θ=1\cos\theta=1).

Answer: Fastest warming is in the unit direction u=15(−1,−2,0)\boxed{\mathbf{u}=\tfrac{1}{\sqrt5}(-1,-2,0)} at the rate ≈22.3 °C per unit length\boxed{\approx 22.3\ \text{°C per unit length}}. (Physically: away from the origin's hot core, the field decays, so steepest ascent points back toward the peak.)

Common Misconceptions

⚠️ Common mistake

"The gradient is the slope." No — the gradient is a vector. Its magnitude is the slope of steepest ascent; its direction tells you which way that steepest climb lies. Confusing the vector ∇f\nabla f with the scalar DufD_{\mathbf{u}}f is the single most common error.

"Partial derivatives existing means ff is differentiable, so [3][3] holds." False. Differentiability is strictly stronger than partial-derivative existence. Formula [3][3] is guaranteed only under differentiability.

"The gradient lives in the same space as ff-values." The gradient lives in the domain (input) space, not the output. For f:R3→Rf:\mathbb{R}^3\to\mathbb{R}, ∇f\nabla f is a 3-vector tangent to the domain, never a 4-dimensional object.

:::counterexample[All Directional Derivatives Exist, Yet [3][3] Fails] Let

11
f(x,y)={x2yx4+y2,(x,y)≠(0,0)0,(x,y)=(0,0).\quad f(x,y)=\begin{cases}\dfrac{x^2 y}{x^4+y^2}, & (x,y)\neq(0,0)\\[4pt] 0,&(x,y)=(0,0).\end{cases}

Derivation hint: Substitute the line a+hu=(hu1,hu2)\mathbf{a}+h\mathbf{u}=(hu_1,hu_2) into ff and take the limit h→0h\to0 to compute each directional derivative directly. Along any line through the origin (x,y)=(hu1,hu2)(x,y)=(hu_1,hu_2) with u2≠0u_2\neq0:

f(hu1,hu2)=h3u12u2h4u14+h2u22=h u12u2h2u14+u22→h→00,f(hu_1,hu_2)=\frac{h^3u_1^2u_2}{h^4u_1^4+h^2u_2^2}=\frac{h\,u_1^2u_2}{h^2u_1^4+u_2^2}\xrightarrow[h\to0]{}0,

so Duf(0)=0D_{\mathbf{u}}f(\mathbf{0})=0 for every direction (the u2=0u_2=0 case also gives 00). If [3][3] held, we'd need ∇f(0)⋅u=0\nabla f(\mathbf 0)\cdot\mathbf u=0 for all u\mathbf u, forcing ∇f(0)=0\nabla f(\mathbf 0)=\mathbf 0 — consistent so far. But approaching along the parabola y=x2y=x^2 gives f=x2⋅x2x4+x4=12≠0=f(0)f=\frac{x^2\cdot x^2}{x^4+x^4}=\frac12\neq 0=f(\mathbf 0), so ff is not even continuous at the origin, hence not differentiable. The directional derivatives exist in every direction yet do not assemble into a valid linear gradient relation along curved paths. This shows the differentiability hypothesis in the theorem is essential.

Connections

connection

The directional derivative is the bridge between several structures:

  • It is the action of the <span class="wiki-link-missing">Total Derivative</span> (Jacobian/differential dfadf_{\mathbf a}) on a vector: Duf=dfa(u)D_{\mathbf u}f=df_{\mathbf a}(\mathbf u). The gradient is just the differential expressed as a vector via the dot product.
  • Through [3][3] it is built on the <span class="wiki-link-missing">Multivariable Chain Rule</span> and the <a class="wiki-link" href="/wiki/math-analysis-partial-derivatives">Partial Derivatives</a>.
  • The orthogonality of ∇f\nabla f to level sets is the engine behind <a class="wiki-link" href="/wiki/math-analysis-lagrange-multipliers">Lagrange Multipliers</a> (gradients align at constrained optima) and <span class="wiki-link-missing">Tangent Planes to Surfaces</span> (normal vector =∇F=\nabla F for a level surface F=cF=c).
  • The operator ∇\nabla generalizes to <span class="wiki-link-missing">Divergence and Curl</span> and the <span class="wiki-link-missing">Laplacian</span> in vector calculus.
  • When ff has a gradient field, line integrals become path-independent — the topic of <span class="wiki-link-missing">Conservative Vector Fields</span> and the gradient theorem.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- 1740s–1760s — Euler and the development of partial derivatives in the study of functions of several variables and in the calculus of variations.
- 1820s — Cauchy formalizes limits, providing the rigorous foundation for difference quotients like [1][1].
- 1828 — George Green's essay introduces potential theory; gradients of potential functions appear implicitly in physics.
- 1843 — William Rowan Hamilton invents quaternions and introduces the operator ∇\nabla (which he called "nabla" after a Hebrew harp), the ancestor of the modern del.
- 1873 — James Clerk Maxwell, in A Treatise on Electricity and Magnetism, uses Hamilton's ∇\nabla extensively, coining/naming "slope," "convergence," and "curl," cementing the gradient's role in field theory.
- 1881–1884 — J. W. Gibbs distributes Elements of Vector Analysis, stripping vector calculus from quaternions and defining gradient via the dot product, essentially the modern form.
- 1893 — Oliver Heaviside independently popularizes operational vector calculus for electromagnetism.
- 1901 — E. B. Wilson's Vector Analysis, based on Gibbs's lectures, standardizes notation and teaching of the gradient and directional derivative.
- 20th c. — Generalization to differential forms (Cartan), Riemannian geometry (where the gradient requires a metric), and the explosion of gradient methods in 20th–21st century optimization and deep learning.

Subtleties & Limits

open-problem

Several subtleties deserve a serious student's attention:

  • Gradient requires a metric. On a general manifold or with non-Euclidean inner products, the differential dfdf is a covector (1-form), and converting it to a gradient vector requires raising an index with a metric tensor gg: ∇f=g−1df\nabla f = g^{-1}df. The "obvious" identification ∇f↔\nabla f \leftrightarrow partials is metric-dependent; in non-orthonormal coordinates the naive componentwise formula [2][2] is wrong.
  • Differentiability vs. directional derivatives. As the counterexample shows, existence of all directional derivatives does not guarantee differentiability, continuity, or the validity of [3][3]. The gap is subtle and a recurring source of error.
  • Nonsmooth optimization. Many practical objectives (e.g. with ℓ1\ell_1 regularization, ReLU networks) are not differentiable everywhere. The gradient is replaced by the subgradient or Clarke generalized gradient, an active research area where the clean steepest-descent picture only partially survives.
  • Infinite dimensions. In Banach/Hilbert spaces the analog is the Fréchet or Gâteaux derivative; the gradient exists by the Riesz representation theorem only in Hilbert spaces, and pathologies of the finite-dimensional counterexample multiply.

See Also

Total Derivative · Jacobian Matrix · Hessian Matrix · Level Sets and Contour Lines · Laplacian · Vector Calculus Identities · Taylor Series in Several Variables