TITLE: Why do mean value theorems have open interval for differentiablity while closed for continuity?
QUESTION [11 upvotes]: For mean value theorems like Lagrange's and Rolle's, we have the following conditions:

For applying mean value theorem to any function $f(x)$ for the domain $[a,b]$ , it should be
(1) continuous in $[a,b]$
(2) differentiable in $(a,b)$

So why is it that for the criteria of differentiablity, we have the open interval ?? Is it possible for a function differentiable in $(a,b)$ and continuous in $[a,b]$ to be non- differentiable at the end points?
Also why is the first statement needed ?? Doesn't the second statement of differentiablity also mean that the function is continuous ??
I'm not very experienced in calculus and still in high-school,  so it might be something too obvious I'm missing , please help :)

REPLY [14 votes]: Here are a couple of examples to think about:

$f(x) = \sqrt{x}$ on the interval $[0,1]$.  This is continuous on $[0,1]$ and differentiable on $(0,1)$, but not differentiable at 0 in any reasonable sense.  Yet the mean value theorem applies to it.
$f(x) = \begin{cases} 0, & x = 0 \\ 1, & x > 0. \end{cases}$ This is differentiable on $(0,1)$ but the mean value theorem does not apply to it.

REPLY [10 votes]: For example, the function $\sqrt{x(1-x)}$ is continuous in $[0,1]$ but only differentiable on $(0,1)$.  
On the other hand, $1/x$ is differentiable in $(0,\infty)$ but is not continuous at $0$
(even if you define it at $0$).