Free lesson · Partial derivatives
Gradients, directional derivatives and Jacobians
Open interactive lessonPractice calculationsExplore labs
Start with the idea
- The gradient gathers the partial derivatives of a scalar output into one vector.
- Its dot product with an input direction gives the rate in that direction.
- A Jacobian does the same bookkeeping for multiple outputs.
Symbols, units & horizon
- ∇f: gradient of a scalar function
- T: transpose
- u: direction vector of unit Euclidean length for a per-unit-distance derivative
- Dᵤf: directional derivative
- Fᵢ: output component i
- xⱼ: input component j
- J: Jacobian matrix
- Δx,ΔF: small finite input and output changes
- || ||: vector length
When and why to use this
Use gradients for scenario directions and optimisation; use Jacobians to connect stages of a multivariable model and audit input/output dimensions.
- For a unit direction u, the directional derivative measures output change per unit distance in the chosen coordinate scale.
- Rescaling an input changes what a unit step means.
- This matters when combining prices, rates and volatility coordinates.
- If a model maps an input vector x to an output vector F, its Jacobian entry Jᵢⱼ is the partial derivative of output i with respect to input j.
- Multiplying J by a small input change gives a first-order output-change vector.
- The rows and columns must match the documented ordering.
Gradients, directional derivatives and Jacobians
- For f=x²+2y², the gradient is (2x,4y). At (1,1) it is (2,4).
- Use direction u=(3/5,4/5), whose squared length is 9/25+16/25=1. The directional derivative is 2×3/5+4×4/5=4.4.
- For F=(x+y,xy), differentiate each output to get Jacobian rows (1,1) and (y,x). At (2,3), a change (.1,−.2) gives first-order output change (−.1,−.1).
For F=(x+y,xy), actual change from (2,3) to (2.1,2.8) is (−.1,−.12). The −.02 difference in the second component is the product of the two input changes, omitted at first order.
An analogy to remember
A gradient is a slope map telling you how a hill rises in each coordinate direction. A Jacobian is a table of such responses when you are tracking several outputs at once.
How this becomes a building block
A Jacobian can map market-quote changes into instrument-price changes or map parameter changes into calibration errors. Reverse-mode automatic differentiation efficiently propagates a scalar output’s sensitivities backward through a computational graph; it differentiates the implemented operations, not an independently validated economic truth.
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
def directional_quadratic(x,y,direction):
ux,uy=direction
if abs(ux*ux+uy*uy-1)>1e-9: raise ValueError("Unit direction required")
return 2*x*ux+4*y*uy
def example_jacobian(x,y):
return [[1,1],[y,x]]
def linear_output_change(jacobian,change):
if any(len(row)!=len(change) for row in jacobian): raise ValueError("Dimensions must match")
return [sum(a*b for a,b in zip(row,change)) for row in jacobian]
print(directional_quadratic(1,1,(.6,.8)),linear_output_change(example_jacobian(2,3),[.1,-.2]))Continue learning
Multivariable Calculus & Partial Derivatives — all lessons- Start with two inputs: change only one
- Partial derivatives: holding the other inputs fixed
- Gradients, directional derivatives and Jacobians
- Hessians, mixed derivatives and second-order scenarios
- Constrained optimisation and multiple integrals
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations