TITLE: Rolle's Theorem: why do we need the premise $f(a) = f(b)$?
QUESTION [6 upvotes]: If a real-valued function $f$ is continuous on a closed interval $[a, b]$, differentiable on the open interval $(a, b)$, and $f(a) = f(b)$, then there exists at least one $c$ in the open interval $(a, b)$ such that $f'(c) = 0$.

Above you can see Rolle's theorem. It contains three premises:

$f$ must be continuous on the interval $[a,b]$
$f$ must be differentiable on the open interval $(a,b)$
$f(a) = f(b)$

I understand why we need the first two premises, but I don't see the meaning of the third one. Could you please tell me why do we need $f(a) = f(b)$?
Thank you for your help!

REPLY [3 votes]: The proof of Rolle's theorem says that (since $f$ is continuous on the closed interval $[a,b]$), it must attain both a minimum and a maximum value there.  Let $m = \min_{x\in [a,b]} f(x)$, $M = \max_{x \in [a,b]} f(x)$.  If $m = M$, then $f$ is constant, so it has a zero derivative everywhere on $(a,b)$.  Now, suppose $m < M$.  
If $f(a) = f(b)$, then we can conclude that either $m \not\in \{f(a), f(b)\}$ or $M \not\in \{f(a), f(b)\}$, so $f$ has either a local minimum or a local maximum at some point $c \in (a,b)$.  By playing with the definition of minimum (maximum), we can see that $f'(c) = 0$.
On the other hand, if $f(a) \not= f(b)$, then $f$ could be a strictly increasing (or decreasing) function, so, say, $f(a) = m$, $f(b) = M$, and $f'(x) > 0$ for all $x \in (a,b)$.