Linear Algebra
16.98 min read

Hessians and Convexity

For differentiable functions, there is a beautiful Hessian-based test for convexity — a global version of the second derivative test.

The theorem: a D2D^2 function ff over a convex domain is convex if and only if its Hessian Hf(x)Hf(\mathbf{x}) is PSD at every point. If the Hessian is everywhere PD, then ff is strictly convex (but not vice versa — the converse fails).

Compare this to the second derivative test: there, having a PSD Hessian at one specific critical point tells us very little. Here, knowing the Hessian is PSD everywhere is much stronger — it gives global convexity.

Combined with the convexity-implies-global-minimum theorem: if you find a critical point of a function whose Hessian is everywhere PSD, you have found the global minimum. Gradient descent wins the game.

Formal View

Theorem 16.6 — Hessian Criterion for Convexity
Let ff be twice differentiable over a convex domain CC. Then:
f is convex    Hf(x) is PSD for all xint(C)f \text{ is convex} \iff Hf(\mathbf{x}) \text{ is PSD for all } \mathbf{x} \in \text{int}(C)
If Hf(x)Hf(\mathbf{x}) is PD everywhere, then ff is strictly convex (but not conversely).
Remark 16.1 — Why PSD Everywhere Differs from the Second Derivative Test
In the second derivative test, a PSD (but not PD) Hessian at one critical point is inconclusive — error terms can tip either way. But PSD everywhere in a convex domain locks in convexity globally. The "flat direction" in any local quadratic cannot create a local minimum that is not global, because convexity of the domain rules it out.

Why This Matters

This criterion is how you verify that a problem is convex — and once verified, you know gradient descent will find the global optimum.

  • Verifying ML loss functions are convex: check Hessian is globally PSD
  • Least squares: Hessian is AtAA^t A (PSD everywhere) → unique global min
  • Neural networks: non-convex loss landscape — Hessian is indefinite at many points
  • Convex relaxations: approximate a non-convex problem with one having a PSD Hessian

Quiz

Question 1

A D2D^2 function ff on a convex domain is convex if and only if:

Question 2

If HfHf is PD everywhere, then ff is strictly convex.

Question 3

For f(x)=x4f(x) = x^4, is ff convex on R\mathbb{R}?

Question 4

You find a critical point of ff and verify HfHf is everywhere PSD. The critical point is:

Question 5

The least squares objective f(x)=Axb2f(\mathbf{x}) = \|A\mathbf{x} - \mathbf{b}\|^2 is convex.

Common Mistakes

  • Confusing "PSD at a critical point (inconclusive 2nd derivative test)" with "PSD everywhere (convex function)" — these are very different claims.
  • Thinking PD everywhere is required for convexity — PSD everywhere suffices.
  • Assuming a convex function must have a global minimum — it might not (e.g., f(x)=exf(x) = e^x on R\mathbb{R} has no minimum).