Unit 2 of 6 · about 3 hours · derive

Jacobians, Hessians and Taylor approximations

Jacobians say how outputs move; Hessians say how gradients move. Taylor turns both into the local models that justify gradient steps and Newton steps.

You'll be able to

  • Assemble the Jacobian of a vector-valued map with consistent shapes under a stated layout.
  • Write first- and second-order Taylor approximations and bound the remainder from the Hessian size.
  • Classify a stationary point from Hessian eigenvalues on a small hand-worked example.

Covers

Jacobians, Hessians and consistent shape conventionsFirst- and second-order Taylor approximations
1

Read

In this order, only the parts listed

0 of 3 done

  1. Jacobians, Hessians and multivariate TaylorMathematics for Machine Learning - Ch. 5

    Section 5.3 (pp. 149-154): vector-valued gradients, the Jacobian, the determinant-as-magnifier example, gradient of in (5.67)-(5.68). Section 5.7 (pp. 164-165): higher-order derivatives and Hessian symmetry for twice continuously differentiable functions. Section 5.8 (pp. 165-169): multivariate Taylor series (5.149)-(5.156) with the worked cubic at (1, 2): gradient (5.165), Hessian (5.171) and third derivatives (5.174)-(5.176)

  2. Second derivatives, bilinear forms and HessiansMIT 18.S096 - Matrix Calculus for ML

    Lecture 7, Part 2 notes (course notes Chapter 12): second derivatives as symmetric bilinear forms, Hessian matrices, minima versus maxima versus saddles

  3. Second-derivative test in two variablesMIT 18.02SC - Multivariable Calculus Unit 2

    Session 30 (Part A): second-derivative test for two-variable functions

    Use only as the 2-D classification check; skip the Lagrange sessions.

2

Focus on

  • The Jacobian of is in numerator layout, and each row is one scalar gradient.
  • Hessian symmetry needs continuous second partials. Without , mixed partials can disagree and the Taylor form breaks.
  • The first-order remainder scales with the squared step times the Hessian size; the second-order remainder with the cubed step.
  • Eigenvalue signs classify: all positive is a strict local minimum, mixed signs a saddle, a zero eigenvalue leaves the test silent.
Common mistakes · 3
  • Calling a stationary point with positive diagonal Hessian entries a minimum. Off-diagonals matter; only definiteness decides.
  • Trusting a Taylor model far from the base point. The remainder grows with powers of the step, so recompute rather than extrapolate.
  • Switching gradient layout mid-derivation. The layout fixes the Jacobian and Hessian shapes, so a silent switch transposes everything.
3

Try it yourself

Closed-book, before checking anything

Closed-book, give the Hessian of , its eigenvalues 1 and 3 from numpy.linalg.eigvalsh, and classify the origin as a strict local minimum since is positive definite. Verify the second-order Taylor model is exact: , and in float64 gives 0.06999999999999999, one ulp (1.4e-17) below.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.For , what is the Jacobian shape and what is its first row?Answer

    in numerator layout. The first row is the (row) gradient of .

  2. 2.Where is the assumption used in the claim that the Hessian is symmetric?Answer

    Continuity of the mixed second partials lets the two differentiation orders agree. The proof step equating the two mixed partials uses exactly this continuity.

  3. 3.Approximate with about 0. Give the value, the remainder and a bound.Answer

    , actual value 1.10517092, remainder 0.00517092. With bounding the second derivative on [0, 0.1], , and the remainder satisfies the bound.

  4. 4.Classify the stationary point with Hessian .Answer

    Eigenvalues 1 and 3, both positive, so the Hessian is positive definite and the point is a strict local minimum.

5

Practice

  • TrenTorch: Hessian

    Implement hessian(f, x) as the centered-difference Jacobian of the provided gradient, and classify_critical_point(H) from eigvalsh signs with a tolerance

    Its tests call diag(1e-9, 2) a saddle, but a near-zero eigenvalue leaves the second-derivative test silent: has Hessian diag(0, 2) at its minimum. Pass the tests, then return a fourth label for that case in your own copy.

  • MIT 18.S096 Problem Set 1, Problem 0 ( Jacobian matrices)

    Problem 0, parts (a) to (d): Jacobian matrices of the rotate, hyperbolic rotate, nonlinear shear and warp maps. Official solutions exist; attempt before reading them

    Do the hyperbolic rotation by hand; its Jacobian determinant returns in Problem Set 2, Problem 4(a), which calls it Problem 1b.

You're done when

You write the Jacobian and second-order Taylor of a new map by hand, classify its stationary point, and NumPy eigvalsh plus a remainder evaluation agree.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 3 more in the section

Also in this section

  • Hands-On ML - Autodiff notebookAurelien Geron · required

    Work through numerical differentiation and both AD modes, then rebuild the essential reverse-mode engine independently.

  • PyTorch Autograd mechanicsPyTorch documentation · required

    Consult after the handwritten engine for accumulation, graph behavior, disabled tracking and vector-Jacobian products.

  • CS231n - Linear ClassificationStanford University · support

    Read the Softmax classifier section for the cross-entropy loss formula with both the information-theory and MLE views, and Practical issues: Numeric stability for the max-subtraction trick. Derive the softmax gradient by hand; do not implement the course assignment here.