Multivariable Calculus — Topic 02

The Gradient and
Directional Derivatives

When a function depends on two or more variables, the derivative is no longer a single number: it becomes a vector. The gradient ∇f captures all the rate-of-change information at once, and the directional derivative lets you ask: how fast is f changing in any chosen direction?

∇fThe Gradient Vector
10Worked Examples
3Visual Diagrams
10Quiz Questions
Share this page
On This Page
  1. The Intuition, From Slope to Direction
  2. The Gradient Vector ∇f
  3. The Directional Derivative Dûf
  4. Maximum Rate of Change and Steepest Ascent
  5. Level Curves and Gradient Perpendicularity
  6. The Gradient in Three Dimensions
  7. Fully Worked Examples
  8. Common Mistakes
  9. 10-Question Quiz

§ 01The Intuition — From Slope to Direction

In single-variable calculus, f′(x) gives you a single number: the slope at a point. In multivariable calculus, the "slope" depends on which direction you move, so the derivative becomes a vector.

Think of a mountainous landscape described by a height function f(x, y). At any point on the mountain, you could walk north, east, northeast, or in any of infinitely many compass directions. Each direction gives a different rate of ascent or descent. The question "how steep is it here?" has no single answer: unless you also specify a direction.

The gradient resolves this by packaging the rate-of-change information from every direction into a single vector. Once you have it, you can instantly compute the rate of change in any specific direction with a dot product. The gradient also has a beautiful geometric property: it always points directly uphill: in the direction of steepest ascent.

The Central Idea The gradient vector ∇f at a point P encodes two things simultaneously: its direction tells you which way is steepest uphill, and its magnitude tells you how steep that steepest slope is. Every other directional rate of change is a projection of the gradient onto that direction.

Prerequisites for This Page

This topic builds directly on partial derivatives. You should be comfortable computing ∂f/∂x and ∂f/∂y for polynomial, exponential, and trigonometric functions before continuing. You will also need a basic understanding of vectors, specifically the dot product: since the directional derivative formula uses it explicitly. The chain rule also appears in the derivation.

§ 02The Gradient Vector ∇f

For a differentiable function f(x, y), the gradient of f (written ∇f (read "del f" or "nabla f")) is the vector formed by collecting both partial derivatives:

Definition — Gradient in 2D
∇f(x, y) = ⟨ ∂f/∂x , ∂f/∂y ⟩

The symbol ∇ (nabla) is a vector differential operator. Applying it to a scalar function f gives a vector field, at each point (x, y), the gradient is a vector in ℝ².

Notice what this means concretely. The first component ∂f/∂x measures how fast f changes as you move in the x-direction (while y stays fixed). The second component ∂f/∂y measures how fast f changes in the y-direction. The gradient vector combines these two rates into a single arrow at each point in the domain.

Component Form vs. Notation

You will encounter several equivalent ways to write the gradient. All of the following mean the same thing:

Angle-bracket notation
∇f = ⟨ fx, fy
Clean and unambiguous — preferred in most multivariable texts.
Unit-vector notation
∇f = fx i + fy j
Common in physics texts. i and j are the standard basis vectors.
Column-vector notation
∇f = [ fx, fy ]T
Used in linear algebra and machine learning (gradient descent) contexts.

Computing the Gradient — Step by Step

The process is exactly the same as computing partial derivatives, organised into a vector:

Step 01
Compute ∂f/∂x
Differentiate f with respect to x, treating every other variable as a constant. This is the first component of ∇f.
Step 02
Compute ∂f/∂y
Differentiate f with respect to y, treating every other variable as a constant. This is the second component of ∇f.
Step 03
Assemble the vector
Write ∇f = ⟨ ∂f/∂x, ∂f/∂y ⟩. Note that ∇f is itself a function of (x, y) — it produces a different vector at each point.
Example 01 Gradient of a polynomial in two variables

Find ∇f for f(x, y) = x³y + 2x − y².

Step 1

Differentiate with respect to x (treat y as constant):

∂f/∂x = 3x²y + 2
Step 2

Differentiate with respect to y (treat x as constant):

∂f/∂y = x³ − 2y
Result
∇f = ⟨ 3x²y + 2, x³ − 2y ⟩

At the specific point (1, 2): ∇f(1, 2) = ⟨ 3(1)(2) + 2, 1 − 4 ⟩ = ⟨ 8, −3 ⟩

Example 02 Gradient involving trigonometric and exponential terms

Find ∇f for f(x, y) = exsin(y) + x²y.

∂f/∂x
exsin(y) + 2xy

The term exsin(y) differentiates as ex·sin(y) (sin(y) is a constant w.r.t. x). The term x²y differentiates as 2xy.

∂f/∂y
excos(y) + x²

The term exsin(y) differentiates as ex·cos(y) (ex is a constant w.r.t. y). The term x²y differentiates as x².

Result
∇f = ⟨ exsin(y) + 2xy, excos(y) + x² ⟩

§ 03The Directional Derivative Dûf

The partial derivatives ∂f/∂x and ∂f/∂y only tell you the rate of change in the coordinate axis directions. The directional derivative generalises this to any direction in the plane.

Let û = ⟨ a, b ⟩ be a unit vector (meaning |û| = √(a² + b²) = 1) that specifies the direction you want to move. The directional derivative of f at a point P in the direction û is:

Definition — Directional Derivative
Dûf = ∇f · û = fxa + fyb

where û = ⟨ a, b ⟩ is a unit vector and ∇f is evaluated at the point of interest.

The dot product projects the gradient onto the direction û. The result is a scalar: the rate of change of f in the direction û.

Why Must û Be a Unit Vector?

The directional derivative measures rate of change per unit distance in a given direction. If you used a non-unit vector, the magnitude would affect the result, conflating the direction with the speed of travel. Normalising to a unit vector ensures that Dûf is purely about direction, not about how far you walk per step.

Converting an Angle to a Unit Vector If you are given a direction as an angle θ measured from the positive x-axis, the corresponding unit vector is û = ⟨ cos θ, sin θ ⟩. For example, the direction "northeast" (θ = 45°) gives û = ⟨ cos 45°, sin 45° ⟩ = ⟨ 1/√2, 1/√2 ⟩.

Formal Definition via Limits

Before we had the gradient formula, the directional derivative was defined as a limit. Understanding this definition clarifies why the formula works:

Limit Definition
Dûf(x₀, y₀) = limh→0 [f(x₀ + ha, y₀ + hb) − f(x₀, y₀)] / h

This is the standard difference quotient, but instead of moving along the x-axis, you move in the direction û = ⟨ a, b ⟩ by a small amount h. The partial derivative ∂f/∂x is the special case û = ⟨1, 0⟩, and ∂f/∂y is the case û = ⟨0, 1⟩.

Using the chain rule and the definition of differentiability, one can prove that this limit equals ∇f · û whenever f is differentiable: giving us the convenient formula we use in practice.

Example 03 Directional derivative in a specified direction

Let f(x, y) = x² + xy. Find the directional derivative at (1, 2) in the direction of the vector v = ⟨ 3, 4 ⟩.

Normalise

First find the unit vector: |v| = √(9 + 16) = 5

û = ⟨ 3/5, 4/5 ⟩
Gradient
∇f = ⟨ 2x + y, x ⟩

At (1, 2): ∇f(1, 2) = ⟨ 2(1) + 2, 1 ⟩ = ⟨ 4, 1 ⟩

Dot product
Dûf = ⟨4, 1⟩ · ⟨3/5, 4/5⟩ = 12/5 + 4/5 = 16/5
Result
Dûf(1, 2) = 16/5 = 3.2

Moving from (1, 2) in the direction of ⟨3, 4⟩, the function f increases at a rate of 3.2 per unit distance.

Example 04 Directional derivative using an angle

Let f(x, y) = x²y − y³. Find the rate of change of f at the point (2, 1) in the direction making angle θ = π/3 with the positive x-axis.

Unit vector
û = ⟨cos(π/3), sin(π/3)⟩ = ⟨1/2, √3/2⟩
Gradient

∂f/∂x = 2xy, ∂f/∂y = x² − 3y²

At (2,1): ∇f = ⟨4, 4 − 3⟩ = ⟨4, 1⟩

Dot product
Dûf = ⟨4, 1⟩ · ⟨1/2, √3/2⟩ = 2 + √3/2 ≈ 2.866
Result
Dûf ≈ 2 + √3/2

§ 04Maximum Rate of Change and Steepest Ascent

The directional derivative Dûf = ∇f · û depends on the angle between the gradient vector and the direction û. Using the geometric definition of the dot product:

Dot Product Expansion
Dûf = ∇f · û = |∇f| |û| cos θ = |∇f| cos θ

Here θ is the angle between ∇f and û. Since |û| = 1 (unit vector), the formula simplifies to |∇f|cos θ.

This immediately gives us three fundamental results:

Angle θ Direction Dûf Meaning
θ = 0° Parallel to ∇f (same direction) +|∇f| (maximum) Steepest ascent
θ = 90° Perpendicular to ∇f 0 No change — along a level curve
θ = 180° Anti-parallel to ∇f −|∇f| (minimum) Steepest descent
Key Theorem — Steepest Ascent
Max Dûf = |∇f|, achieved when û = ∇f / |∇f|

The maximum rate of change of f at a point P is the magnitude of the gradient at P. The direction that achieves this maximum is the unit vector pointing in the same direction as ∇f.

Similarly, the minimum rate of change (most negative) is −|∇f|, in the direction −∇f / |∇f|.

Example 05 Finding the direction and magnitude of steepest ascent

Let f(x, y) = 4x² − y². Find: (a) the direction of steepest ascent at (1, 2), (b) the maximum rate of change, and (c) the direction along which f does not change.

Gradient
∇f = ⟨8x, −2y⟩

At (1, 2): ∇f(1, 2) = ⟨8, −4⟩

Part (a)

Direction of steepest ascent: û = ∇f / |∇f|

|∇f| = √(64 + 16) = √80 = 4√5 û = ⟨8/(4√5), −4/(4√5)⟩ = ⟨2/√5, −1/√5⟩
Part (b)
Max rate = |∇f| = 4√5 ≈ 8.944
Part (c)

f does not change when moving perpendicular to ∇f = ⟨8, −4⟩. A vector perpendicular to ⟨8, −4⟩ is ⟨4, 8⟩ (swap components, negate one), or its unit version ⟨1/√5, 2/√5⟩.

Summary

Steepest ascent direction: ⟨2/√5, −1/√5⟩

Maximum rate of change: 4√5 ≈ 8.94

Level-curve direction: ⟨1/√5, 2/√5⟩

§ 05Level Curves and Gradient Perpendicularity

A level curve of f(x, y) is the set of all points where f equals a fixed constant k:

Level Curve Definition
Level curve at height k: {(x, y) ∈ ℝ² : f(x, y) = k}

On a topographic map, level curves are the contour lines, curves of constant elevation. Moving along a level curve keeps you at the same height, so f is not changing at all in that direction.

This connects directly to the gradient: since Dûf = 0 when û is tangent to a level curve, and since Dûf = ∇f · û = 0 means ∇f ⊥ û, we get the key theorem:

Gradient Perpendicularity Theorem At any point P on the level curve f(x, y) = k, the gradient vector ∇f(P) is perpendicular (orthogonal) to the level curve at P. Equivalently, ∇f always points in the direction of the greatest increase, which is necessarily perpendicular to the direction of no change.
Figure 01 — Level Curves and Gradient Vectors
k=5 k=4 k=3 k=2 ∇f x y ∇f ⊥ level curve at every point
The gradient vectors (teal arrows) point radially outward — perpendicular to each elliptical level curve — toward increasing values of f. The small square on the rightmost arrow indicates a right angle between the gradient and the level curve tangent.

Application: Finding Tangent Lines to Implicit Curves

The perpendicularity of ∇f to level curves gives an elegant method for finding tangent lines to implicitly defined curves. If a curve is defined by F(x, y) = k, then at any point (x₀, y₀) on the curve, the tangent line is perpendicular to ∇F(x₀, y₀). Since ∇F is the normal vector to the tangent line, the tangent line equation is:

Tangent Line to an Implicit Curve
Fx(x₀, y₀)(x − x₀) + Fy(x₀, y₀)(y − y₀) = 0

This is the equation of the line through (x₀, y₀) with normal vector ∇F(x₀, y₀).

Example 06 Tangent line to an ellipse using the gradient

Find the tangent line to the ellipse x² + 4y² = 20 at the point (2, 2).

Setup

Let F(x, y) = x² + 4y². The ellipse is the level curve F = 20.

Gradient
∇F = ⟨2x, 8y⟩

At (2, 2): ∇F = ⟨4, 16⟩

Tangent line
4(x − 2) + 16(y − 2) = 0 4x − 8 + 16y − 32 = 0 4x + 16y = 40, i.e. x + 4y = 10
Result
Tangent line: x + 4y = 10

§ 06The Gradient in Three Dimensions

Everything extends naturally to functions of three variables f(x, y, z). The gradient becomes a vector in ℝ³:

Gradient in 3D
∇f(x, y, z) = ⟨ ∂f/∂x, ∂f/∂y, ∂f/∂z ⟩

The directional derivative formula remains the same: Dûf = ∇f · û, where û = ⟨a, b, c⟩ is now a unit vector in ℝ³ (satisfying a² + b² + c² = 1).

In three dimensions, the analogue of a level curve is a level surface: the set of all points (x, y, z) where f equals a constant k. The gradient ∇f at a point P is perpendicular to the level surface through P. This is the key fact used in many applications:

Tangent Planes
Normal to tangent plane = ∇F
The tangent plane to the surface F(x,y,z) = k at P has normal vector ∇F(P), giving equation ∇F · (r − r₀) = 0.
Heat Flow
Heat flows opposite ∇T
In thermodynamics, heat flows in the direction of −∇T (from hot to cold), i.e., down the temperature gradient.
Gradient Descent
Update: x ← x − α∇f
Machine learning optimisation moves opposite the gradient to minimise a loss function — the algorithm is literally "gradient descent."
Example 07 Gradient and directional derivative for f(x, y, z)

Let f(x, y, z) = xyz². Find the gradient and the directional derivative at (1, 2, 3) in the direction of v = ⟨ 1, 1, −1 ⟩.

Gradient

∂f/∂x = yz², ∂f/∂y = xz², ∂f/∂z = 2xyz

At (1, 2, 3): ∇f = ⟨2·9, 1·9, 2·1·2·3⟩ = ⟨18, 9, 12⟩

Unit vector
|v| = √(1+1+1) = √3 û = ⟨1/√3, 1/√3, −1/√3⟩
Dot product
Dûf = ⟨18,9,12⟩ · ⟨1/√3, 1/√3, −1/√3⟩ = (18 + 9 − 12)/√3 = 15/√3 = 5√3 ≈ 8.66
Result
Dûf(1,2,3) = 5√3 ≈ 8.66
Example 08 Tangent plane to a level surface using the gradient

Find the equation of the tangent plane to the surface x² + y² + z² = 14 at the point (1, 2, 3).

Normal vector

Let F(x,y,z) = x² + y² + z². The surface is F = 14 (a level surface).

∇F = ⟨2x, 2y, 2z⟩

At (1,2,3): ∇F = ⟨2, 4, 6⟩: this is normal to the tangent plane.

Plane equation
2(x−1) + 4(y−2) + 6(z−3) = 0 2x − 2 + 4y − 8 + 6z − 18 = 0 2x + 4y + 6z = 28
Result
Tangent plane: x + 2y + 3z = 14

§ 07Further Worked Examples

The following examples cover a broader range of function types and question styles. Work through them yourself before reading the solutions, each one highlights a different aspect of the gradient or directional derivative.

Example 09 Checking a specific directional rate is zero

Let f(x,y) = x² − 2xy + y². Verify that the directional derivative in the direction û = ⟨1/√2, 1/√2⟩ at any point (a, a) (on the line y = x) is zero. Interpret this geometrically.

Gradient
∇f = ⟨2x − 2y, −2x + 2y⟩

At (a, a): ∇f = ⟨2a − 2a, −2a + 2a⟩ = ⟨0, 0⟩

Dûf
Dûf = ⟨0,0⟩ · û = 0

The rate of change is zero in every direction at these points.

Geometric interpretation

Notice that f(x,y) = (x−y)² ≥ 0, and f = 0 precisely on the line y = x. Every point on y = x is a global minimum, so f has zero rate of change there, the gradient is the zero vector at all these points, confirming that (a, a) lies at the bottom of a valley.

Example 10 Direction that produces a specified rate of change

Let f(x,y) = ln(x² + y²). At the point (1, 0), find all unit vectors û such that Dûf = 1.

Gradient

∂f/∂x = 2x/(x²+y²), ∂f/∂y = 2y/(x²+y²)

At (1,0): ∇f = ⟨2/1, 0/1⟩ = ⟨2, 0⟩

Condition

Let û = ⟨cosθ, sinθ⟩. Then:

Dûf = ⟨2,0⟩ · ⟨cosθ, sinθ⟩ = 2cosθ = 1 cosθ = 1/2 → θ = ±π/3
Result
û = ⟨1/2, √3/2⟩ or û = ⟨1/2, −√3/2⟩

Two directions (symmetric about the x-axis) give a rate of change of exactly 1. This makes geometric sense: the set of directions achieving a given rate D = ∇f · û = c is a pair of vectors at equal angles from ∇f.

Figure 02 — Directional Derivative as a Projection
∇f û Dûf = |∇f|cosθ θ Origin P The projection of ∇f onto û equals the directional derivative
The directional derivative Dûf is the scalar projection of ∇f onto the unit vector û. This equals |∇f|cosθ, which is maximised (= |∇f|) when θ = 0 — i.e., when û aligns with the gradient.

§ 08Common Mistakes

Mistake 1: Forgetting to normalise the direction vector The formula Dûf = ∇f · û only holds when û is a unit vector. If you use an arbitrary vector v without dividing by its magnitude, your answer will be scaled by |v|. Always normalise first: û = v / |v|.
Mistake 2: Confusing ∇f with the directional derivative The gradient ∇f is a vector; the directional derivative Dûf is a scalar. They are related by the dot product Dûf = ∇f · û, but they are different objects. A common error is writing ∇f as the answer when the question asks for a rate of change in a specific direction.
Mistake 3: Claiming ∂f/∂x is the "x-component of the directional derivative" The partial derivative ∂f/∂x is a special case of the directional derivative where û = ⟨1, 0⟩ (the pure x-direction). It is one component of the gradient, not a component of an arbitrary directional derivative.
Mistake 4: Thinking |∇f| gives the directional derivative in all directions The magnitude |∇f| is the maximum directional derivative — achieved only when moving in the direction of ∇f itself. For any other direction, Dûf = |∇f|cosθ ≤ |∇f|. Students sometimes write |∇f| as the answer to "find the rate of change in the direction ⟨a, b⟩" without computing the dot product.
Mistake 5: Misreading the gradient as pointing toward the maximum of f The gradient ∇f at a point P points in the direction of steepest increase locally — it does not generally point toward the global maximum of f. Following the gradient repeatedly (gradient ascent) traces a path uphill, but the path curves as ∇f changes direction across the domain.
Tip: Check units and signs A quick sanity check: the directional derivative should be negative if you are moving "downhill" on f. If you compute a positive directional derivative in what should clearly be a descent direction, check that you normalised correctly and used the right sign in your components.

§ 09Test Your Understanding

Ten questions covering every concept from this page: gradient computation, directional derivatives, steepest ascent, level curves, and 3D gradients. Try each question before revealing the explanation.

10-Question Quiz
Gradient & Directional Derivatives

Cookie Settings