Mathematical Foundations

The Hessian & Curvature

The gradient tells you which way is downhill. The Hessian tells you the shape of the ground — bowl, dome, or saddle — and that shape is what lets Newton's method leap straight to the bottom.

Prerequisites: single-variable derivatives + what a 2×2 matrix is. That's it. Everything else we build.
8
Chapters
6+
Simulations
0
Assumed Knowledge

Chapter 0: The Gradient Isn't Enough

You're standing somewhere on a hilly landscape in thick fog. You crouch down and feel the ground tilt under your boots. That tilt — the gradient — tells you which way is downhill and how steep it is. Good. You step that way.

But the gradient hides something crucial. Imagine you walk until the ground feels perfectly flat — zero tilt in every direction. The gradient is now the zero vector. Have you reached the bottom of a valley? Maybe. Or maybe you're balanced on the very top of a dome, about to roll off. Or maybe you're at a mountain pass — flat along the trail but dropping away on both sides into different valleys.

All three of these places have exactly the same gradient: zero. The gradient cannot tell them apart. To know whether flat ground is a bottom, a top, or a pass, you need to know how the slope is changing around you — you need the curvature.

The trap: beginners think "gradient zero means minimum." It doesn't. Zero gradient means you're at a critical point — flat ground — but flat ground comes in three flavors: minimum (bowl), maximum (dome), and saddle (pass). The gradient is blind to which one. Curvature is what sees the difference.

What Curvature Means

In one dimension you already know this story. Take f(x). The first derivative f′(x) is the slope. The second derivative f″(x) tells you how the slope is changing — whether the curve is bending up like a smile (f″ > 0, a bowl) or bending down like a frown (f″ < 0, a dome).

At a flat point where f′(x) = 0, that second derivative settles the question. f″ > 0 means a minimum, f″ < 0 means a maximum. This is the second-derivative test from single-variable calculus, and you've probably used it without thinking of it as "curvature."

The whole job of this lesson is to carry that idea up into two (and then many) dimensions. In 2D a surface can curve differently in different directions — up along one axis, down along another (that's the saddle). To capture all of that curvature information we need not a single number but a small matrix of second derivatives. That matrix is the Hessian, named after the mathematician Otto Hesse.

Three flat points, three different fates

Drag the slider to roll a marble down each surface from its flat spot. All three have zero gradient at the center. Watch what the curvature does to the marble.

push 0

Notice: in the bowl the marble returns to center (stable minimum). On the dome it rolls off and never comes back (unstable maximum). On the saddle it depends which way you nudge it — flat along one ridge, falling away the other. Same zero gradient; three completely different behaviors. The behavior is set by the curvature, and the curvature is what the Hessian records.

Where this is going: by the end you'll compute the Hessian of a messy function by hand, read off from it whether you're at a bowl/dome/saddle, and see how Newton's method uses the Hessian to take a single optimal step instead of thousands of timid gradient steps.
You walk until the ground feels perfectly flat in every direction — the gradient is zero. What does this tell you?

Chapter 1: Second Partial Derivatives

Before we can build the Hessian we need its raw ingredients: second partial derivatives. Let's build them from the ground up, with no hand-waving.

First, a partial derivative

A function of two variables, f(x, y), is a landscape: feed it a position (x, y) and it returns a height. A partial derivative measures the slope in one direction while you hold the other variable frozen.

The notation ∂f/∂x (read "partial f partial x", also written fx) means: treat y as a constant number, and differentiate with respect to x as if it were ordinary single-variable calculus. Likewise fy = ∂f/∂y freezes x and differentiates in y.

The "freeze the other variable" rule. When you compute fx, every y in the formula is just a number along for the ride — like the 5 in 5x, whose derivative is 5. When you compute fy, every x is the frozen constant. This single rule is all of multivariable differentiation.

A tiny worked example. Let g(x, y) = x²y. To get gx, freeze y (call it a constant c): g = c·x², so gx = c·2x = 2xy. To get gy, freeze x: g = (x²)·y, a constant times y, so gy = x².

Now go one level deeper

A second partial derivative is just a partial derivative of a partial derivative. Each first partial fx and fy is itself a function of (x, y), so we can differentiate it again. That gives four possible second partials:

SymbolBuilt byWhat it measures
fxx∂/∂x of fxHow the x-slope changes as you move in x — curvature along the x-axis
fyy∂/∂y of fyHow the y-slope changes as you move in y — curvature along the y-axis
fxy∂/∂y of fxHow the x-slope changes as you move in y — the twist
fyx∂/∂x of fyHow the y-slope changes as you move in x — the other twist

The first two, fxx and fyy, are the pure second partials. They are the direct analog of the single-variable f″: fxx > 0 means the surface bends upward (smiles) as you walk along x.

The last two are the mixed second partials, and they carry the genuinely new information. fxy asks: as I take one step in the y-direction, how does my x-slope change? If walking north makes the east-west ground tilt differently, the surface is twisted — and that twist is exactly what distinguishes a saddle from a simple bowl.

Why mixed partials matter. A pure bowl can be built with only fxx and fyy. But a saddle's defining feature — rising one way, falling another, with a twist between them — lives in fxy. Drop the mixed term and you can never describe a tilted saddle correctly.

A full worked computation

Take f(x, y) = x³ + 4x²y. We'll compute all four second partials with every step shown.

Step 1 — first partials.

fx = ∂/∂x (x³ + 4x²y) = 3x² + 8xy   (y frozen)
fy = ∂/∂y (x³ + 4x²y) = 0 + 4x² = 4x²   (x frozen; x³ is constant, derivative 0)

Step 2 — differentiate fx again.

fxx = ∂/∂x (3x² + 8xy) = 6x + 8y
fxy = ∂/∂y (3x² + 8xy) = 0 + 8x = 8x

Step 3 — differentiate fy again.

fyx = ∂/∂x (4x²) = 8x
fyy = ∂/∂y (4x²) = 0   (4x² has no y in it)

Look at fxy = 8x and fyx = 8x. They came out identical, even though we computed them by differentiating in opposite orders. That is not a coincidence — it is a theorem, and it's the subject of the next chapter.

The classic sign slip: when y is frozen and the term is, say, −3xy², the y² is a constant, so ∂/∂x gives −3y² — keep the minus. Forgetting that a frozen variable still carries its sign and exponent is the single most common mistake. Write the frozen variable's value explicitly the first few times until it's automatic.
Slope-of-the-slope, made visible

The curve is a slice of a surface. The orange line is the tangent (first derivative). Drag to move the point and watch how the tangent rotates — the rate it rotates is the second derivative, the curvature.

x -1.00
For f(x, y) = x³ + 4x²y, what is fxy (differentiate fx with respect to y)?

Chapter 2: Assembling the Hessian

We have four second partials. The Hessian simply packages them into a 2×2 grid — and that packaging is what turns a pile of numbers into a single object that describes curvature in every direction at once.

H =   [   fxx    fxy   ]
      [   fyx    fyy   ]

The layout is logical, not arbitrary. Row 1 is "how do my x-derivatives change": fxx (as I move in x) and fxy (as I move in y). Row 2 is the same story for the y-derivatives: fyx and fyy. The diagonal holds the pure curvatures; the off-diagonal holds the twist.

One matrix, all directions. The magic of bundling the curvatures into a matrix H is that you can then ask "how curved is the surface in this direction v?" and get the answer from a single expression, vTHv. The whole curvature of the landscape is encoded in four numbers. We'll cash this in when we classify critical points.

The Hessian is symmetric — Clairaut's theorem

In the last chapter fxy and fyx came out equal. This is guaranteed by Clairaut's theorem (also called Schwarz's theorem):

Clairaut's theorem. If the second partial derivatives of f are continuous (true for every polynomial, exponential, trig, and log function you'll meet), then the mixed partials are equal: fxy = fyx. The order of differentiation does not matter.

Why should the order not matter? Here's the napkin intuition. fxy measures "change in the x-slope as you step in y." fyx measures "change in the y-slope as you step in x." Both are secretly measuring the same thing: the single number that says how much the surface twists as you move diagonally. A smooth surface has one twist at each point, and you can measure it by walking around the little square in either order — you end up at the same corner, so you read the same twist.

The practical payoff: the Hessian is a symmetric matrix. Its top-right entry equals its bottom-left entry, so we usually write it as:

H =   [   fxx    fxy   ]
      [   fxy    fyy   ]

Symmetry is not just tidy bookkeeping. A real symmetric matrix is guaranteed to have real eigenvalues and perpendicular eigenvectors — and those eigenvalues and eigenvectors are precisely the curvatures and the principal directions of the surface. Symmetry is the mathematical reason the curvature story works out cleanly. (If you've met eigenvalues, this will click in Chapter 4.)

A symmetry sanity check, free of charge. After you assemble any Hessian, glance at the two off-diagonal entries. If they aren't identical, you made an arithmetic error somewhere — go back and find it. Clairaut guarantees they must match for any reasonable function, so a mismatch is a built-in bug detector.

A quick numeric assembly

Reusing f(x, y) = x³ + 4x²y from Chapter 1, we found fxx = 6x + 8y, fxy = 8x, fyy = 0. So the Hessian as a function of position is:

H(x, y) =   [   6x+8y    8x   ]
          [   8x       0   ]

The Hessian is a matrix that depends on where you stand. Plug in a point to get a concrete matrix of numbers. At (x, y) = (1, 1):

H(1,1) =   [   6+8    8   ] = [   14    8   ]
           [   8     0   ]      [   8     0   ]

Symmetric (8 = 8 ✓). This is exactly the kind of assembly we'll do for the full assessment function next chapter.

Clairaut's theorem tells us the Hessian is symmetric. Which entries must be equal?

Chapter 3: The Assessment Function, Fully Worked

Time to earn the title. We compute the Hessian of a genuinely messy function — the one from the AA174A assessment — with every single step shown. If you can follow this, you can do any 2D Hessian.

f(x, y) = 2xy + 6x²y − 3xy²

Three terms. Notice each term contains both x and y, so neither partial will ever vanish completely — there's real work in every step. Let's go.

Step 1 — the first partials

Compute fx: freeze y, differentiate in x. Go term by term.

Termy frozen, ∂/∂xResult
2xy2y is the constant on x; derivative of x is 12y
6x²y6y is the constant; ∂/∂x of x² is 2x12xy
−3xy²−3y² is the constant; ∂/∂x of x is 1−3y²
fx = 2y + 12xy − 3y²

Compute fy: freeze x, differentiate in y.

Termx frozen, ∂/∂yResult
2xy2x is the constant; derivative of y is 12x
6x²y6x² is the constant; derivative of y is 16x²
−3xy²−3x is the constant; ∂/∂y of y² is 2y−6xy
fy = 2x + 6x² − 6xy
Gradient so far: ∇f = ( 2y + 12xy − 3y² ,   2x + 6x² − 6xy ). These match the gradient field we'll draw in the Code Lab. Hold onto them.

Step 2 — differentiate fx to get the first Hessian row

We have fx = 2y + 12xy − 3y². Differentiate it twice — once in x (giving fxx), once in y (giving fxy).

fxx = ∂/∂x (2y + 12xy − 3y²): freeze y again.

fxx = 12y

fxy = ∂/∂y (2y + 12xy − 3y²): now freeze x.

fxy = 2 + 12x − 6y

Step 3 — differentiate fy to get the second Hessian row

We have fy = 2x + 6x² − 6xy. Differentiate in x (gives fyx, the symmetry check) and in y (gives fyy).

fyx = ∂/∂x (2x + 6x² − 6xy): freeze y.

fyx = 2 + 12x − 6y

fyy = ∂/∂y (2x + 6x² − 6xy): freeze x.

fyy = −6x
Symmetry check passes. fxy = 2 + 12x − 6y and fyx = 2 + 12x − 6y are identical, exactly as Clairaut promised. If they had differed, that would be the signal to hunt for an arithmetic slip. They match — proceed with confidence.

Step 4 — assemble the Hessian

Drop the four pieces into the 2×2 grid:

H(x, y) =   [   12y       2+12x−6y   ]
           [   2+12x−6y    −6x   ]
This is the answer — PDF answer (a). The Hessian of f = 2xy + 6x²y − 3xy² is
H = [[ 12y , 2+12x−6y ] , [ 2+12x−6y , −6x ]].
The symmetric second-derivative matrix, exactly as computed.

Step 5 — plug in a point and read numbers

The Hessian above is a function of position. To get a concrete matrix, evaluate at a point. Take (x, y) = (1, 1):

H(1,1) =   [   12    8   ]
           [   8  −6   ]

This exact matrix [[12, 8], [8, −6]] is what the Code Lab will reproduce numerically by finite differences. (Spoiler from Chapter 4: with a positive 12 and a negative −6 on the diagonal and a determinant of 12·(−6) − 8·8 = −72 − 64 = −136 < 0, this point is a saddle.)

Evaluate the assessment Hessian anywhere

Drag x and y. The Hessian entries update live from H = [[12y, 2+12x−6y], [2+12x−6y, −6x]]. Watch the determinant flip sign as you cross into saddle territory.

x 1.0
y 1.0
Evaluate the assessment Hessian at (x, y) = (0, 2). What is the top-left entry fxx = 12y?

Chapter 4: Bowl, Dome, or Saddle?

We promised the Hessian could tell apart the three flavors of flat ground. Now we cash that in. The tool is the second-derivative test, and underneath it sits the deeper idea of eigenvalues.

The intuition: eigenvalues are curvatures

A symmetric 2×2 matrix has two real eigenvalues, λ1 and λ2, with perpendicular eigenvectors. For the Hessian, those eigenvectors point along the surface's principal directions — the directions of pure, untwisted curving — and each eigenvalue is the curvature in that direction.

So at a critical point (gradient zero), the two eigenvalue signs decide everything:

λ1, λ2ShapeCritical point
both > 0Bowl — curves up every wayMinimum
both < 0Dome — curves down every wayMaximum
opposite signsSaddle — up one way, down anotherSaddle point
This is the whole story. A minimum is where the surface curves up in both principal directions; a maximum curves down in both; a saddle does one of each. The eigenvalues of the Hessian are literally those two curvatures. Everything else is shortcut arithmetic for reading their signs.

The shortcut: determinant + trace

You rarely need to compute eigenvalues explicitly. Two summary numbers of the 2×2 Hessian H = [[a, b], [b, c]] reveal the signs for free:

det H = ac − b² = λ1λ2      tr H = a + c = λ1 + λ2

The determinant equals the product of the eigenvalues; the trace equals their sum. From a product and a sum you can read both signs:

ConditionMeansVerdict
det H > 0 and a > 0product positive, both same sign, and one is positiveMinimum (both +)
det H > 0 and a < 0product positive, both same sign, one is negativeMaximum (both −)
det H < 0product negative → eigenvalues have opposite signsSaddle
det H = 0an eigenvalue is zero — flat directionInconclusive
Why det < 0 is always a saddle. det H = λ1λ2. A negative product can only happen if the two factors have opposite signs. Opposite signs means up-curve in one principal direction, down-curve in the other — the definition of a saddle. You don't even need the trace in this case.

Worked classification — the assessment point

Recall H(1,1) = [[12, 8], [8, −6]] from Chapter 3. (At this point the gradient is ∇f(1,1) = (2+12−3, 2+6−6) = (11, 2), which is not zero — so strictly this isn't a critical point, but the Hessian still describes the local curvature, and the same arithmetic applies to any point.)

Determinant:

det H = (12)(−6) − (8)(8) = −72 − 64 = −136

det H = −136 < 0. Negative determinant → eigenvalues of opposite sign → saddle-shaped curvature. The surface bends up along one direction and down along the perpendicular one. No need to find the eigenvalues themselves — the sign of the determinant settled it.

If you did want the eigenvalues, solve λ² − (tr)λ + det = 0, i.e. λ² − 6λ − 136 = 0, giving λ = (6 ± √(36 + 544))/2 = 3 ± √145 ≈ 15.0 and −9.0. One up-curvature of about +15, one down-curvature of about −9 — opposite signs, confirming the saddle.

The det-vs-eigenvalue confusion. Students sometimes test "is det > 0?" and declare a minimum. Wrong — det > 0 only says the eigenvalues share a sign. You still need the trace (or just the sign of a = fxx) to know which sign. Positive det + positive fxx = minimum; positive det + negative fxx = maximum. Don't skip the second check.

A clean worked minimum for contrast

Take g(x, y) = x² + 3y². Then gx = 2x, gy = 6y, so the only critical point is (0, 0). The Hessian is constant: H = [[2, 0], [0, 6]]. Here det H = 2·6 − 0 = 12 > 0 and fxx = 2 > 0, so (0,0) is a genuine minimum. The eigenvalues are just 2 and 6 (diagonal matrix) — both positive, both up-curving, a clean bowl. This is the picture in your head whenever you hear "convex."

Read the verdict from a Hessian

Set the three entries of a symmetric Hessian. The widget computes det and trace, infers the eigenvalue signs, and names the critical point. Try to build a saddle (det < 0).

fxx (a)2.0
fxy (b)0.0
fyy (c)6.0
A critical point has Hessian H = [[−4, 1], [1, −9]]. det H = 36 − 1 = 35 > 0 and fxx = −4 < 0. What is it?

Chapter 5: The Curvature Lab

Here's the payoff. A live contour map of a quadratic surface with the Hessian's eigen-directions drawn on top. You set the three Hessian entries; the lab redraws the landscape, overlays the two principal axes (the eigenvectors), and labels the curvature along each (the eigenvalues). Switch between presets to flip instantly between a bowl, a dome, and a saddle.

How to read the contour map. Each closed loop is a "height line" — points of equal value, like elevation lines on a hiking map. Tightly packed rings mean steep, strongly curved ground. Concentric closed rings around the center = a bowl or dome. Hyperbola-shaped lines that open outward in opposite directions = a saddle. The two straight overlaid lines are the eigenvectors: the surface curves purely (no twist) along each of them, by the amount of its eigenvalue.
Curvature Lab — contours + eigen-directions of vᵀHv

The surface is the quadratic form q(x,y) = ½(a·x² + 2b·xy + c·y²), whose Hessian is exactly [[a,b],[b,c]]. Set the entries or hit a preset. The teal/warm lines are the eigenvectors; the badge names the critical point.

a = fxx2.0
b = fxy0.0
c = fyy2.0

Play with it. Start at the default bowl (a = c = 2, b = 0): two positive eigenvalues, concentric rings, the badge reads Minimum. Now drag c down past zero — the moment c goes negative the determinant ac − b² flips sign, the rings tear open into hyperbolas, and the badge snaps to Saddle. You are watching the second-derivative test happen in real time.

Now crank up b, the mixed partial, with a and c fixed and positive. At b = 0 the eigenvectors lie along the axes. As b grows, the eigenvectors rotate off the axes — that's the twist — and once b² exceeds ac the determinant goes negative and even this "two-positive-diagonal" matrix becomes a saddle. This is the concrete reason the mixed partial cannot be ignored: enough twist turns a would-be bowl into a saddle.

The Feynman test for this lesson. If you can predict, before releasing the slider, whether the next drag will keep the rings closed or tear them into a saddle — purely from the sign of ac − b² — then you understand the Hessian. Try to call it three times in a row.
Don't confuse "negative entries" with "saddle." A matrix can have a negative entry on the diagonal and still be a clean dome (e.g. a = c = −2, b = 0: both eigenvalues −2, a maximum). And it can have all-positive entries yet be a saddle if b is big enough (a = c = 1, b = 2: det = 1 − 4 = −3 < 0). The determinant is the honest judge, not the individual signs.

This single widget contains the entire classification chapter as a feeling in your fingertips. There's no quiz here — the lab is the test. If you can drive it to each of the three shapes on demand and explain why, move on.

Chapter 6: Why It Matters — Newton's Method

Gradient descent walks downhill using only the slope. It's blind to curvature, so it has no idea how big a step is safe — too small and it crawls; too big and it overshoots and bounces. The Hessian fixes this by telling the optimizer the shape of the bowl, so it can step straight to the bottom. That algorithm is Newton's method.

The idea: fit a bowl, jump to its bottom

Near any point, a smooth function looks like a quadratic — a bowl (or dome, or saddle). The gradient and the Hessian are exactly the ingredients of that local quadratic. The second-order Taylor expansion around a point x0 is:

f(x) ≈ f(x0) + ∇fT(xx0) + ½(xx0)TH(xx0)

That last term — the one with the Hessian H — is the curvature term. It's what turns a flat tangent-plane approximation (gradient only) into a curved bowl approximation. And the bottom of a bowl is somewhere we can jump to in one shot: set the derivative of the quadratic to zero and solve.

Doing that gives the Newton step:

xnew = x0 − H−1 ∇f

Compare it to a gradient-descent step, xnew = x0 − η∇f. Gradient descent multiplies the gradient by a single scalar guess η. Newton's method multiplies by H−1, the inverse Hessian — a matrix that rescales each direction by its own curvature. Steep directions (big curvature) get a small step; shallow directions (small curvature) get a big step. It's a per-direction, curvature-aware learning rate, derived rather than guessed.

H−1 is the perfect learning rate, one per direction. Where gradient descent uses one timid η for all directions and hopes, Newton reads the true curvature off the Hessian and takes exactly the right step in each principal direction. On a perfect quadratic bowl it lands at the minimum in a single step.

A worked Newton step

Minimize g(x, y) = x² + 3y² starting from (4, 2). The gradient is ∇g = (2x, 6y), and the Hessian is constant: H = [[2, 0], [0, 6]], with inverse H−1 = [[½, 0], [0, ⅜]].

At the start point: ∇g(4, 2) = (8, 12). The Newton step:

H−1∇g = ( ½·8 , ⅜·12 ) = (4, 2)
xnew = (4, 2) − (4, 2) = (0, 0)

One step. Straight to the exact minimum at the origin, no matter where we started, because g is exactly quadratic and Newton fits it perfectly. Gradient descent on the same problem would take dozens of zig-zagging steps because the bowl is stretched (6× steeper in y than x) — and a fixed η can't be right for both axes at once. The Hessian's job is precisely to undo that stretch.

The catch — and why saddles are dangerous here. Newton's method jumps to where the gradient is zero, but that's any critical point — including maxima and saddles! If the Hessian has a negative eigenvalue, Newton can happily march uphill toward a saddle. This is exactly why saddle classification (Chapter 4) matters in practice: real optimizers (e.g. in deep learning) add safeguards — "trust regions," damping, or flipping negative curvature — to avoid being lured to saddles. The Hessian both enables the leap and warns of the trap.
Newton vs. gradient descent on a stretched bowl

Same start point, same function g = x² + k·y². Watch gradient descent (warm, timid η) zig-zag while Newton (teal) lands in one curvature-aware step. Crank the stretch k to make gradient descent suffer.

stretch k6.0
GD rate η0.12
What does multiplying the gradient by H−1 (instead of a scalar η) buy Newton's method?

Chapter 7: Cheat Sheet & Connections

Everything in one place. If you internalize this table, you can compute and classify any 2D Hessian, and you know what it's for.

The recipe

StepWhat to do
1. First partialsfx (freeze y), fy (freeze x). Each frozen variable is a constant — keep its sign and exponent.
2. Second partialsDifferentiate fx in x → fxx, in y → fxy. Differentiate fy in y → fyy.
3. AssembleH = [[fxx, fxy], [fxy, fyy]]. Check the off-diagonals match (Clairaut).
4. EvaluatePlug in the point to get a matrix of numbers.
5. Classifydet = ac − b². det < 0 → saddle. det > 0 & a > 0 → min. det > 0 & a < 0 → max. det = 0 → inconclusive.

Key facts

ObjectMeaning
H = [[fxx, fxy], [fxy, fyy]]Symmetric matrix of second partials — curvature in all directions.
Clairaut: fxy = fyxMixed partials are equal → H is symmetric. Free bug-check.
Eigenvalues λ1, λ2The two principal curvatures. Signs decide bowl/dome/saddle.
det H = λ1λ2, tr H = λ12Product and sum of curvatures — read signs without solving.
Newton step: −H−1∇fCurvature-aware step; one move to the min of a quadratic.

The assessment answer, boxed

f = 2xy + 6x²y − 3xy²

H =   [   12y       2+12x−6y   ]
       [   2+12x−6y    −6x   ]
That's PDF answer (a) — the symmetric matrix of second partials, with the mixed partial 2+12x−6y repeated off-diagonal exactly as Clairaut requires.

Beyond 2D — the n×n Hessian

For a function of n variables, the Hessian is an n×n symmetric matrix Hij = ∂²f / ∂xi∂xj. Everything generalizes: it's still symmetric (Clairaut), its n eigenvalues are still the principal curvatures, all-positive eigenvalues still means a minimum (the matrix is "positive definite"), and the Newton step is still −H−1∇f. In machine learning the Hessian of the loss with respect to millions of weights is too big to store, so methods like L-BFGS and Adam approximate its curvature information — but the idea you learned here is exactly what they're chasing.

Where to go next

The thread of this lesson: the gradient is a vector that points downhill; the Hessian is a matrix that describes the shape of the hill. Slope tells you which way; curvature tells you what kind of place you're in and how far to step.

"What I cannot create, I do not understand." — Richard Feynman.
You computed the Hessian by hand, classified it, and watched Newton use it. You can now create it.

Code Lab — Hessian by finite differences, checked against the hand answer

Compute the Hessian of the assessment function numerically and confirm it matches H=[[12y, 2+12x−6y],[2+12x−6y, −6x]]. Then draw the gradient field. Press Run (Python boots once, ~5s).

Exercises & Workbook

The lesson showed you the Hessian. This workbook makes you produce it — every exercise asks you to derive a partial, trace a classification, build a function, design a saddle, or debug a sign slip. Work them with a pencil; the answers check your arithmetic and every reveal walks the full path. Nothing is a placeholder.

Mastery
0 / 34 exercises (0%)
0
Day Streak
Best: 0

Part A — Partials, frozen variables, and the four pieces

Everything starts with "freeze the other variable." These build the four second partials before you ever touch the matrix.

A.1 — What a partial measures Trace
When you compute fx, what do you do with y?
A.2 — A pure second partial Derive

For f = 3x²y, compute fxx and evaluate it at (x,y) = (1, 2). Enter the number.

fxx
Show derivation
fx = ∂/∂x (3x²y) = 6xy  (y frozen)
fxx = ∂/∂x (6xy) = 6y → at (1,2): 6·2 = 12

fxx = 6y is independent of x, so only y matters.

A.3 — A mixed partial Derive

For f = 3x²y, compute the mixed partial fxy and evaluate at (x,y) = (1, 2). Enter the number.

fxy
Show derivation
fx = 6xy ⇒ fxy = ∂/∂y (6xy) = 6x → at (1,2): 6·1 = 6

fxy = 6x depends on x, not y — opposite of fxx.

A.4 — The sign-keeping trap Trace
For the term −3xy², what is its contribution to fx (y frozen)?
A.5 — fyy of the assessment function Derive

For f = 2xy + 6x²y − 3xy², compute fyy as a formula, then evaluate at (x,y) = (2, 5). Enter the number.

fyy
Show derivation
fy = 2x + 6x² − 6xy ⇒ fyy = −6x
at (2,5): −6·2 = −12  (y doesn't appear, so the 5 is irrelevant)
A.6 — fxx of the assessment function Derive

For f = 2xy + 6x²y − 3xy², fxx = 12y. Evaluate at (x,y) = (3, −1). Enter the number.

fxx
Show derivation
fx = 2y + 12xy − 3y² ⇒ fxx = 12y
at (3,−1): 12·(−1) = −12
A.7 — The mixed partial as a formula Derive

For the assessment f, fxy = 2 + 12x − 6y. Evaluate at (x,y) = (1, 1). Enter the number.

fxy
Show derivation
2 + 12·1 − 6·1 = 2 + 12 − 6 = 8

This is the off-diagonal of H(1,1) = [[12,8],[8,−6]].

A.8 — Build a Hessian function Build

Write fxx(x,y) for f = x²y + y³. (fx = 2xy, so fxx = 2y.)

Show solution
function fxx(x, y) { return 2 * y; }

f = x²y + y³ → fx = 2xy → fxx = 2y. The y³ term has no x, so it drops.

Part B — Assemble the matrix & verify symmetry

Four numbers into a 2×2 grid — and always confirm Clairaut.

B.1 — Layout of H Trace
Which entry sits in the top-right corner of H = [[?,?],[?,?]]?
B.2 — Clairaut as a bug check Trace
You compute fxy = 4x and fyx = 4x + 2. What does this tell you?
B.3 — Evaluate H at a point Derive

For the assessment H = [[12y, 2+12x−6y],[2+12x−6y, −6x]], find the bottom-right entry fyy at (x,y) = (−2, 7). Enter the number.

fyy
Show derivation
fyy = −6x = −6·(−2) = 12
B.4 — Full assembly at the origin Derive

Evaluate the assessment H at (x,y) = (0, 0). All three distinct entries: fxx=12y, fxy=2+12x−6y, fyy=−6x. Enter the off-diagonal entry fxy.

fxy
Show derivation
fxy(0,0) = 2 + 12·0 − 6·0 = 2
So H(0,0) = [[0, 2],[2, 0]] — det = −4 < 0, a saddle at the origin.
B.5 — Hessian of a Gaussian-like term Derive

For f = x² + xy + y², the Hessian is constant. Enter its fxy entry.

fxy
Show derivation
fx = 2x + y ⇒ fxy = 1
H = [[2, 1],[1, 2]] (constant)
B.6 — Build a symmetry checker Build

Write isSym(a,b,c,d) for H=[[a,b],[c,d]], returning true iff b equals c (within 1e-9).

Show solution
function isSym(a, b, c, d) { return Math.abs(b - c) < 1e-9; }

Part C — det, trace, and the second-derivative test

Read bowl / dome / saddle straight off the matrix.

C.1 — Determinant of a 2×2 Derive

Compute det of H = [[5, 2],[2, 3]]. Enter the number.

det
Show derivation
det = ac − b² = 5·3 − 2² = 15 − 4 = 11
C.2 — Classify a bowl Trace
H = [[4, 1],[1, 3]]: det = 12−1 = 11 > 0, fxx = 4 > 0. This critical point is a:
C.3 — Classify a saddle Trace
H = [[2, 5],[5, 2]]: det = 4 − 25 = −21 < 0. This is a:
C.4 — The maximum case Trace
H = [[−3, 0],[0, −7]]: det = 21 > 0, fxx = −3 < 0. This is a:
C.5 — Determinant of the assessment point Derive

H(1,1) = [[12, 8],[8, −6]]. Compute det H. Enter the number.

det
Show derivation
det = (12)(−6) − (8)(8) = −72 − 64 = −136 < 0 ⇒ saddle curvature
C.6 — Eigenvalues from trace & det Derive

For H = [[2, 0],[0, 6]], the eigenvalues are the diagonal. Enter the larger eigenvalue.

λ
Show derivation
Diagonal matrix ⇒ eigenvalues 2 and 6. Both positive ⇒ minimum (a bowl).
C.7 — The inconclusive case Trace
H = [[1, 1],[1, 1]]: det = 1 − 1 = 0. The second-derivative test says:
C.8 — Build a classifier Build

Write classify(a,b,c) for H=[[a,b],[b,c]] returning "min", "max", "saddle", or "flat" using det = ac−b².

Show solution
function classify(a, b, c) {
  const det = a*c - b*b;
  if (det < 0) return 'saddle';
  if (det === 0) return 'flat';
  return a > 0 ? 'min' : 'max';
}

Part D — Design functions with chosen curvature

Reverse the process: build a function whose Hessian does what you want.

D.1 — Design a saddle at the origin Design

You want f with a saddle at (0,0): up along x, down along y. The classic is f = x² − y². Enter fxx for this f (it's constant).

fxx
Show derivation
f = x² − y² ⇒ H = [[2, 0],[0, −2]], det = −4 < 0 — a saddle. fxx = 2.

Up-curve +2 along x, down-curve −2 along y — the textbook saddle.

D.2 — Design a bowl with target curvature Design

You want a bowl (min at origin) that is 5× steeper in x than in y, with fyy = 2. Using f = a·½x² + ½·2·y², enter the fxx you need.

fxx
Show derivation
5× steeper than fyy=2 means fxx = 5·2 = 10. Both positive ⇒ bowl. f = 5x² + y² works.
D.3 — Turn a bowl into a saddle with twist Design

Start from H = [[1, b],[b, 1]] (a = c = 1). What is the smallest |b| that makes it a saddle (det < 0)? Enter the threshold value of b above which it becomes a saddle.

b
Show derivation
det = 1·1 − b² = 1 − b². det < 0 ⇔ b² > 1 ⇔ |b| > 1.

Even with both diagonal entries positive, enough mixed-partial twist tears the bowl into a saddle.

D.4 — Design a degenerate (flat) direction Design

You want H = [[4, b],[b, 1]] to have det = 0 (a flat eigen-direction). Enter the positive b that achieves it.

b
Show derivation
det = 4·1 − b² = 0 ⇒ b² = 4 ⇒ b = 2. One eigenvalue is exactly 0 — a flat valley floor.
D.5 — Build a monkey-saddle test Design

For f = x³ − 3xy² (the "monkey saddle"), the Hessian at the origin is the zero matrix. Enter det H(0,0).

det
Show derivation
fxx = 6x, fyy = −6x, fxy = −6y. At (0,0): all zero ⇒ H = [[0,0],[0,0]], det = 0.

The test is inconclusive here — you'd need third derivatives. A vivid reminder that det = 0 means "look closer."

Part E — Debug the broken computation

Each card has a planted bug. Find the wrong line.

E.1 — Sign slip in a partial Debug

A student computes fx for f = 2xy + 6x²y − 3xy². Which line is wrong?

E.2 — Lost the chain rule Debug

Computing fyy for −3xy²: a student writes ∂/∂y(−3xy²) = −3x. Then fyy = 0. What's wrong?

E.3 — Determinant sign error Debug

For H = [[3, 4],[4, 3]] a student writes det = 3·3 + 4·4 = 25 > 0, "minimum." Which step is the bug?

E.4 — Skipped the second check Debug

H = [[−5, 0],[0, −2]]: det = 10 > 0, so a student concludes "minimum." What did they forget?

E.5 — Wrong Newton sign Debug

A student writes the Newton step as xnew = x0 + H−1∇f. Why does it diverge on a bowl?

E.6 — Off-diagonal mismatch Debug

A student assembles H = [[12y, 2+12x−6y],[2+12x, −6x]] for the assessment function. Which entry is wrong?

E.7 — Constant mistaken for variable Debug

Computing fxx for fx = 2y + 12xy − 3y², a student gets fxx = 2 + 12y − 6y. What's wrong?

You can now create, not just recognize. Across 34 exercises you computed partials with frozen variables, assembled and symmetry-checked the Hessian, classified bowls, domes, and saddles by determinant, designed functions with chosen curvature, and debugged the classic sign and Clairaut slips. That is the Feynman bar: what you can build, you understand.