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 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 determine if any stationary point is a maximum, minimum, or inflection point.