Tutorials › Calculus III › Fermat’s Necessary Condition in Several Variables

Critical Points and Local Extrema · Tutorial 402 of 999

Fermat’s Necessary Condition in Several Variables

Learn why every partial derivative must vanish at an interior local extremum, and why the condition does not guarantee an extremum.

Intermediate 9 min read

What You'll Learn

  • State Fermat’s necessary condition for differentiable functions of several variables.
  • Prove the one-variable condition using difference quotients from both sides.
  • Relate coordinate-line restrictions to the components of the gradient.
  • Apply the condition to local minima, local maxima, and points that cannot be extrema.
  • Recognize why interiority and differentiability are essential assumptions.
  • Distinguish a necessary condition from a guarantee of an extremum.

Why Look Along Coordinate Directions?

A local maximum or minimum is a condition on the values of a function throughout a neighborhood, so it can initially seem to require checking infinitely many directions. A useful simplification is to examine the function along each coordinate direction separately. Each such restriction is a one-variable function, where a basic necessary condition for an extremum applies.

The conclusion is important but limited: if a differentiable function has a local extremum at an interior point, every component of its gradient must be zero. This condition can rule out extrema when the gradient is nonzero. By itself, however, it does not show that a point with zero gradient is an extremum.

Definition: Let \(f:U\to\mathbb{R}\), where \(U\) is an open subset of \(\mathbb{R}^n\), and let \(\mathbf{a}\in U\). The point \(\mathbf{a}\) is a local maximum if there is a radius \(r>0\) such that \(f(\mathbf{x})\leq f(\mathbf{a})\) whenever \(\mathbf{x}\in U\) and \(\|\mathbf{x}-\mathbf{a}\|<r\). A local minimum is defined by reversing the inequality. The point is an interior point of the domain when some open ball centered at \(\mathbf{a}\) lies in the domain.

We say \(f\) is differentiable at \(\mathbf{a}\) if its change near \(\mathbf{a}\) can be approximated by a linear map, with an error that is small compared with the distance from \(\mathbf{a}\). In coordinates, this means there is a linear map \(Df(\mathbf{a})\) such that

$$ f(\mathbf{a}+\mathbf{h}) = f(\mathbf{a})+Df(\mathbf{a})\mathbf{h} +o(\|\mathbf{h}\|) \quad\text{as }\mathbf{h}\to\mathbf{0}. $$

For a differentiable real-valued function, the gradient is the vector of its first partial derivatives:

$$ \nabla f(\mathbf{a}) = \left( \frac{\partial f}{\partial x_1}(\mathbf{a}), \frac{\partial f}{\partial x_2}(\mathbf{a}), \dots, \frac{\partial f}{\partial x_n}(\mathbf{a}) \right). $$

The One-Variable Condition

First consider a differentiable function \(g\) of one real variable with a local extremum at \(t=0\). If \(0\) is a local maximum, then for sufficiently small \(h\), \(g(h)-g(0)\leq 0\). For positive and negative \(h\), division by \(h\) gives inequalities in opposite directions:

$$ h>0:\quad \frac{g(h)-g(0)}{h}\leq 0, \qquad h<0:\quad \frac{g(h)-g(0)}{h}\geq 0. $$

Since \(g'(0)\) exists, both one-sided difference quotients approach the same number. The limit from positive \(h\) cannot be positive, and the limit from negative \(h\) cannot be negative. Therefore their common limit is zero. For a local minimum the inequalities reverse, and the same reasoning again gives \(g'(0)=0\).

Theorem: If \(g\) is differentiable at an interior point \(t_0\) and has a local maximum or local minimum there, then \(g'(t_0)=0\). Differentiability and an interior point are required for this conclusion.

Fermat’s Necessary Condition in Several Variables

To use the one-variable result for \(f\), restrict \(f\) to a line through \(\mathbf{a}\) parallel to one coordinate axis. For each index \(i\), let \(\mathbf{e}_i\) be the vector with \(1\) in its \(i\)-th coordinate and \(0\) in every other coordinate. Define the restriction

$$ \phi_i(t)=f(\mathbf{a}+t\mathbf{e}_i). $$

Because \(\mathbf{a}\) is interior, \(\mathbf{a}+t\mathbf{e}_i\) remains in the domain for every sufficiently small \(t\). If \(f\) has a local maximum at \(\mathbf{a}\), then \(\phi_i\) has a local maximum at \(t=0\); if \(f\) has a local minimum there, then \(\phi_i\) has a local minimum at \(t=0\).

Differentiability of \(f\) gives the derivative of each restriction. In the linear approximation for \(f\), set \(\mathbf{h}=t\mathbf{e}_i\). The coefficient of \(t\) is \(Df(\mathbf{a})\mathbf{e}_i\), which is the \(i\)-th partial derivative. Thus \(\phi_i'(0)=\frac{\partial f}{\partial x_i}(\mathbf{a})\). Applying the one-variable condition to every coordinate restriction proves the result.

Theorem: Let \(f:U\to\mathbb{R}\) be differentiable at an interior point \(\mathbf{a}\) of \(U\subseteq\mathbb{R}^n\). If \(f\) has a local maximum or local minimum at \(\mathbf{a}\), then $$ \nabla f(\mathbf{a})=\mathbf{0}. $$

Proof by Coordinate Restrictions

1
Choose a coordinate direction.
For an arbitrary index \(i\), define \(\phi_i(t)=f(\mathbf{a}+t\mathbf{e}_i)\) for \(t\) near \(0\). Interiority ensures this restriction is defined on an interval containing \(0\).
2
Transfer the extremum.
If \(f\) has a local maximum or minimum at \(\mathbf{a}\), then \(\phi_i\) has the same type of local extremum at \(0\), because its values come from points in the neighborhood of \(\mathbf{a}\).
3
Apply the one-variable result.
The restriction is differentiable, so Fermat’s one-variable condition gives \(\phi_i'(0)=0\).
4
Identify the partial derivative.
By the definition of the coordinate restriction, \(\phi_i'(0)=\frac{\partial f}{\partial x_i}(\mathbf{a})\). Hence this partial derivative is zero.
5
Use every coordinate.
The index \(i\) was arbitrary, so every component of \(\nabla f(\mathbf{a})\) is zero. Therefore \(\nabla f(\mathbf{a})=\mathbf{0}\).

The proof does not need to test every possible direction: checking the coordinate directions is enough to show that every partial derivative vanishes. The full differentiability assumption is a convenient sufficient condition for the restrictions to be differentiable and for their derivatives to agree with the corresponding partial derivatives.

Worked Examples

Worked Example: Checking the Condition at a Local Minimum

Consider \(f(x,y)=x^2+3y^2\) at \((0,0)\). Restrict to the two coordinate lines through this point:

$$ \phi_1(t)=f(t,0)=t^2, \qquad \phi_2(t)=f(0,t)=3t^2. $$

Their derivatives are \(\phi_1'(t)=2t\) and \(\phi_2'(t)=6t\), so \(\phi_1'(0)=0\) and \(\phi_2'(0)=0\). Equivalently, \(\frac{\partial f}{\partial x}=2x\), \(\frac{\partial f}{\partial y}=6y\), and \(\nabla f(0,0)=(0,0)\).

To verify the extremum, observe that \(x^2\geq 0\) and \(3y^2\geq 0\), so \(f(x,y)\geq 0=f(0,0)\) everywhere. Equality holds at \((0,0)\). Thus the origin is a global, and therefore local, minimum, and the gradient satisfies the necessary condition.

Worked Example: Checking the Condition at a Local Maximum

Let \(f(x,y)=7-(x-1)^2-2(y+2)^2\), and consider the point \((1,-2)\). Write nearby points as \((1+s,-2+t)\). The coordinate restrictions are

$$ \phi_1(s)=f(1+s,-2)=7-s^2, \qquad \phi_2(t)=f(1,-2+t)=7-2t^2. $$

Therefore \(\phi_1'(s)=-2s\), \(\phi_1'(0)=0\), and \(\phi_2'(t)=-4t\), \(\phi_2'(0)=0\). Directly, the partial derivatives are \(\frac{\partial f}{\partial x}=-2(x-1)\) and \(\frac{\partial f}{\partial y}=-4(y+2)\), giving \(\nabla f(1,-2)=(0,0)\).

Also, \((x-1)^2\geq 0\) and \(2(y+2)^2\geq 0\), so \(f(x,y)\leq 7=f(1,-2)\) for every \((x,y)\). Equality occurs at \((1,-2)\). This verifies the global, and hence local, maximum.

Worked Example: Ruling Out an Extremum with a Nonzero Gradient

Consider \(f(x,y)=x^2+y^2\) at \((1,0)\). Its partial derivatives are \(2x\) and \(2y\), so

$$ \nabla f(1,0)=(2,0)\neq(0,0). $$

The point is interior and the function is differentiable there. Fermat’s necessary condition therefore rules out both a local maximum and a local minimum at \((1,0)\). We can check the change along the \(x\)-axis directly: for \(0<\varepsilon<1\),

$$ f(1+\varepsilon,0)-f(1,0)=2\varepsilon+\varepsilon^2>0, $$ $$ f(1-\varepsilon,0)-f(1,0)=-2\varepsilon+\varepsilon^2 =\varepsilon(\varepsilon-2)<0. $$

Both points can be made arbitrarily close to \((1,0)\) by taking \(\varepsilon\) arbitrarily small. One gives a larger function value and the other a smaller one, confirming that neither type of local extremum occurs there.

What the Condition Does—and Does Not—Say

The theorem gives a necessary condition: an interior local extremum of a differentiable function must have zero gradient. Its logical form is one-way. Finding \(\nabla f(\mathbf{a})\neq\mathbf{0}\) proves that \(\mathbf{a}\) is not an interior local extremum. Finding \(\nabla f(\mathbf{a})=\mathbf{0}\) does not, on its own, prove that \(\mathbf{a}\) is a local maximum or minimum.

For instance, for \(q(x,y)=x^2-y^2\), the gradient at \((0,0)\) is \((0,0)\). But along the \(x\)-axis, \(q(t,0)=t^2>0\) for nonzero \(t\), while along the \(y\)-axis, \(q(0,t)=-t^2<0\). There are values both above and below \(q(0,0)=0\) arbitrarily close to the origin. So a zero gradient alone does not establish an extremum. The theorem identifies points that remain possible candidates; additional reasoning is needed to determine what happens there.

Common Pitfall: Forgetting the Interior Assumption

The interior assumption cannot simply be dropped. A local extremum on the boundary of a domain may have a nonzero gradient. For example, let \(f(x,y)=x\) on the domain \(D=\{(x,y):x\geq 0\}\). Relative to this domain, \((0,0)\) is a local minimum: every point of \(D\) has \(f(x,y)=x\geq 0=f(0,0)\). Yet the ambient gradient is \(\nabla f(0,0)=(1,0)\), not \((0,0)\).

A mistaken application would say, “There is a local minimum, so Fermat’s condition forces \((1,0)=(0,0)\).” The error is that \((0,0)\) is not an interior point of \(D\); no open ball around it lies entirely in \(D\). In the missing direction \(x<0\), the function is outside the domain, so the two-sided one-variable difference-quotient argument does not apply. Always check both hypotheses: differentiability at the point and interiority in the domain.

Why the Coordinate Argument Is Useful

When looking for interior extrema of a differentiable function, the theorem reduces a necessary condition to a system of equations: set each partial derivative equal to zero. This can narrow down which points need further investigation. The condition alone does not classify those points, and it does not replace the checks on differentiability or domain. Its value is that it provides a rigorous first test: a nonzero partial derivative in even one coordinate direction rules out an interior local extremum.

Check Your Understanding

Use the one-variable restrictions and the hypotheses of the theorem to answer these questions.

  1. Why must the coordinate-line restriction \(\phi_i(t)=f(\mathbf{a}+t\mathbf{e}_i)\) have a local extremum at \(t=0\) when \(f\) has a local extremum at \(\mathbf{a}\)?
  2. For \(f(x,y)=x^2+4y^2\), compute the gradient at \((0,0)\) and state whether it is consistent with the necessary condition for a local minimum.
  3. If a differentiable function has gradient \((3,-1)\) at an interior point, what does Fermat’s condition allow you to conclude about local extrema there?
  4. Why does a zero gradient fail to prove that a point is a local maximum or minimum?
  5. In the domain \(\{(x,y):x\geq 0\}\), why does the one-variable proof of the condition fail at a point on the boundary \(x=0\)?