Interior Extrema and the Vanishing Derivative
Suppose a smooth trail winds through the mountains. You stand at its highest point, not at either end. What must be true of the trail's slope exactly where you stand? Every hiker's intuition says the ground is momentarily flat there. This article turns that intuition into a theorem. The result is due to Pierre de Fermat. It is one of the shortest and most consequential proofs in calculus: at an interior point where a differentiable function attains a local maximum or minimum, its derivative must vanish. This fact is often mistaken for a triviality, a picture rather than a theorem. But its precision matters enormously. It requires the extremum to be interior (not at an endpoint). It also requires differentiability at that exact point. Drop either hypothesis and the conclusion collapses. The counterexamples below will show this concretely. Understanding exactly what Fermat's theorem does and does not say matters greatly. It separates a student who can locate critical points from one who can also justify the method. The big picture is that this innocuous-looking lemma is important. It is the hinge on which a huge share of single-variable calculus turns. It converts the geometric notion of "extremum" into the algebraic condition "derivative equals zero." This turns optimization problems into equation-solving problems. It is also the seed from which Rolle's Theorem grows. The Mean Value Theorem grows from it too. Ultimately, the entire theory of monotonicity and curve sketching grows from it as well. This article states Fermat's theorem with all hypotheses made explicit. It gives a complete one-sided-limits proof. The proof is built directly from the The Derivative: Definition via Difference Quotients. The article also stress-tests the statement with worked examples. It includes a counterexample showing why each hypothesis is load-bearing.
- Fermat's theorem: if has a local extremum at an interior point and exists, then .
- The proof uses only the definition of the derivative as a two-sided limit of difference quotients, split into left and right sign estimates.
- "Interior" is essential: endpoints of a domain routinely have extrema with nonzero one-sided derivatives.
- "Differentiable at " is essential: a corner (non-differentiable point) can be an extremum without any derivative to vanish.
- The converse is false: does not imply an extremum at (inflection points like ).
- Key idea: at an interior extremum, the difference quotient is forced to be from one side and from the other, so if a single two-sided limit exists it must equal .
Where this lives today
Fermat's theorem is the computational engine behind every "take the derivative and set it to zero" optimization technique taught across science and engineering. In physics, finding equilibrium points of a potential energy function reduces to solving , precisely because stable and unstable equilibria are local extrema of . In economics, profit-maximizing quantities are found by setting marginal revenue equal to marginal cost — an instance of at an interior maximum of profit. In statistics and machine learning, maximum-likelihood estimation and loss-minimization in gradient-based training both begin from the same principle in many-variable form: at an interior optimum of a differentiable objective, every partial derivative vanishes, giving the gradient equation used throughout regression, neural network training, and convex optimization. In numerical analysis, root-finding methods for (Newton's method applied to the derivative) are the standard computational route to locating extrema when no closed form exists. And within pure mathematics, Fermat's theorem is the base case from which Rolle's Theorem is proved (by applying Fermat's theorem to the interior point where a function returning to the same value attains its max or min), which in turn drives the Mean Value Theorem and the entire theory of monotonicity, convexity, and curve sketching.
:::quiz[Which hypothesis of Fermat's theorem fails for on the domain at the point , even though is a perfectly differentiable, simple function?]
- is not differentiable at
- is not an interior point of the domain ✓
- does not have a local extremum at
- The limit defining does not exist
Ask the tutor: Can you show me step by step how Fermat's theorem is used inside the proof of Rolle's Theorem?
Let be a real-valued function defined on a set , and let .
Local maximum. has a local maximum at if there exists such that
Local minimum is defined by reversing the inequality. A point where either occurs is a local extremum.
Interior point. is an interior point of if there exists such that the entire interval is contained in . Equivalently, is defined on both sides of , not merely up to .
Differentiability at . is differentiable at if the two-sided limit
exists as a finite real number; this requires to be defined on an open interval containing .
Critical point. If , is called a critical point of . (More broadly, points where fails to exist are also called critical points, but Fermat's theorem concerns only the differentiable case.)
Intuition
Picture the graph of near an interior local maximum at . Because is defined on both sides of and is at least as large as all nearby values, the secant line from to a nearby point with must have slope — you are looking rightward and downward or flat. The secant to a point on the left, , must have slope — reading the quotient with a negative denominator flips the sign of a numerator that is still . So as the difference quotients are squeezed toward being , and as they are squeezed toward being . If is differentiable at , both one-sided limits must equal the same number . A number that is simultaneously (as a limit from the right) and (as a limit from the left) can only be . This is the entire proof, compressed into one sentence; the formal version below just makes each sign statement rigorous using the definition of limit. The picture also reveals immediately why "interior" matters: at a right endpoint of the domain, there is no room to test , so only one of the two sign constraints exists, and there is nothing to force the slope to zero.
Let be a real-valued function defined on an open interval (or more generally on a set for which is an interior point). Suppose: 1. has a local extremum (a local maximum or a local minimum) at ; 2. is an interior point of the domain, so is defined on some full open interval around ; 3. is differentiable at , i.e. exists. Then
We prove the case where has a local maximum at ; the local minimum case follows by applying this result to , which has a local maximum at exactly when has a local minimum there, and , so .
Step 1 (Set up the local inequality). Since has a local maximum at , by Definition: Local maximum there exists such that
By hypothesis (2), is interior, so choose ; then is defined and satisfies throughout .
Step 2 (Sign of the difference quotient from the right). Let satisfy . Then , so , i.e.
Dividing by preserves the inequality direction:
Step 3 (Sign of the difference quotient from the left). Let satisfy . Again , so as before. Now dividing by reverses the inequality:
Step 4 (Pass to one-sided limits). By hypothesis (3), exists as a finite limit. Existence of a two-sided limit implies existence and equality of both one-sided limits (this is a basic property of limits, used here exactly as in the limit definition underlying The Derivative: Definition via Difference Quotients):
We now invoke the order-preserving property of limits: if for all in a punctured neighborhood of a limit point and exists, then (proved directly from the –/– definition of limit: if the limit satisfied , taking would force for close enough to the limit point, contradicting there). Applying this to with the right-hand limit and :
Applying the analogous (reverse-direction) fact to with the left-hand limit and :
Step 5 (Conclude). We have shown and simultaneously for the same real number . The only real number satisfying both inequalities is . Hence
This completes the proof for a local maximum; the local minimum case follows from the argument applied to as noted above.
∎Proof technique used: direct construction of one-sided sign inequalities from the defining local inequality, combined with the order-preserving (squeeze-type) property of limits — no appeal to any theorem built on top of Fermat's theorem itself (such as the Mean Value Theorem), so the argument is non-circular.
If is differentiable on and attains its global maximum or minimum on at a point , then either , or and . In particular, to locate the global extrema of a differentiable function on a closed interval, it suffices to check the two endpoints together with all interior critical points.
If the global extremum occurs at , then is in particular a local extremum (the global condition on implies the local condition on any smaller neighborhood contained in ), is interior to the domain of differentiability , and is differentiable at by hypothesis. All three hypotheses of Fermat's theorem hold, so by Fermat's Theorem on Interior Extrema. The only remaining possibility is that the extremum occurs at an endpoint.
∎Worked examples
Example 1: A cubic with an asymmetric interior maximum. Let on the interval . We locate all candidates for global extrema. Since is a polynomial, it is differentiable everywhere, in particular on the open interval , so Fermat's theorem applies to any interior local extremum. Compute
Setting gives and , both interior to , so both are candidates permitted by the corollary above. Evaluate:
Interesting asymmetry: the global maximum value is attained both at the interior critical point and at the endpoint — a tie between an interior critical point and a boundary point, which is exactly the scenario the corollary anticipates by requiring us to check both types of candidates. The global minimum value is likewise attained both at interior critical point and at endpoint . Fermat's theorem correctly predicted that if an extremum were strictly interior, it would show up among — and indeed both interior extrema (which are local, at least) occur exactly there. Direct sign analysis of confirms is a local minimum ( changes ... here and , confirming a local min at ) and is a local maximum (, , confirming a local max at ).
Example 2: A function differentiable at the extremum but not elsewhere — testing the hypotheses precisely. Let
restricted to the interior point of . This is a genuinely delicate case because oscillates infinitely often near yet is differentiable there. First confirm differentiability at directly from the definition:
since . So . Does this contradict Fermat's theorem? No — because does not have a local extremum at . Indeed for small , , and for small , ; more carefully, since , the term dominates the sign of for small , so for small and for small . Thus is strictly increasing through in a suitable sense and has no local extremum at at all — consistent with . This example is instructive precisely because it shows Fermat's theorem is a one-directional implication: differentiability plus interior-ness alone say nothing; the extremum hypothesis is what does the work, and here that hypothesis genuinely fails, so there is no contradiction.
Consider on the interior point of (domain , so is certainly interior). Here and for all , so has a (global, hence local) maximum at . The interior-point hypothesis holds. But is not differentiable at : the right-hand difference quotient is
while the left-hand difference quotient is
These one-sided limits disagree (), so the two-sided limit defining does not exist. There is no derivative to set equal to zero — the conclusion of Fermat's theorem simply has no object to assert. This shows precisely why differentiability at is not a technical nicety but a load-bearing hypothesis: the proof's Step 4 needed a single two-sided limit squeezed between and . Here the "limit from the right" (which the proof shows is ) equals , and the "limit from the left" (which the proof shows is ) equals ; both sign bounds are individually satisfied and consistent with the proof, but since they are unequal, there is no common value for them to pin down to . The corner is exactly the obstruction the differentiability hypothesis is designed to rule out.
Scope, edge cases & common traps
| Situation | Does Fermat's theorem apply? | What can happen |
|---|---|---|
| Interior point, differentiable there, local extremum | Yes | , guaranteed |
| Endpoint of a closed interval | No (not interior) | can be any nonzero value, e.g. on at |
| Interior point, not differentiable there, extremum present | No | may not exist at all, e.g. at |
| Interior point, | N/A (converse direction) | Extremum may or may not occur, e.g. at has but no extremum |
| Interior point, differentiable, no extremum | N/A | can be any real number, as in Worked Example 2 |
The mathematician behind it
Origins · 1 minPierre de Fermat and how this was discovered
Fermat was a lawyer and government official in Toulouse who pursued mathematics as an intense private avocation, corresponding with contemporaries like Mersenne and Pascal rather than publishing formally. He is best known to the general public for Fermat's Last Theorem, but his method for finding maxima and minima — worked out in the 1630s in a manuscript titled Methodus ad disquirendam maximam et minimam — is arguably his most direct ancestor to modern calculus. Fermat's method, applied to polynomials, effectively computed what we now call the derivative and set it to zero, decades before Newton and Leibniz built the full differential and integral calculus around the same idea.
Does Fermat's theorem require to be continuous, in addition to differentiable?
No separate continuity hypothesis is needed, because differentiability at already implies continuity at — this is the content of Differentiability Implies Continuity. The proof of Fermat's theorem uses only the existence of the two-sided limit defining , and continuity is automatically along for the ride. What is required, beyond differentiability at the single point , is that be defined on a full open interval around (the interior-point condition), so that both one-sided difference quotients in Steps 2–3 of the proof make sense.
Is Fermat's theorem true for functions of several variables?
Yes, in an analogous form: if has a local extremum at an interior point of its domain and all partial derivatives of exist at , then every partial derivative vanishes there, i.e. . The proof reduces to the one-variable case: fix all but one coordinate and apply the single-variable theorem to the resulting function of one variable along each axis direction. This is exactly the gradient-vanishing condition used throughout multivariable optimization.
What exactly goes wrong in the proof if the extremum is at an endpoint instead of an interior point?
The proof needs both a right-hand inequality ( for slightly greater than ) and a left-hand inequality ( for slightly less than ) to derive the two opposite-sign bounds on the difference quotient. At a left endpoint, for instance, there are no domain points to the left of at all, so Step 3 of the proof (the left-hand sign bound) cannot even be formulated. Only one of the two sign constraints survives, and a single inequality like does not force .
Can happen without being any kind of critical value of interest, i.e. is the converse ever "almost true"?
The converse fails outright as a biconditional, but a useful partial converse holds under extra hypotheses: if is twice differentiable at with and , then is a strict local minimum (and symmetrically for , a strict local maximum). This is the second-derivative test, itself typically proved using a Taylor expansion or the Mean Value Theorem, both of which trace back to Fermat's theorem as their starting lemma. When too, no conclusion follows from the second derivative alone, as and both illustrate.
Why is the interior-point hypothesis phrased in terms of an open interval rather than just saying "not an endpoint"?
Domains in analysis are not always intervals with two endpoints — they can be unions of intervals, or more exotic subsets of . The precise requirement is that some full open interval around lies entirely in the domain, which is exactly what "interior point" means in a general topological sense. This phrasing correctly excludes not just the two endpoints of a closed interval , but also isolated points of the domain or points that are limits only from one side, all of which would break the proof's need for domain points on both sides of .
Does Fermat's theorem hold for functions from to , or only real-valued functions?
As stated, Fermat's theorem is inherently about real-valued functions, because "local maximum" and "local minimum" require an ordering on the codomain, and is not ordered in a way compatible with its field structure. For complex-valued or complex-differentiable (holomorphic) functions, the relevant extremum results look completely different — for instance, the Maximum Modulus Principle governs where can attain its maximum, and it has a very different proof and different hypotheses from Fermat's theorem.
How does Fermat's theorem foreshadow Rolle's Theorem?
Rolle's Theorem considers a function continuous on , differentiable on , with , and concludes some has . Its proof works by locating a global extremum of on (using the Extreme Value Theorem), then arguing that if this extremum is not at both endpoints, it must occur at some interior point — at which point Fermat's theorem immediately gives . Fermat's theorem is thus the final algebraic step that Rolle's Theorem's existence argument is built to reach.