Why doesn't MVT prove all derivatives are continuous? Obviously something is wrong with the following argument, but I'm not entirely what is. Let $f$ be differentiable in $(-1,1)$ and fix $0<x<1$. Then, by MVT, there exists $0<y<x$ such that
$$\frac{f(x)-f(0)}{x} = f'(y)$$
Taking the limit as $x \rightarrow 0$ on both sides gives $f'(0)$ on the LHS by definition, so we get $f'(0) = \lim_{x \rightarrow 0} f'(y)$, which seems to prove $f'$ is continuous at zero since $y \rightarrow 0$ as $x \rightarrow 0$. Again, I know this is wrong and can produce a counter-example (for instance, $f(x) = x^2\sin(1/x)$, so $f'(0) = 1$ but $f'(x) < 0$ in neighborhoods of $0$). Can someone tell me exactly which step is invalid? Based on the conditions of L'Hopital's rule, the flaw seems to be that I'm assuming $\lim_{x \rightarrow 0} f'(y)$ exists, but I'm not sure if this is it since we just proved that it exists and equals $f'(x)$.
 A: The logical dependency between $x$ and $y$ is in the wrong direction.
Here, as $x \to 0$ through positive values, there is for each $x > 0$ a corresponding $y \in (0,x)$.
For the argument to work, you would need to prove that as $y \to 0$ through positive values, for each value of $y$ there is a corresponding $x > y$ such that $f'(y) = (f(x) - f(0))/x$, with the dependency additionally being such that as $y \to 0$, we have $x \to 0$.
A: The first statement is indeed false. You have
$$\frac{f(x)-f(0)}{x} = f^\prime (y_x)$$ according to the MVT where $y_x \in (0,x)$ depends on $x$. Therefore, you have no way to prove that $\lim\limits_{x \to 0} f^\prime(x)$ exists based on that. You can only state that $\lim\limits_{x \to 0} f^\prime(y_x) =f^\prime(0)$.
Your second statement is also false. $f(x)=x^2 \sin \left(\frac{1}{x}\right)$ is differentiable at zero and $f^\prime(0)=0$. However as you noticed correctly, the derivative doesn’t have a limit at zero.
A: The Mean Value Theorem says that if $f$ is differentiable at all points of $[a,b]$, then there is a point $a\lt\xi\lt b$ so that
$$
\frac{f(b)-f(a)}{b-a}=f'(\xi)
$$
Consider $f(x)=x^2\sin\left(\frac1x\right)$. The following image shows the graphs of $f'(x)$ and $\frac{f(x)-f(0)}{x-0}$:

The Mean Value Theorem guarantees that a horizontal line through any point on the graph of $\frac{f(x)-f(0)}{x-0}$ will intersect the graph of $f'(x)$ somewhere between $0$ and $x$. As can be seen, this can be done without $\lim\limits_{x\to0}f'(x)$ existing.
