## Fermat’s Theorem

Okay, the Heine-Borel theorem tells us that a continuous real-valued function on a compact space takes a maximum and a minimum value. In particular, this holds for functions on closed intervals. But how can we recognize a maximum or a minimum when we see one?

First of all, what we get from the Heine-Borel theorem is a *global* maximum and minimum. That is, a point so that for any we have (or ). We also can consider “local” maxima and minima. As you might guess from local connectedness and local compactness, a local maximum (minimum) is a global maximum (minimum) in some neighborhood . For example, if is a function on some region in then having a local maximum at means that there is some interval with , and for every we have .

So a function may have a number of local maxima and minima, but they’re not all global. Still, finding local maxima and minima is an important first step. In practice there’s only a finite number of them, and we can easily pick out which of them are global by just computing the function. So what do they look like?

For functions on regions in , the biggest part of the answer comes from Fermat’s theorem. The theorem itself actually talks about differentiable functions, so the first thing we’ll say is that an extremum may occur at a point where the function is not differentiable (though a point of nondifferentiability is not a sure sign of being an extremum).

Now, let’s say that we have a local maximum at and that is differentiable at . We can set up the difference quotient . When we take our limit as goes to , we can restrict to the neighborhood where gives a global maximum, so . To the right of , , so the difference quotient is negative here. To the left of , , so the difference quotient is positive here. Then since the limit must be a limit point of both of these regions, it must be . That is, . And the same thing happens for local minima.

So let’s define a “critical point” of a function to be one where either isn’t differentiable or . Then any local extremum must happen at a critical point. But not every critical point is a local extremum. The easiest example is , which has derivative . Then the only critical point is , for which , but any neighborhood of has both positive and negative values of , so it’s not a local maximum or minimum.

Geometrically, we should have expected as much as this. Remember that the derivative is the slope of the tangent line. At a local maximum, the function rises to the crest and falls again, and at the top the tangent line balances perfectly level with zero slope. We can see this when we draw the graph, and it provides the intuition behind Fermat’s theorem, but to speak with certainly we need the analytic definitions and the proof of the theorem.