Lesson 1.5core3 h 30 min

Multivariable and matrix calculus

Jacobians, Hessians, the identities you need, and what autograd really computes

Models are built from vectors and matrices, so their derivatives are too. Jacobians generalize the derivative to vector-valued functions, Hessians measure curvature, and a handful of matrix-calculus identities let you derive the gradients of linear regression (3.2 Linear regression), logistic regression (3.3 Logistic regression and softmax classification) and softmax cross-entropy (4.3 Loss functions catalog) in a few lines instead of pages. You will also learn what autograd actually computes — vector-Jacobian products — which is why backpropagation (4.4 Backpropagation, fully derived) costs about as much as a forward pass no matter how many parameters a model has.

You'll be able to

  • Write the Jacobian of a vector-valued function and compose Jacobians with the chain rule
  • Use the second-order Taylor expansion and the Hessian to classify critical points and define convexity
  • Apply the core matrix-calculus identities, including the backward rule for a linear layer
  • Derive the gradients of least squares and of softmax cross-entropy, and explain vector-Jacobian products

Key ideas

  1. The Jacobian J (m×n, Jᵢⱼ = ∂fᵢ/∂xⱼ) is the matrix of a vector function's local linear approximation; chain rule = Jacobian product.
  2. Second-order Taylor: f(x+δ) ≈ f + ∇fᵀδ + ½δᵀHδ; Hessian eigenvalues are curvatures; H ≻ 0 minimum, mixed signs saddle, H ⪰ 0 everywhere ⇔ convex.
  3. Code convention: the gradient of a scalar loss has the same shape as the tensor it is taken with respect to.
Show 4 more key ideas
  1. Identities: ∇(aᵀx) = a; ∇(xᵀAx) = (A + Aᵀ)x; ∇‖Xw − y‖² = 2Xᵀ(Xw − y).
  2. Linear-layer backward rule: for Z = XW with upstream G, ∂L/∂W = XᵀG and ∂L/∂X = GWᵀ (shape trick recovers it).
  3. Softmax + cross-entropy has the gradient ∇_z L = p − y: prediction minus target.
  4. Autograd computes vector-Jacobian products right-to-left, never full Jacobians; backward cost ≈ forward cost, memory = stored activations.

Suggested path through this lesson