19. Multivariable & Vector Calculus
CollegeReal quantities often depend on more than one variable — temperature across a room, or profit over both price and quantity. This chapter extends calculus to several variables using vectors, partial derivatives and the gradient.
Vectors, partial derivatives and the gradient
A vector in ℝn is an ordered list of numbers with both magnitude and direction. The dot product of vectors a and b is a·b = ∑ aibi = |a||b|cosθ — it measures how aligned two vectors are, and is zero exactly when they are perpendicular. In ℝ³, the cross product a × b produces a new vector perpendicular to both.
For f(x, y), the partial derivative ∂f/∂x differentiates with respect to x while treating every other variable as a constant. Collecting all partials gives the gradient:
The gradient points in the direction of steepest increase of f, with magnitude equal to that steepest rate. The directional derivative along a unit vector u is Duf = ∇f · u. Multiple integrals extend the same accumulation idea to two or three dimensions, e.g. a double integral over a region gives the volume under a surface.
Uphill in every direction at once
Imagine standing on a hillside described by f(x, y) = elevation. A partial derivative asks: "if I only ever step east-west (holding north-south fixed), how steep is it?" That is one slice of the full picture. The gradient stitches every direction's slope together into a single vector that always points straight uphill, as steeply as possible — walk in that direction and you gain elevation fastest of all.
The dot product's role in the directional derivative is elegant: ∇f · u measures how much of the gradient's "push" lines up with the direction u you actually chose to walk. Walk along the gradient itself and you get the maximum possible rate; walk perpendicular to it and the rate is zero — you're moving along a contour line, at constant height. This machinery — the gradient — is exactly what powers gradient descent, the algorithm that trains most modern machine learning models by repeatedly stepping downhill on an error surface.
Worked example: gradient and directional derivative
Let f(x, y) = x²y + 3y². Find ∇f at (2, 1), and the directional derivative there in the direction u = (3/5, 4/5) (a unit vector).
- ∂f/∂x = 2xy. At (2,1): 2(2)(1) = 4.
- ∂f/∂y = x² + 6y. At (2,1): 4 + 6(1) = 10.
- So ∇f(2,1) = (4, 10).
- Directional derivative: Duf = ∇f · u = 4(3/5) + 10(4/5) = 12/5 + 40/5 = 52/5 = 10.4.
Answer: ∇f(2,1) = (4, 10); the function increases at rate 10.4 in the direction u.
Test your understanding
What does it mean geometrically if ∇f = 0 at a point?
It's a critical point — the surface is momentarily flat in every direction, exactly like f′(x) = 0 in single-variable calculus. It could be a local maximum, a local minimum, or a saddle point (up in one direction, down in another), which has no single-variable analogue.
Why is the dot product of two perpendicular vectors zero?
Because a·b = |a||b|cosθ, and perpendicular vectors have θ = 90°, where cos 90° = 0. Geometrically, neither vector has any component "along" the other's direction, so there's nothing to multiply together.
What's the difference between a partial derivative and a directional derivative?
A partial derivative measures the rate of change along one coordinate axis only (holding the others fixed). A directional derivative generalises this to any chosen direction u, computed as ∇f · u. In fact, the partial derivatives are just the special cases where u is a coordinate axis unit vector.
Give a real-world example where the gradient is useful.
Machine learning: training a model means minimising an error function of many parameters, and gradient descent repeatedly steps in the direction opposite the gradient (steepest decrease) until the error is minimised. Meteorologists similarly use the gradient of a pressure or temperature field to find the direction of fastest change.
How the ideas connect
Every key idea in this chapter, branching from the core concept — use it to see the whole picture at a glance.
The key facts, visualised
Worked problems, step by step
Follow each solution line by line, then try to reproduce it on paper before moving on.
Example 1Find the gradient of f(x, y) = x^2 + y^2.
- Partial in x: df/dx = 2x
- Partial in y: df/dy = 2y
- Gradient = (2x, 2y)
Example 2Find the directional derivative of f = x^2 + y^2 at (1, 1) in direction (1, 0).
- Gradient at (1,1) is (2, 2)
- Unit direction is (1, 0)
- Dot product: 2(1) + 2(0) = 2
Now you try
Work each one out first, then tap to reveal the worked answer.