Why is/isn't the derivative of a differentiable function continuous? I am confused about the following Theorem:
Let $f: I \to \mathbb{R}^n$, $a \in I$. Then the function $f$ is differentiable at $a$ if and only if there exists a function $\varphi: I \to \mathbb{R}^n$ that is continuous in $a$, and such that $f(x) - f(a) = (x - a)\varphi(x)$, for all $x \in I$; furthermore, $\varphi(a) = f'(a)$.
I understand the proof of this theorem, but something confuses me. Doesn't this theorem state that the derivative of a function in a point is always continuous in that point, since $f'(a) = \varphi(a)$ is continuous in $a$? This would mean that the derivative of a function is always continuous on the domain of the function, but I have encountered counterexamples. I have probably misinterpreted something; any help would be welcome.
 A: The theorem states that $\varphi(a)=f'(a)$ for this particular value of $a$.  It doesn't say that $\varphi(x)=f'(x)$ for all $x$, or indeed for any value of $x$ besides the single value $x=a$.  So the fact that $\varphi$ is continuous at $a$ doesn't tell you that $f'$ is continuous at $a$, since continuity depends on the values of the function at points near $a$, not just at $a$ itself.
A: The theorem is simply stating that the function
\begin{align*}
\varphi(x) &= 
\begin{cases}
\frac{f(x) - f(a)}{x - a} &  \text{if}\;x\not = a; \\
f'(a) & \text{if}\;x = a
\end{cases}
\end{align*}
is continuous. And it clearly is; the only point to check is $x = a$, and the condition $\lim_{x\to a} \varphi(x) = \varphi(a)$ is exactly the definition of $f'(a)$. The theorem is not claiming that $f = \varphi$ everywhere on $I$.
One of the classic examples of a differentiable function $f$ with $f'$ not continuous is $f(x) = x^2\sin (1/x)$ (with $f(x) = 0$). The derivative
\begin{align*}
f'(x) &= \begin{cases}
2x \sin (1/x) - \cos (1/x) & \text{if}\; x \not = 0; \\
0 & \text{if}\; x = 0
\end{cases}
\end{align*}
exists everywhere, but it is not continuous at $0$.
A: The point is that $\varphi$ is not $f'$. They just coincide in one point, and it is easy to see that two functions coinciding in one point entails nothing about some relationship of differentiability/continuity etc between one another.
