# How do I find local maxima and minima of a function?

Mar 22, 2018

Let $f \left(x\right)$ be a real function of a real variable defined in$\left(a , b\right)$ and differentiable in the point ${x}_{0} \in \left(a , b\right)$

A necessary condition for ${x}_{0}$ to be a local minimum or maximum is that:

$f ' \left({x}_{0}\right) = 0$

If $f \left(x\right)$ is differentiable in the entire interval, or at least in an interval around ${x}_{0}$, we also have a sufficient condition:

${x}_{0}$ is a local minimum if $f ' \left({x}_{0}\right) = 0$ and there is a number $\delta$ such that:

$x \in \left({x}_{0} - \delta , {x}_{0}\right) \implies f ' \left(x\right) \le 0$
$x \in \left({x}_{0} , {x}_{0} + \delta\right) \implies f ' \left(x\right) \ge 0$

In this case in fact $f \left(x\right)$will be decreasing on the left of ${x}_{0}$ and increasing on the right, so that ${x}_{0}$ is a relative minimum.

Vice versa ${x}_{0}$ is a local maximum if:

$x \in \left({x}_{0} - \delta , {x}_{0}\right) \implies f ' \left(x\right) \ge 0$
$x \in \left({x}_{0} , {x}_{0} + \delta\right) \implies f ' \left(x\right) \le 0$

In both cases the necessary condition is that the derivative of $f \left(x\right)$ changes sign around ${x}_{0}$.

If $f \left(x\right)$ also has a second derivative in an interval around ${x}_{0}$ this is equivalent to the conditions:

$f ' \left({x}_{0}\right) = 0 \text{ and } f ' ' \left({x}_{0}\right) > 0 \implies {x}_{0}$ is a local minimum.

$f ' \left({x}_{0}\right) = 0 \text{ and } f ' ' \left({x}_{0}\right) < 0 \implies {x}_{0}$ is a local maximum.

So, to find local maxima and minima the process is:

1) Find the solutions of the equation:

$f ' \left(x\right) = 0$

also called critical points.

2) Solve the inequality:

$f ' \left(x\right) \le 0$

to see if the sign of $f ' \left(x\right)$ changes around the critical points, or, alternatively:

2') Calculate $f ' ' \left(x\right)$ and look at its value in the critical points.

Example:

Let $f \left(x\right) = 2 {x}^{3} - 3 {x}^{2} - 12 x + 1$

Calculate the derivative:

$f ' \left(x\right) = 6 {x}^{2} - 6 x - 12$

Solve the equation:

$f ' \left(x\right) = 0$

$6 {x}^{2} - 6 x - 12 = 0$

${x}^{2} - x - 2 = 0$

$x = \frac{1 \pm \sqrt{1 + 8}}{2}$

so the critical points are:

${x}_{1} = - 1$

${x}_{2} = 2$

As $f ' \left(x\right)$ is a second degree polynomial with positive leading coefficients we know that:

$f ' \left(x\right) < 0$ for $x \in \left(- 1 , 2\right)$

$f ' \left(x\right) > 0$ for $x \in \left(- \infty , - 1\right) \cup \left(2 , + \infty\right)$

and we can soon determine that ${x}_{1}$ is a local maximum and ${x}_{2}$ a local minimum.

Alternatively we can evaluate the second derivative:

$f ' ' \left(x\right) = 12 x - 6$

and check that:

$f ' ' \left({x}_{1}\right) = - 12 - 6 = - 18 < 0 \implies {x}_{1}$ is a maximum

$f ' ' \left({x}_{2}\right) = 24 - 6 = 18 > 0 \implies {x}_{2}$ is a minimum