Part I — Calculus, Optimization & Gradients · Chapter 4

Jacobians & Hessians

Hook

A gradient is a vector of partial derivatives for a function with one output. What replaces it when a function has several outputs at once — and what replaces the second derivative, which told you whether a 1D curve was bending up or down?

Intuition
F(x,y) = (7.0, 11.0)
4.01.01.06.0
Jacobian of F at this point

Drag the point around the bowl. Below it sits a small grid — the Jacobian of a different, vector-valued function evaluated at that same spot. Watch its four numbers shift as you move; unlike the single gradient arrow, this matrix has one row per output.

Formalize

For a function F:R2R2F:\mathbb{R}^2\to\mathbb{R}^2, the Jacobian stacks the gradient of each output as a row:

JF(x,y)=[F1xF1yF2xF2y]J_F(x,y) = \begin{bmatrix} \dfrac{\partial F_1}{\partial x} & \dfrac{\partial F_1}{\partial y} \\[4pt] \dfrac{\partial F_2}{\partial x} & \dfrac{\partial F_2}{\partial y} \end{bmatrix}
  • F1,F2F_1, F_2 — the two output components of FF.
  • JF(x,y)J_F(x,y) — the Jacobian: every first partial derivative of every output, evaluated at (x,y)(x,y).

For a single scalar function f:R2Rf:\mathbb{R}^2\to\mathbb{R}, the Hessian plays the analogous role for second derivatives — the matrix of every way of differentiating twice:

Hf(x,y)=[2fx22fxy2fyx2fy2]H_f(x,y) = \begin{bmatrix} \dfrac{\partial^2 f}{\partial x^2} & \dfrac{\partial^2 f}{\partial x\partial y} \\[4pt] \dfrac{\partial^2 f}{\partial y\partial x} & \dfrac{\partial^2 f}{\partial y^2} \end{bmatrix}
  • Hf(x,y)H_f(x,y) — the Hessian of the scalar function ff at (x,y)(x,y): its matrix of second partials.
  1. The Jacobian generalizes the gradient

    For a scalar function (FF has one output), the Jacobian is the gradient, just written as a row instead of a vector — nothing new, only more rows once there's more than one output.

  2. The Hessian generalizes the second derivative

    Just as f(x)>0f''(x)>0 meant "curving upward" in one dimension, the Hessian's sign pattern says the same thing in two: a positive definite Hessian (both the top-left entry and the determinant positive) means ff curves upward in every direction — a genuine bowl.

  3. The Jacobian's determinant measures local stretching

    Where detJF0\det J_F \neq 0, FF is locally invertible — near that point, FF doesn't collapse two different inputs onto the same output. Where detJF=0\det J_F = 0, that guarantee breaks down.

Play
∇f = (7.0, 8.0)
4.01.01.06.0
Jacobian of F, det = 23.0
2.01.01.02.0
Hessian of f (constant everywhere)

Hessian is positive definite — f curves upward in every direction, a genuine bowl.

The Hessian of ff here never changes — ff is a fixed quadratic bowl, so its curvature is the same everywhere. The Jacobian of FF genuinely depends on where you are, which is exactly why it needs to be recomputed at every point instead of stated once.

Worked example

Let F(x,y)=(x2+y, x+y2)F(x,y) = (x^2+y,\ x+y^2) and f(x,y)=x2+xy+y2f(x,y) = x^2+xy+y^2.

  1. Evaluate F and its Jacobian at (2, 3)

    Differentiate each output with respect to each input:

    • F1/x=2x\partial F_1/\partial x = 2x
    • F1/y=1\partial F_1/\partial y = 1
    • F2/x=1\partial F_2/\partial x = 1
    • F2/y=2y\partial F_2/\partial y = 2y

    That gives the general Jacobian

    JF(x,y)=[2x112y]J_F(x,y) = \begin{bmatrix}2x & 1 \\ 1 & 2y\end{bmatrix}

    Now evaluate both FF and JFJ_F at (2,3)(2,3):

    • F(2,3)=(4+3, 2+9)=(7,11)F(2,3) = (4+3,\ 2+9) = (7, 11)
    • JF(2,3)=[2(2)112(3)]=[4116]J_F(2,3) = \begin{bmatrix}2(2) & 1 \\ 1 & 2(3)\end{bmatrix} = \begin{bmatrix}4 & 1 \\ 1 & 6\end{bmatrix}
  2. Its determinant
    detJF(2,3)=(4)(6)(1)(1)=23\det J_F(2,3) = (4)(6) - (1)(1) = 23
  3. The Hessian of f is constant

    First partials:

    • f/x=2x+y\partial f/\partial x = 2x+y
    • f/y=x+2y\partial f/\partial y = x+2y

    Differentiate each of those again:

    • 2f/x2=/x[2x+y]=2\partial^2f/\partial x^2 = \partial/\partial x[2x+y] = 2
    • 2f/xy=/y[2x+y]=1\partial^2f/\partial x\partial y = \partial/\partial y[2x+y] = 1
    • 2f/yx=/x[x+2y]=1\partial^2f/\partial y\partial x = \partial/\partial x[x+2y] = 1
    • 2f/y2=/y[x+2y]=2\partial^2f/\partial y^2 = \partial/\partial y[x+2y] = 2

    giving

    Hf=[2112]H_f = \begin{bmatrix}2 & 1\\1 & 2\end{bmatrix}

    everywhere — with no x,yx,y left in any entry, since ff is a fixed quadratic. Its determinant is 41=3>04-1=3>0 and its top-left entry is 2>02>0, so ff is positive definite: a true bowl with one minimum, at the origin.

Checkpoint

At the point (1, 4), compute the determinant of the Jacobian of F(x,y) = (x² + y, x + y²).

2.01.01.08.0
Jacobian of F at (1, 4)
Compute det(J), then pick a value
Summary
JF(x,y)=[F1/xF1/yF2/xF2/y],Hf(x,y)=[2f/x22f/xy2f/yx2f/y2]J_F(x,y) = \begin{bmatrix} \partial F_1/\partial x & \partial F_1/\partial y \\ \partial F_2/\partial x & \partial F_2/\partial y \end{bmatrix}, \qquad H_f(x,y) = \begin{bmatrix} \partial^2 f/\partial x^2 & \partial^2 f/\partial x\partial y \\ \partial^2 f/\partial y\partial x & \partial^2 f/\partial y^2 \end{bmatrix}

The Jacobian and Hessian are both just organized bookkeeping — a matrix instead of a vector or scalar — for derivatives you already know how to take. The Jacobian will resurface the moment backpropagation has to push gradients through a layer with more than one output; the Hessian will resurface the moment an optimizer wants to reason about curvature instead of just slope, which is exactly where the next chapter, Taylor series, picks up.