Gradients and Directional Derivatives
The gradient is the compass needle of a multi-input function — it points the way that increases the output fastest, and every other direction's rate of change is just its shadow.
Prerequisites: Derivatives and Differentiation Rules, Vector Spaces and Bases
A portfolio's P&L depends on dozens of things at once — rates, spot, volatility, credit spreads. If you nudge every input a little, which direction makes P&L improve fastest? With one variable, "the slope" answers that instantly: go up if the derivative is positive. With many variables at once, "the slope" isn't a single number anymore — it's a direction. The gradient is the tool that finds it: a vector pointing exactly toward steepest increase, from which every other question ("what if I move rates up and vol down together?") falls out as a simple projection.
The analogy: standing on a hillside
Imagine standing on a hillside described by height as a function of your east-west and north-south position. There's one direction that takes you uphill fastest — that's the gradient. Walk sideways along the contour line instead, and your altitude doesn't change at all: the directional derivative there is zero. Walk in any other direction, and you climb at some rate in between, which depends on how much that direction "agrees" with the steepest-ascent direction.
The mechanics, one symbol at a time
For a function of several variables, the gradient is the vector of all its partial derivatives — how much changes per unit move in each coordinate direction, holding the others fixed:
In words: each entry answers "if I nudge just this one input, how fast does the output move?" — the gradient bundles all of those answers into one vector, which turns out to point in the single direction of fastest increase.
To find the rate of change along an arbitrary direction (a unit vector), you don't need a new derivative — you project the gradient onto that direction with a dot product, called the directional derivative:
where is the angle between the gradient and . In plain English: how fast changes as you move in direction depends only on the length of the gradient (how steep the hill is at its steepest) and how closely aligns with that steepest direction — moving exactly along the gradient gives the maximum rate ; moving perpendicular to it gives zero.
Worked example 1: a two-asset P&L surface
Suppose a book's P&L (in thousands) as a function of a spot move and a vol move (both in percent) is approximately , and you're currently at . The gradient is , so at : . This says: right now, P&L is far more sensitive to a spot move than a vol move — an extra 1% of spot adds about $8,000, while a small extra vol move adds almost nothing locally. The steepest-improvement direction is purely "increase spot."
Worked example 2: rate of change along a specific stress path
A risk manager wants to stress spot up 1% and vol down 1% simultaneously — direction (normalized). Using the gradient from above, at :
So along that specific combined stress, P&L improves at roughly $5,660 per unit move — less than the $8,000 you'd get moving purely along the gradient, because the stress direction only partially aligns with steepest ascent. This is exactly how a directional derivative turns "what if these two things move together" into a single number without recomputing anything from scratch.
Watch the arrows: at every point they point along the (negative) gradient — steepest descent — and their length shows how steep the surface is there; flatter regions near the minimum give shorter steps.
What this means in practice
Gradients are the machinery behind every multi-factor risk sensitivity a desk computes — cross-Greeks, factor exposures, and gradient-descent calibration of models are all directional-derivative questions in disguise. Any "what if two risk factors move together" stress test is a dot product with the gradient, no re-derivation needed. Optimization algorithms from gradient descent to Newton's method use (and, for curvature, its extension the Hessian) as their entire compass for deciding which way to step.
The gradient points in the direction of fastest increase of ; the rate of change in any other direction is just the gradient dotted with that direction, which shrinks toward zero as the direction turns away from the gradient and toward a contour line.
A common mix-up is treating "the derivative with respect to " as if it tells you the full rate of change when several variables move at once. It only tells you the rate along the -axis with everything else frozen. If multiple inputs move together, you need the full directional derivative — summing individual partial derivatives without regard to the actual direction of joint movement, or worse, without normalizing to unit length, silently gives the wrong number.
Related concepts
Practice in interviews
Further reading
- Boyd & Vandenberghe, Convex Optimization, appendix A
- Strang, Calculus, ch. 13