Partial Derivatives, Gradient, Jacobian, and Hessian
The full first- and second-order local picture of a multivariable function, and the objects that drive every optimizer.
Leads to: The gradient and Hessian are the engine of optimization (3.4, 3.5) and gradient descent everywhere later.
Learning Objectives
Click a status chip to cycle: Not started → In progress → Studied → Practiced → Needs review → Mastered.
- Compute partial derivatives and assemble the gradient of a scalar field.
- Derive the directional derivative and prove the gradient points in the direction of steepest ascent.
- Build the Jacobian of a vector field and the Hessian of a scalar field.
- Implement a numerical gradient and verify it against an analytic one.
Key Vocabulary
- Partial derivative
- The rate \(\partial f/\partial x_i\) with all other variables held fixed.
- Gradient
- The vector \(\nabla f=(\partial f/\partial x_1,\dots,\partial f/\partial x_n)\) of first partials.
- Directional derivative
- The rate \(D_u f=\nabla f\cdot u\) of change along a unit vector \(u\).
- Jacobian
- The \(m\times n\) matrix \(J_{ij}=\partial F_i/\partial x_j\) of a vector field \(F:\R^n\to\R^m\).
- Hessian
- The symmetric matrix \(H_{ij}=\partial^2 f/\partial x_i\partial x_j\) of second partials.
- Total derivative
- The best linear approximation \(f(a+h)\approx f(a)+\nabla f(a)\cdot h\); differentiability means this error is \(o(\lVert h\rVert)\).
Intuition & Motivation
Second derivatives measure curvature. The Hessian packages all of them into a symmetric matrix whose eigenvalues will later tell us whether a critical point is a minimum, maximum, or saddle.
Partials and the gradient
For \(f(x,y)=x^2 y+\sin y\) the partials are \(\partial_x f=2xy\) and \(\partial_y f=x^2+\cos y\). The gradient collects them:
Jacobian and Hessian
For a vector field \(F=(F_1,\dots,F_m)\) the Jacobian stacks the gradients of each component as rows; it is the total-derivative matrix. For a scalar field the Hessian is the Jacobian of the gradient:
When the second partials are continuous, Clairaut’s theorem gives \(\partial_i\partial_j f=\partial_j\partial_i f\), so the Hessian is symmetric - the fact that makes the spectral theorem (Phase 4) applicable.
Interactive: descend a bowl
The workbench walks \(x_{k+1}=x_k-\eta\,\nabla f(x_k)\) on an ill-conditioned bowl. Watch the zig-zag when the level ellipses are elongated (high condition number): steepest descent bounces across the narrow valley.
Interactive: a numerical gradient
- Forgetting to normalize \(u\) before computing \(D_u f=\nabla f\cdot u\); the formula needs a unit vector.
- Swapping Jacobian rows and columns - \(J_F\) is \(m\times n\) with component gradients as rows.
- Assuming \(\partial_i\partial_j f=\partial_j\partial_i f\) without continuity of the second partials (Clairaut needs it).
- Treating the gradient as a slope (a number) rather than a vector; its length is the steepest slope.
- Always sanity-check an analytic gradient against a central-difference gradient before trusting an optimizer.
- For \(f=\tfrac12 x^\top A x+b^\top x\) memorize \(\nabla f=Ax+b\) and \(H=A\); most quant objectives are locally this.
- The gradient is orthogonal to level sets - on a risk contour map it points straight across the ellipses toward higher loss.
Knowledge Check
Practical Exercise
Let \(f(x,y)=x^2+xy+2y^2\). (a) Find \(\nabla f\) and the Hessian \(H\). (b) Give the direction of steepest ascent at \((1,1)\) and the maximal directional derivative there.
(a) \(\partial_x f=2x+y,\ \partial_y f=x+4y\), so \(\nabla f=(2x+y,\ x+4y)\). The Hessian is constant:
(b) At \((1,1)\), \(\nabla f=(3,5)\). Steepest ascent is the unit vector \((3,5)/\sqrt{34}\), and the maximal directional derivative is \(\lVert(3,5)\rVert=\sqrt{34}\approx 5.83\).
Lesson Summary
Formula Sheet Additions
Retrieval Practice
Close the lesson and answer from memory before checking. This is deliberate, effortful recall - the single highest-yield study action.
A: Because D_u f = grad f · u is maximized (Cauchy-Schwarz) when u aligns with grad f, giving value ||grad f||.
A: Gradient Ax and Hessian A (constant).
Completion Checklist
- I can explain the core ideas in my own words
- I worked the derivations/examples by hand
- I completed the interactive workbench(es)
- I passed the knowledge check