Of the reasoning behind the Mean Value Theorem I have been attempting to grasp the reasoning behind the formulation of the Mean Value Theorem:
If $f(x)$ is continuous in the closed interval $[x_1;x_2]$ and differentiable at every point of the open interval $(x_1;x_2)$, then there is at least one point $\xi \in (x_1;x_2)$ such that
$$ \frac{f(x_2)-f(x_1)}{x_2-x_1} = f’(\xi)$$
What I cannot understand is why we do say that $f(x)$ is not necessarily differentiable at the end-points $x_1$ and $x_2$ of the interval. I also cannot fully understand the overall value of the premise that the function is continuous at those points; for I understand that if a function possesses an infinite discontinuity or a discontinuity of that sort when the value of the function does not coincide with its limiting value at that point, but I simply cannot imagine a singular example for the MVT not holding as the function possesses no definite limit at the end-points.
Thank you!
Edit: I have noticed that my question is a little convoluted, so I have re-phrased it a slight bit:
Consider a function which is continuous everywhere in the interval $[x_1;x_2]$ except for at least one of the end-points (say, $x_1$), as the function, though being defined at $x_1$, possesses no definite limit as it approaches $x_1$ (for instance, the function $\sin\frac{1}{x}$ as $x \to 0$). Does there exist a function of the mentioned sort, for which MVT does not hold?
 A: Though the question is a little unclear, I think this is an example of what you're asking.  Define $f$ on $[0,1]$ by
$$
f(x) = \begin{cases} 0, & x=0\\ \frac{1}{x}, & 0 < x \leq 1.\end{cases}
$$
This function, though defined at $x=0$, has no limit as you approach $0$ thanks to the vertical asymptote.  It is continuous on $(0,1]$.
The slope of the secant is
$$
\frac{f(1)-f(0)}{1-0}
= 1$$
yet the derivative on $(0,1)$ is $f'(x) = - \frac{1}{x^2}$.  Clearly this can never equal $1$.
Note that I was able to create this contrived example exactly because I'm violating continuity at one of the ends.
A: The requirement that $f$ is differentiable only in the interior comes from Rolle's Theorem: if $f(x_1) = f(x_2) = 0$ then unless $f$ is identically zero (in which case $f'(x) = 0$ for all $x$ in the interval) $f$ must attain a nonzero extreme value somewhere in the interior of the interval.  All that is required for the conclusion of Rolle's Theorem is that $f'(x)$ exists for all $x$ in the interior, not at the endpoints.
As far as continuity, consider $f(x) = 1$ if $x = 0$ and $f(x) = x^2$ if $0 < x \le 1$. Then $f$ is defined on $[0,1]$ and is differentiable at every point of $(0,1)$, but there is no point $x \in (0,1)$ satisfying $\displaystyle \frac{f(1) - f(0)}{1-0} = f'(x)$.
A: You asked for an example of a function where the limit does not exist at one endpoint. Even if the limit exists but the function is not continuous at one endpoint, the MVT fails.
Consider for example $f(x)=x$ if $x\in(0,1]$ and $f(0)=1$. Then $f$ is continuous on $(0,1]$, is discontinuous at $0$, is differentiable on $(0,1)$ but $\frac{f(1)-f(0)}{1-0}=0$ while $f'(x)=1$ for every $x\in(0,1)$.
