Critical Points and Extrema

Suppose you are designing a metal container and want to know where its temperature is hottest. Or you are modeling a landscape and want to find every summit and basin. In each case you face the same question. Given a scalar function of several variables, where can it possibly attain a maximum or minimum value? Single-variable calculus answers this with the vanishing-derivative test. The multivariable world needs a genuine generalization. A function of several variables can fail to have an extremum at a point in far more intricate ways than a function of one variable can. This article develops the first-order machinery for locating candidates for local extrema of a function of several real variables. It introduces the notion of a critical point (or stationary point). It also proves the theorem that every interior local extremum of a differentiable function must occur at such a point. We also confront the subtlety that a domain's boundary is invisible to the gradient. The interior test says nothing about points on the edge of the domain. These must be examined separately, often by restricting the function to the boundary. The argument is then repeated one dimension down. The big picture is that "critical point" is a necessary condition, not a sufficient one. It flags candidates, but does not by itself distinguish maxima from minima from saddle points. That finer classification is the job of the second-derivative (Hessian) test. When the domain has constraints baked in, it is the job of Lagrange multipliers. Both of these are set up in this article but not resolved. This deliberately leaves the story open at its natural cliffhanger. By the end, you will have a precise definition of local extremum and critical point for functions f:Rn→Rf:\mathbb{R}^n\to\mathbb{R}. You will also have a fully proved theorem (Fermat's theorem in several variables) pinning interior extrema to critical points. There is a worked classification of stationary points. This includes one that is neither a max, min, nor simple saddle in the naive sense. Finally, there is a clear-eyed discussion of what goes wrong at boundaries and at points of non-differentiability.

Key takeaways
  • A local extremum of ff at an interior point a\mathbf{a} requires ∇f(a)=0\nabla f(\mathbf{a}) = \mathbf{0}, provided ff is differentiable there.
  • Points where ∇f=0\nabla f = \mathbf{0} (or the gradient fails to exist) are called critical points; they are only candidates for extrema.
  • The proof reduces the vector claim to the single-variable Fermat's theorem, applied along each coordinate direction.
  • Not every critical point is an extremum: saddle points exist, and the gradient test cannot tell them apart from maxima or minima.
  • Boundary points are exempt from the gradient condition — extrema on a closed domain's boundary must be found by separately analyzing the restriction of ff to that boundary.
  • Non-differentiable points (corners, cusps) must also be checked directly; they are critical points too, but the gradient-vanishing argument does not apply to them.
  • Key idea: critical points are where the gradient offers no preferred direction of increase or decrease — a necessary, not sufficient, signature of a local extremum.

Where this lives today

Critical point analysis via the vanishing gradient is the entry point for optimization in every quantitative discipline. In machine learning, training a model by minimizing a loss function L(w)L(\mathbf w) over weights w\mathbf w relies on the same first-order condition: gradient descent moves iteratively toward points where ∇L≈0\nabla L \approx \mathbf 0, and understanding saddle points (which are ubiquitous in high-dimensional loss landscapes) is central to why plain gradient descent can stall. In economics, utility- and profit-maximization problems set the gradient of a utility or profit function to zero to find optimal consumption or production bundles, often then layering budget constraints via Lagrange Multipliers. In physics, equilibrium configurations of a system (e.g. the shape of a hanging chain, or the resting position of a mechanical system) are critical points of a potential energy function, with stability determined by the second-order behavior mentioned above via The Hessian Matrix. In engineering design, minimizing material stress, cost functions, or drag subject to structural constraints again begins by finding the critical points of a differentiable objective. In statistics, maximum-likelihood estimation finds parameter values maximizing a likelihood function, again by solving ∇θℓ(θ)=0\nabla_{\theta} \ell(\theta) = \mathbf 0 for the log-likelihood ℓ\ell. And in numerical analysis and scientific computing, root-finding methods (Newton's method in several variables) are frequently deployed precisely to solve the critical-point equation ∇f=0\nabla f = \mathbf 0 when it cannot be solved in closed form, as illustrated in the boundary calculation of Example 2.

Ask the tutor: How does the second-derivative (Hessian) test decide whether a critical point is a max, min, or saddle?

DefinitionLocal extrema and critical points

Let U⊆RnU \subseteq \mathbb{R}^n be an open set (or more generally the domain of ff), and let f:U→Rf : U \to \mathbb{R}.

Local maximum / minimum. A point a∈U\mathbf{a} \in U is a local maximum of ff if there exists δ>0\delta > 0 such that

f(x)≤f(a)for all x∈U with ∥x−a∥<δ.f(\mathbf{x}) \le f(\mathbf{a}) \quad \text{for all } \mathbf{x} \in U \text{ with } \|\mathbf{x} - \mathbf{a}\| < \delta.

It is a local minimum if the inequality is reversed, and a local extremum if it is either. The extremum is strict if the inequality is strict for x≠a\mathbf{x} \ne \mathbf{a}.

Interior point. A point a∈U\mathbf{a} \in U is an interior point of UU if some open ball B(a,δ)⊆UB(\mathbf{a}, \delta) \subseteq U. If UU is open, every point of UU is interior; if UU has a boundary (e.g. UU is a closed disk), points on ∂U\partial U are not interior.

Critical point. Suppose a\mathbf{a} is an interior point of the domain of ff. Then a\mathbf{a} is a critical point (or stationary point) of ff if either: 1. ff is differentiable at a\mathbf{a} and ∇f(a)=0\nabla f(\mathbf{a}) = \mathbf{0}, or 2. ff is not differentiable at a\mathbf{a}. A critical point of type (1) is called a stationary point; some authors reserve "critical point" for type (1) only and treat non-differentiability points separately. We use the broader convention because both types must be checked when hunting for extrema.

Intuition

In one variable, a smooth curve y=f(x)y = f(x) has a horizontal tangent line at a local max or min — the derivative vanishes because the curve momentarily "levels off." In several variables, the graph of ff is a surface (or hypersurface), and the analogous statement is that the tangent plane is horizontal: every directional derivative at a\mathbf{a} vanishes, which forces the entire gradient vector to vanish, since the gradient encodes all directional information at once. Picture a mountain range. At a summit, walking in any direction takes you downhill (or keeps you level, right at the peak) — there is no direction of ascent. At a mountain pass (a saddle point between two peaks), the gradient is also zero, yet walking along the ridge keeps you level or takes you up, while walking across the ridge takes you down. The gradient vanishing only tells you that to first order, no direction is preferred; it cannot by itself distinguish a summit from a pass from a basin. That distinction needs second-order information — the subject of The Hessian Matrix. The other crucial geometric fact: this entire argument is a purely interior phenomenon. If you are standing at the edge of a plateau that has been cut off by a fence (the boundary of the domain), the ground might slope steeply upward just beyond the fence — but you cannot walk there. The function can be increasing at the boundary point in the "forbidden" direction, so the gradient there need not vanish at all, yet the point can still be a genuine (constrained) local max or min of ff restricted to the domain.

Figure
Critical points of f(x,y)f(x,y): a max, a min, and a saddle, shown via level curves
local max ∇f = 0 rings decrease outward local min ∇f = 0 rings increase outward saddle point up along blue, down along red
TheoremFermat's theorem for functions of several variables

Let U⊆RnU \subseteq \mathbb{R}^n be open, let f:U→Rf : U \to \mathbb{R}, and let a∈U\mathbf{a} \in U. Suppose: 1. a\mathbf{a} is a local extremum of ff (a local maximum or a local minimum), and 2. ff is differentiable at a\mathbf{a}, i.e. all partial derivatives ∂f/∂xi(a)\partial f/\partial x_i(\mathbf{a}) exist and

f(a+h)=f(a)+∇f(a)⋅h+o(∥h∥)as h→0.f(\mathbf{a} + \mathbf{h}) = f(\mathbf{a}) + \nabla f(\mathbf{a}) \cdot \mathbf{h} + o(\|\mathbf{h}\|) \quad \text{as } \mathbf{h} \to \mathbf{0}.

Then

∇f(a)=0.\nabla f(\mathbf{a}) = \mathbf{0}.
Proof

We use the technique of reduction to one variable: restrict ff along each coordinate axis through a\mathbf{a} and invoke the single-variable Fermat theorem, which we take as known (it is the statement that a differentiable function of one real variable has zero derivative at an interior local extremum, proved directly from the definition of the derivative and the sign of difference quotients).

Step 1 — Set up single-variable restrictions. Since UU is open and a∈U\mathbf{a} \in U, there is δ>0\delta > 0 with B(a,δ)⊆UB(\mathbf{a}, \delta) \subseteq U. Fix an index i∈{1,…,n}i \in \{1, \dots, n\} and define gi:(−δ,δ)→Rg_i : (-\delta, \delta) \to \mathbb{R} by

gi(t)=f(a+tei),g_i(t) = f(\mathbf{a} + t\mathbf{e}_i),

where ei\mathbf{e}_i is the ii-th standard basis vector. This is well defined because a+tei∈B(a,δ)⊆U\mathbf{a} + t\mathbf{e}_i \in B(\mathbf{a},\delta) \subseteq U for ∣t∣<δ|t| < \delta.

Step 2 — gig_i inherits the local extremum at t=0t = 0. Suppose a\mathbf{a} is a local maximum of ff, witnessed by radius δ\delta as in the definition (shrink the δ\delta above if necessary so both conditions hold on the same ball). Then for all x∈B(a,δ)\mathbf{x} \in B(\mathbf{a}, \delta),

f(x)≤f(a).f(\mathbf{x}) \le f(\mathbf{a}).

In particular, taking x=a+tei\mathbf{x} = \mathbf{a} + t\mathbf{e}_i for ∣t∣<δ|t| < \delta, which lies in B(a,δ)B(\mathbf{a},\delta) since ∥tei∥=∣t∣<δ\|t\mathbf{e}_i\| = |t| < \delta, we get

gi(t)=f(a+tei)≤f(a)=gi(0)for all ∣t∣<δ.g_i(t) = f(\mathbf{a} + t\mathbf{e}_i) \le f(\mathbf{a}) = g_i(0) \quad \text{for all } |t| < \delta.

Hence t=0t = 0 is a local maximum of gig_i on the open interval (−δ,δ)(-\delta, \delta). (If instead a\mathbf{a} is a local minimum of ff, the same argument with the inequality reversed shows t=0t=0 is a local minimum of gig_i.)

Step 3 — gig_i is differentiable at 00, with derivative equal to a partial derivative of ff. By hypothesis ff is differentiable at a\mathbf{a}, so the partial derivative ∂f/∂xi(a)\partial f/\partial x_i(\mathbf{a}) exists. By definition,

∂f∂xi(a)=lim⁡t→0f(a+tei)−f(a)t=lim⁡t→0gi(t)−gi(0)t=gi′(0).\frac{\partial f}{\partial x_i}(\mathbf{a}) = \lim_{t \to 0} \frac{f(\mathbf{a} + t\mathbf{e}_i) - f(\mathbf{a})}{t} = \lim_{t\to 0} \frac{g_i(t) - g_i(0)}{t} = g_i'(0).

So gig_i is differentiable at t=0t=0 and gi′(0)=∂f/∂xi(a)g_i'(0) = \partial f/\partial x_i(\mathbf{a}).

Step 4 — Apply the one-variable Fermat theorem. We have shown gig_i is a real-valued function of one real variable, differentiable at the interior point 00 of its domain (−δ,δ)(-\delta,\delta), with a local extremum at t=0t=0. By the one-variable Fermat theorem,

gi′(0)=0.g_i'(0) = 0.

Combined with Step 3, this gives

∂f∂xi(a)=0.\frac{\partial f}{\partial x_i}(\mathbf{a}) = 0.

Step 5 — Range over all coordinates. Steps 1–4 did not depend on which index i∈{1,…,n}i \in \{1,\dots,n\} we chose. Hence ∂f/∂xi(a)=0\partial f/\partial x_i(\mathbf{a}) = 0 for every i=1,…,ni = 1, \dots, n. Since

∇f(a)=(∂f∂x1(a),…,∂f∂xn(a)),\nabla f(\mathbf{a}) = \left( \frac{\partial f}{\partial x_1}(\mathbf{a}), \dots, \frac{\partial f}{\partial x_n}(\mathbf{a}) \right),

this exactly says ∇f(a)=0\nabla f(\mathbf{a}) = \mathbf{0}. ■\blacksquare

∎
CorollaryNecessary condition for extrema

If f:U→Rf: U \to \mathbb{R} (UU open) attains a local extremum at a∈U\mathbf{a} \in U, then a\mathbf{a} is a critical point of ff: either ff is not differentiable at a\mathbf{a}, or ∇f(a)=0\nabla f(\mathbf{a}) = \mathbf{0}.

Proof

This is the contrapositive-free restatement of the theorem: if ff is differentiable at a\mathbf{a}, the theorem forces ∇f(a)=0\nabla f(\mathbf{a}) = \mathbf{0}. If ff is not differentiable at a\mathbf{a}, then a\mathbf{a} is a critical point by clause (2) of the definition directly, with nothing further to prove. Either way a\mathbf{a} is a critical point. ■\blacksquare

∎

Worked examples

Example 1: A saddle disguised in cross-terms. Let f(x,y)=x3−3xy2+2yf(x,y) = x^3 - 3xy^2 + 2y on R2\mathbb{R}^2. Find all critical points and determine, using only elementary reasoning (not yet the Hessian test), which ones cannot be extrema. Solution. Compute the gradient:

∂f∂x=3x2−3y2,∂f∂y=−6xy+2.\frac{\partial f}{\partial x} = 3x^2 - 3y^2, \qquad \frac{\partial f}{\partial y} = -6xy + 2.

Setting both to zero:

3x2−3y2=0  ⟹  x2=y2  ⟹  y=±x,3x^2 - 3y^2 = 0 \implies x^2 = y^2 \implies y = \pm x,
−6xy+2=0  ⟹  xy=13.-6xy + 2 = 0 \implies xy = \tfrac{1}{3}.

Case y=xy = x: then x2=1/3x^2 = 1/3, so x=±1/3x = \pm 1/\sqrt3, giving points (13,13)\left(\tfrac{1}{\sqrt3}, \tfrac{1}{\sqrt3}\right) and (−13,−13)\left(-\tfrac{1}{\sqrt3}, -\tfrac{1}{\sqrt3}\right). Case y=−xy = -x: then xy=−x2=1/3xy = -x^2 = 1/3 forces x2=−1/3x^2 = -1/3, impossible for real xx. So this case contributes no real solutions. Thus ff has exactly two critical points:

P1=(13,13),P2=(−13,−13).P_1 = \left(\tfrac{1}{\sqrt3}, \tfrac{1}{\sqrt3}\right), \qquad P_2 = \left(-\tfrac{1}{\sqrt3}, -\tfrac{1}{\sqrt3}\right).

Now examine P1P_1 directly. Along the line y=xy = x near P1P_1, write x=13+tx = \tfrac{1}{\sqrt3} + t, y=13+ty = \tfrac{1}{\sqrt3} + t:

f(x,x)=x3−3x⋅x2+2x=−2x3+2x.f(x,x) = x^3 - 3x\cdot x^2 + 2x = -2x^3 + 2x.

Let h(x)=−2x3+2xh(x) = -2x^3 + 2x. Then h′(x)=−6x2+2h'(x) = -6x^2 + 2, and at x0=1/3x_0 = 1/\sqrt3, h′(x0)=−6(1/3)+2=0h'(x_0) = -6(1/3) + 2 = 0 — consistent with P1P_1 being critical along this slice too. But h′′(x)=−12xh''(x) = -12x, so h′′(x0)=−12/3<0h''(x_0) = -12/\sqrt3 < 0: along the line y=xy=x, ff has a strict local max at P1P_1. Now look along the line x=13x = \tfrac{1}{\sqrt3} fixed, varying yy near y0=1/3y_0 = 1/\sqrt3:

f(13,y)=133−3 y2+2y=:k(y).f\left(\tfrac{1}{\sqrt3}, y\right) = \frac{1}{3\sqrt3} - \sqrt3\, y^2 + 2y =: k(y).

Then k′(y)=−23y+2k'(y) = -2\sqrt3 y + 2, and k′(y0)=−23⋅13+2=−2+2=0k'(y_0) = -2\sqrt3\cdot \tfrac{1}{\sqrt3} + 2 = -2+2=0, again consistent. But k′′(y)=−23<0k''(y) = -2\sqrt3 < 0 as well — so along this line it is also a local max in yy alone... yet this single-variable check is not enough to conclude a genuine 2D local max, since we must test all directions, not just two. Test the direction y=x+sy = x + s for small deviations transverse to the diagonal, i.e. approach P1P_1 along x=13+t, y=13−tx = \tfrac{1}{\sqrt3}+t,\ y = \tfrac{1}{\sqrt3} - t (a direction not equal to y=xy=x). Compute ff along this path to second order in tt. With x=a+t, y=a−tx = a+t,\ y=a-t where a=1/3a = 1/\sqrt3:

f=(a+t)3−3(a+t)(a−t)2+2(a−t).f = (a+t)^3 - 3(a+t)(a-t)^2 + 2(a-t).

Expand: (a+t)3=a3+3a2t+3at2+t3(a+t)^3 = a^3+3a^2t+3at^2+t^3, and (a−t)2=a2−2at+t2(a-t)^2 = a^2 - 2at+t^2, so

3(a+t)(a−t)2=3(a+t)(a2−2at+t2)=3[a3−2a2t+at2+a2t−2at2+t3]=3a3−3a2t−3at2+3t3.3(a+t)(a-t)^2 = 3(a+t)(a^2-2at+t^2) = 3\left[a^3 - 2a^2t + at^2 + a^2t - 2at^2+t^3\right]=3a^3 - 3a^2t -3at^2+3t^3.

So

f=a3+3a2t+3at2+t3−(3a3−3a2t−3at2+3t3)+2a−2tf = a^3+3a^2t+3at^2+t^3 - \left(3a^3-3a^2t-3at^2+3t^3\right) + 2a-2t
=−2a3+6a2t+6at2−2t3+2a−2t.= -2a^3 + 6a^2 t + 6at^2 -2t^3+2a-2t.

At a=1/3a = 1/\sqrt3: 6a2=26a^2 = 2, so the linear-in-tt coefficient is 6a2t−2t=2t−2t=06a^2t - 2t = 2t-2t=0 ✓ (confirms critical point). The quadratic term is 6at2=6⋅13t2=23 t2>06at^2 = 6\cdot\tfrac1{\sqrt3} t^2 = 2\sqrt3\, t^2 > 0 for t≠0t \ne 0. So along this transverse direction, ff increases near P1P_1 (to second order), while along the diagonal y=xy=x direction we found ff decreases (a max, h′′<0h''<0). Since ff increases in one direction and decreases in another arbitrarily close to P1P_1, P1P_1 is not a local extremum at all — it is a saddle point. By an identical computation (or by the symmetry f(−x,−y)=−f(x,y)f(-x,-y) = -f(x,y), which sends critical points to critical points with the roles of increase/decrease swapped), P2P_2 is also a saddle point. This example is exactly why Fermat's theorem is only a necessary condition: both critical points exist as the theorem guarantees, but neither is an extremum. Resolving this efficiently — without hand-testing several directions — is precisely the motivation for The Hessian Matrix.

Example 2: Interior vs. boundary on a closed disk. Let f(x,y)=x2+2y2−4x−4yf(x,y) = x^2 + 2y^2 - 4x - 4y on the closed disk D={(x,y):x2+y2≤9}D = \{(x,y) : x^2+y^2 \le 9\}. Find the global maximum and minimum of ff on DD. Solution. DD is closed and bounded (compact), and ff is continuous (indeed a polynomial), so by the Extreme Value Theorem, ff attains a global max and global min somewhere on DD. Any such extremum occurs either at an interior point of DD (the open disk x2+y2<9x^2+y^2<9) or on the boundary circle x2+y2=9x^2+y^2=9. Interior candidates. On the open disk, ff is differentiable everywhere, so by the theorem just proved, any interior extremum must be a critical point. Compute:

∇f=(2x−4, 4y−4).\nabla f = (2x - 4,\ 4y - 4).

Setting this to zero: x=2x = 2, y=1y=1. Check this lies in the open disk: 22+12=5<92^2+1^2 = 5 < 9. Yes. So (2,1)(2,1) is the unique interior critical point, with

f(2,1)=4+2−8−4=−6.f(2,1) = 4 + 2 - 8 - 4 = -6.

Boundary candidates. On the boundary circle, parametrize x=3cos⁡θ, y=3sin⁡θx = 3\cos\theta,\ y = 3\sin\theta, θ∈[0,2π)\theta \in [0,2\pi). Then

f(θ)=9cos⁡2θ+18sin⁡2θ−12cos⁡θ−12sin⁡θ=9+9sin⁡2θ−12cos⁡θ−12sin⁡θ.f(\theta) = 9\cos^2\theta + 18\sin^2\theta - 12\cos\theta - 12\sin\theta = 9 + 9\sin^2\theta - 12\cos\theta-12\sin\theta.

(Using 9cos⁡2θ=9−9sin⁡2θ9\cos^2\theta = 9-9\sin^2\theta.) This reduces the search to a one-variable problem on the boundary — the general strategy for constrained extrema, later formalized via Lagrange Multipliers. Differentiate:

f′(θ)=18sin⁡θcos⁡θ+12sin⁡θ−12cos⁡θ=9sin⁡(2θ)+12sin⁡θ−12cos⁡θ.f'(\theta) = 18\sin\theta\cos\theta + 12\sin\theta - 12\cos\theta = 9\sin(2\theta) + 12\sin\theta - 12\cos\theta.

Rather than solve this transcendental equation symbolically, note f′(θ)=0f'(\theta)=0 defines the boundary's own critical points; a numerical solve (Newton's method from a few seed points) locates them near θ≈0.4636\theta \approx 0.4636 rad and θ≈3.605\theta \approx 3.605 rad (verify: at θ=0.4636\theta=0.4636, cos⁡θ≈0.8944, sin⁡θ≈0.4472\cos\theta\approx0.8944,\ \sin\theta\approx0.4472 — this is the direction of the point (3⋅0.8944,3⋅0.4472)=(2.683,1.342)(3\cdot0.8944, 3\cdot0.4472) = (2.683, 1.342), i.e. the boundary point in the exact direction from the origin through (2,1)(2,1) extended to radius 33, since (2,1)(2,1) has direction angle arctan⁡(1/2)≈0.4636\arctan(1/2)\approx 0.4636). Indeed this makes geometric sense: ff's interior critical point (2,1)(2,1) is the unconstrained minimum of the paraboloid-like function ff, and the boundary point diametrically farthest from it in that radial direction, θ≈0.4636+π≈3.605\theta\approx 0.4636+\pi \approx 3.605, is a natural candidate for the boundary max, while the near point θ≈0.4636\theta\approx0.4636 is a candidate for the boundary min. Evaluate ff at these two boundary points:

  • Near point (x,y)≈(2.683,1.342)(x,y) \approx (2.683, 1.342): f≈(2.683)2+2(1.342)2−4(2.683)−4(1.342)≈7.20+3.60−10.73−5.37≈−5.30f \approx (2.683)^2 + 2(1.342)^2 - 4(2.683) - 4(1.342) \approx 7.20 + 3.60 - 10.73 - 5.37 \approx -5.30.
  • Far point (x,y)≈(−2.683,−1.342)(x,y) \approx (-2.683,-1.342): f≈7.20+3.60+10.73+5.37≈26.90f \approx 7.20+3.60+10.73+5.37 \approx 26.90.

We also must check the endpoints of the θ\theta-range are not separately extremal — but since θ\theta ranges over a full circle (a closed loop with no boundary of its own), the only boundary-of-DD candidates are these two critical θ\theta's (a continuous periodic function on a circle attains its extrema only at its own critical points, by the same Fermat argument applied to the 11-variable function f(θ)f(\theta) on R/2πZ\mathbb R/2\pi\mathbb Z). Comparing all candidates: f(2,1)=−6f(2,1) = -6 (interior), f≈−5.30f \approx -5.30 (boundary near point), f≈26.90f\approx 26.90 (boundary far point). The global minimum on DD is −6-6 at the interior point (2,1)(2,1), and the global maximum is approximately 26.9026.90 at the boundary point near (−2.683,−1.342)(-2.683,-1.342). This example shows both halves of the theorem's scope at once: the interior extremum was correctly found via ∇f=0\nabla f = 0, but the true global maximum lived on the boundary, where the gradient condition simply does not apply and a separate one-dimensional analysis was required.

CounterexampleDropping the "interior point" hypothesis

The theorem requires a\mathbf{a} to be an interior point of the domain. Here is what fails if we allow a\mathbf{a} to be a boundary point instead. Let U={(x,y)∈R2:x≥0}U = \{(x,y) \in \mathbb{R}^2 : x \ge 0\} (a closed half-plane, so UU is not open), and let

f(x,y)=x,(x,y)∈U.f(x,y) = x, \qquad (x,y) \in U.

This ff is differentiable everywhere on UU (in the sense of having a well-defined gradient extending smoothly from an open neighborhood in R2\mathbb R^2), with

∇f(x,y)=(1,0)for all (x,y).\nabla f(x,y) = (1, 0) \quad \text{for all } (x,y).

Consider the point a=(0,0)\mathbf{a} = (0,0), which lies on the boundary line x=0x=0 of UU, not in its interior. Restricted to UU, ff attains its global minimum at every point with x=0x=0, including a\mathbf a: indeed f(x,y)=x≥0=f(0,y)f(x,y) = x \ge 0 = f(0,y) for every (x,y)∈U(x,y) \in U. So a\mathbf{a} is (non-strictly) a global — hence local — minimum of ff on UU. Yet

∇f(a)=(1,0)≠(0,0).\nabla f(\mathbf{a}) = (1,0) \ne (0,0).

The gradient does not vanish at this extremum. The theorem's conclusion fails exactly because its hypothesis — that a\mathbf a be an interior point of the domain — fails: a\mathbf a sits on ∂U\partial U, so no open ball around a\mathbf a is contained in UU, and the key step of the proof (restricting ff to a full two-sided interval (−δ,δ)(-\delta,\delta) along each axis through a\mathbf a, staying inside UU) breaks down: moving in the −x1-x_1 direction from a\mathbf a immediately exits UU. This is precisely the phenomenon flagged in the "boundary considerations" of the definition, and it is the reason boundary extrema must always be hunted separately from interior ones.

Scope, edge cases & common traps

SituationWhat to do
a\mathbf{a} interior, ff differentiable thereExtremum ⇒∇f(a)=0\Rightarrow \nabla f(\mathbf a) = \mathbf 0; solve the gradient system.
a\mathbf{a} interior, ff not differentiable there (corner, cusp, kink)Still a candidate critical point; the gradient test says nothing — check directly (e.g. via directional derivatives or direct comparison of values).
a\mathbf{a} on the boundary of the domainGradient need not vanish (see counterexample). Restrict ff to the boundary and search that lower-dimensional problem for its own extrema/critical points.
∇f(a)=0\nabla f(\mathbf a) = \mathbf 0 foundOnly a candidate. Could be a max, a min, or a saddle (or, in degenerate cases, none of the classical three, e.g. a monkey saddle). Needs second-order test.
Domain unbounded or not closedExtreme Value Theorem may not guarantee a global extremum exists at all; critical point analysis only ever finds candidates, existence must be argued separately.

The mathematician behind it

Origins · 1 minPierre de Fermat and how this was discovered
PD
Pierre de Fermat
1607–1665 · Pre-calculus France, correspondence-era mathematics

Fermat, a magistrate and councillor at the parlement of Toulouse, developed his method of finding maxima and minima (adaequalitas) decades before Newton and Leibniz formalized the calculus. Working with polynomials, Fermat's technique — comparing f(x)f(x) and f(x+e)f(x+e), dividing by ee, and then discarding the remaining terms in ee — is recognizably the germ of setting a derivative to zero, even though he had neither the language of limits nor of derivatives. His method traveled through correspondence with Mersenne, Roberval, and Descartes, and directly influenced the later formal treatments of extrema by Newton, Leibniz, and eventually the rigorous ε\varepsilon–δ\delta framing that underlies the modern proof given above.

History
- 1629 — Fermat develops his method of maxima and minima for polynomials, comparing f(x)f(x) and f(x+e)f(x+e) and discarding higher-order terms in ee.
- 1637 — Fermat's method circulates in correspondence, sharpening disputes with Descartes over methods of tangents and extrema.
- 1670s–1680s — Newton and Leibniz formalize the derivative, recasting Fermat's method as "set the derivative to zero."
- 1800s — Rigorous ε\varepsilon–δ\delta analysis (Cauchy, Weierstrass) makes the single-variable Fermat theorem a fully proved statement about limits.
- Late 1800s–early 1900s — The theory of functions of several variables (Peano, Young, and others) extends differentiability and the gradient, making the vector-valued Fermat theorem and the Hessian-based second-order tests standard tools of analysis.
Is every critical point a local extremum?

No. A critical point is only a candidate; the theorem in this article is a one-directional implication (extremum ⇒\Rightarrow critical point), not an equivalence. The standard counterexample is a saddle point, such as f(x,y)=x2−y2f(x,y) = x^2 - y^2 at the origin: ∇f(0,0)=(0,0)\nabla f(0,0) = (0,0), yet along the xx-axis ff increases away from the origin while along the yy-axis it decreases, so the origin is neither a local max nor a local min. Distinguishing extrema from saddles among critical points requires second-order information, typically packaged into the Hessian matrix and its eigenvalues or its determinant (the second-derivative test), which is the natural next tool after this one.

What happens if ff is not differentiable at a critical point?

The theorem's proof genuinely requires differentiability, since it relies on the existence of ∇f(a)\nabla f(\mathbf a) and the local linear approximation. If ff fails to be differentiable at an interior point a\mathbf a (for instance f(x,y)=x2+y2f(x,y) = \sqrt{x^2+y^2} at the origin, which has a sharp cone-point), a\mathbf a is still classified as a critical point by convention, because it could be an extremum, but the gradient-vanishing argument simply does not apply there. Such points must be checked directly — often by bounding ff near a\mathbf a using inequalities, or by examining one-sided/directional behavior explicitly, since no linear approximation is available to analyze.

Why do we need to treat the boundary of the domain separately?

The proof of Fermat's theorem crucially uses that a full two-sided interval (−δ,δ)(-\delta,\delta) along each coordinate direction through a\mathbf a remains inside the domain, which requires a\mathbf a to be an interior point. At a boundary point, moving in some directions immediately leaves the domain, so there is no guarantee that ff is even defined nearby in every direction, let alone that its restriction along an axis has an honest two-sided local extremum. As the counterexample shows, a genuine minimum can occur at a boundary point where the gradient is a nonzero vector pointing "into" the forbidden region. The correct method is to parametrize or otherwise restrict ff to the boundary set itself (which is typically a lower-dimensional set, e.g. a curve for a 2D domain) and apply the same first-order reasoning one dimension down.

How does this generalize the single-variable version I already know?

The single-variable statement — f′(a)=0f'(a) = 0 at an interior local extremum of a differentiable function — is exactly the n=1n=1 case of the theorem here. The proof strategy in higher dimensions is to reduce back to the single-variable case: fix all but one coordinate, restrict ff to a line through a\mathbf a, and apply the one-variable theorem to that restriction, one coordinate direction at a time. This is why the theorem is often just called "Fermat's theorem" without qualification even in the multivariable setting — it is the same idea applied along every axis simultaneously, using the fact that differentiability supplies all directional derivatives (via the gradient) at once, not just the axis-aligned ones.

Can a function have infinitely many critical points?

Yes, easily. A constant function f(x)=cf(\mathbf x) = c has ∇f≡0\nabla f \equiv \mathbf 0 everywhere, so every point of its domain is critical (and, trivially, every point is a non-strict global extremum, consistent with the theorem). Less trivially, f(x,y)=sin⁡(x)f(x,y) = \sin(x) (independent of yy) has ∇f=(cos⁡x,0)\nabla f = (\cos x, 0), which vanishes on the entire family of vertical lines x=π/2+kπx = \pi/2 + k\pi, k∈Zk \in \mathbb Z — infinitely many critical points, alternating between maxima and minima in xx but constant (hence never even locally strict) in yy. This is a useful reminder that critical points can form higher-dimensional sets, not just isolated points.

Does this theorem tell us that extrema exist?

No — it is purely a necessary condition for where an extremum can be, given that one exists; it never asserts existence. Existence of a global extremum on a given domain is a separate question, typically settled by the Extreme Value Theorem when the domain is compact (closed and bounded) and ff is continuous. On a non-compact domain (open, unbounded, or with points removed), a function can fail to attain any local or global extremum at all — e.g. f(x,y)=xf(x,y) = x on all of R2\mathbb R^2 has no critical points and no extrema whatsoever, consistent with, not contradicted by, the theorem.

How does this connect to Lagrange multipliers?

Lagrange multipliers address a different but related problem: extremizing ff subject to an equality constraint g(x)=0g(\mathbf x) = 0, restricting attention to a lower-dimensional constraint surface rather than an open region. The unconstrained theorem in this article is exactly the g≡g \equiv "no constraint" special case. When a domain's boundary is itself defined by an equation like g(x)=0g(\mathbf x)=0 (as in Example 2's circle x2+y2=9x^2+y^2=9), the boundary search performed there by direct parametrization is precisely what Lagrange multipliers automate in general, replacing the vanishing-gradient condition ∇f=0\nabla f = \mathbf 0 with the tangency condition ∇f=λ∇g\nabla f = \lambda \nabla g.

Before this

Where this leads