Linear Algebra
12.117 min read

Fermat's Theorem

Fermat's theorem is a fundamental result connecting local extrema to critical points: if ff has a local minimum or maximum at a\mathbf{a} and is differentiable at a\mathbf{a}, then f(a)=0\nabla f(\mathbf{a}) = \mathbf{0}.

The proof is elegant: if ff has a local minimum at a\mathbf{a}, then moving in any direction u\mathbf{u} cannot decrease ff locally. But moving in direction u\mathbf{u} changes ff at rate Duf(a)D_\mathbf{u} f(\mathbf{a}), while moving in u-\mathbf{u} changes it at rate Duf(a)-D_\mathbf{u} f(\mathbf{a}). For both to be nonnegative, we need Duf(a)=0D_\mathbf{u} f(\mathbf{a}) = 0 for all u\mathbf{u}, which means f(a)=0\nabla f(\mathbf{a}) = \mathbf{0}.

Fermat's theorem transforms the optimization problem of finding local minima into the algebraic problem of solving f=0\nabla f = \mathbf{0}. It does NOT say every critical point is a local extremum — only the converse.

Formal View

Theorem 12.7 (Fermat's Theorem) — Necessary Condition for Local Extrema
If f:DRnRf: D \subseteq \mathbb{R}^n \to \mathbb{R} is differentiable at aint(D)\mathbf{a} \in \text{int}(D) and a\mathbf{a} is a local minimum or maximum of ff, then f(a)=0\nabla f(\mathbf{a}) = \mathbf{0}.

This gives a necessary but not sufficient condition. The set of critical points contains all local extrema, but may also contain saddle points.

Why This Matters

Fermat's theorem is the foundation of all calculus-based optimization: it reduces finding extrema to solving a system of equations.

  • Maximum likelihood estimation: set derivative of log-likelihood to zero
  • Lagrange multiplier method: derived using Fermat's theorem on a modified objective
  • Physics: equilibrium conditions (e.g., minimum energy) are critical point conditions

Quiz

Question 1

Fermat's theorem states that if a\mathbf{a} is a local minimum of a differentiable ff, then:

Question 2

Fermat's theorem gives a sufficient condition: every critical point is a local minimum.

Common Mistakes

  • Reversing Fermat's theorem: concluding that every critical point is a local extremum.
  • Forgetting that Fermat's theorem requires differentiability — it fails for functions like x|x| at x=0x=0.
  • Applying to boundary points — Fermat's theorem applies only to interior points of the domain.