In mathematics, Fermat's theorem (also known as interior extremum theorem) is a method to find local maxima and minima of differentiable functions on open sets by showing that every local extremum of the function is a stationary point (the function's derivative is zero at that point). Fermat's theorem is a theorem in real analysis, named after Pierre de Fermat.
By using Fermat's theorem, the potential extrema of a function , with derivative , are found by solving an equation in . Fermat's theorem gives only a necessary condition for extreme function values, as some stationary points are inflection points (not a maximum or minimum). The function's second derivative, if it exists, can sometimes be used to determine whether a stationary point is a maximum or minimum.
One way to state Fermat's theorem is that, if a function has a local extremum at some point and is differentiable there, then the function's derivative at that point must be zero. In precise mathematical language:
Let be a function and suppose that is a point where has a local extremum. If is differentiable at , then .
Another way to understand the theorem is via the contrapositive statement: if the derivative of a function at any point is not zero, then there is not a local extremum at that point. Formally:
If is differentiable at , and , then is not a local extremum of .
The global extrema of a function f on a domain A occur only at boundaries, non-differentiable points, and stationary points.
If is a global extremum of f, then one of the following is true:
boundary: is in the boundary of A
non-differentiable: f is not differentiable at
stationary point: is a stationary point of f
In higher dimensions, exactly the same statement holds; however, the proof is slightly more complicated. The complication is that in 1 dimension, one can either move left or right from a point, while in higher dimensions, one can move in many directions. Thus, if the derivative does not vanish, one must argue that there is some direction in which the function increases – and thus in the opposite direction the function decreases.