# Continuous function and its extrema

Let $f(x)$ be a continuous function in $(a,b)$ and it has in this interval $m$ local maximum points and $n$ local minimum points.

Then : $|m-n|\leq1$

It seems very obvious but is there any simple proof that explains this fact?

• I changed $|m-n|\leq$1 to $|m-n|\leq1$. That is standard. – Michael Hardy Feb 6 '14 at 18:16

You need to show that between two local maxima there is a local minimum and vice-versa. Suppose there are local maxima at $x_1$ and $x_2$. Since there are only finitely many local maxima we may choose them so that no others lie between these two. That implies the function cannot be constant on any interval. Therefore in some small open interval about $x_1$, the function is smaller than it is at $x_1$, and similarly at $x_2$. If $x_1<x_2$ we can say that if $x_1+\varepsilon<x<x_2-\varepsilon$, then $f(x)<f(x_1)$ and $f(x)<x_2$, assuming $\varepsilon>0$ is small enough. Since there are no local maxima of $f$ between $x_1$ and $x_2$, the local maximum values of $f$ on the interval $[x_1+\varepsilon,x_2-\varepsilon]$ must be at the endpoints and the minimum must be in the interior.
In order that this make sense, you have to know that a continuous function on a closed interval actually reaches, rather than merely approaches, its maximum and minimum values. Apply that to the interval $[x_1+\varepsilon,x_2-\varepsilon]$.