TITLE: Fake proof for "differentiability implies continuous derivative": review
QUESTION [7 upvotes]: We known that a function may be differentiable at a point while having discontinuous derivative at such point. The following exercise proposes a fake proof for the proposition "let $f : \mathbb{R} \rightarrow \mathbb{R} $ be everywhere continuous and differentiable, then $f'$ is continuous over $\mathbb{R}$"; I am asked to find the mistake(s).
We prove that, for every $ a \in \mathbb{R}$, $\lim_{x \rightarrow} f'(x)=f'(a)$. Fix a point $a \in \mathbb{R}$, for every $x \in \mathbb{R}$ with $x>a$, $f$ is continuous on $[a,x]$ and differentiable on $(a,x)$, hence by MVT there exists a point $\xi \in (a,x)$ such that: $$ \frac{f(x)-f(a)}{x-a} = f'(\xi) $$Now, the limit of the LHS when $x \rightarrow a$ exists (and equals $f'(a)$ since $f$ is differentiable at $x=a$), so does the limit of the RHS. Finally, notice that when $x \rightarrow a$, then  $c \rightarrow a$, leading to: $$  f'(a)=\lim_{\xi \rightarrow a} f'(\xi). $$
My thought is that the trick lies in the worlds "when $x \rightarrow a$, then  $\xi \rightarrow a$": $\xi$ is in fact a function of $x$ (even if not explicitly said) $\xi=\xi(x)$, so the previous assertion somehow requires the continuity of $\xi(x)$. Is that idea correct or there is something else I couldn't see?

REPLY [5 votes]: No, when $x\to a$, indeed $\xi(x)\to a$, since $a<\xi(x)<x$. Or, in other words, $\xi(\bullet)$ is continuous at $a$.
Here is what you are doing: you are comparing the limit as $x\to a$ of two functions: one is $g(x)=\dfrac{f(x)-f(a)}{x-a}$, the other one is $f'\circ\xi$.
Your theorem
 successfully concluded the true fact that these two functions have the same limit and that $\lim_{x\to a} f'(\xi(x))$ exists. But: can you conclude that $\lim_{x\to a^+}f'(x)$ exists? The answer is no. When dealing with $f'\circ\xi$, you are calculating the limit of $f'$  only along the points which can be written as $\xi(y)$ for some $y$, but you are completely oblivious of the points that are not in that form. As far as you know, there could be an interval $I=(a,b)$ such that $\xi(I)$ does not contain a sequence $a_n\to a$. The corresponding sequence $f'(a_n)$ might (and sometimes will) not converge, or converge to a limit $L'\ne\lim_{x\to a^+} f'(\xi(x))$.