Limit of sequences equals $f'(0)$ I'm working on a question that states:
Consider a differentiable function $f:\mathbb{R}\to\mathbb{R}$. Furthermore consider the sequences $(x_n)_n$ and $(y_n)_n$ which both have limit $0$ and $x_n < y_n$ for all $n\in\mathbb{N}$. Is the following true?
$$\lim_{n\to\infty} \frac{f(y_n)-f(x_n)}{y_n-x_n} = f'(0). $$
If yes give a proof, if no give a counter example and find the extra requirements for it to be true.
I thought it was true and as a proof I did the following:
Given that $f$ is differentiable and that $x_n < y_n$, by the mean value theorem there exists a $c_n \in (x_n,y_n)$ such that
$$ \frac{f(y_n)-f(x_n)}{y_n-x_n} = f'(c_n). $$
As $x_n$ and $y_n$ both converge to $0$ we have that $c_n$ will also converge to $0$. Therefore, by taking the limit for $n$ to infinity we find that
$$\lim_{n\to\infty} \frac{f(y_n)-f(x_n)}{y_n-x_n} = \lim_{n\to\infty}f'(c_n) = f'(0). $$
At this point I realised that I had used the continuity of $f'$ which was not given in the question. I am now wondering if this is a necessary condition for the problem or if it can be solved without using the continuity of $f'$. If it is a necessary condition what is a suitable counter example where $f'$ isn't continuous? Any help is appreciated.
 A: A counterexample has been given in the comment: $f(x) = x^2 \sin (1/x)$. Actually, any differentiable functions so that $f'(x)$ does not converge to $f'(0)$ as $x\to 0$ suffices: in this case, there is $\epsilon_0>0$ and a sequence $x_n \to 0$ so that $|f'(x_n) - f'(0)| >\epsilon_0$ for all $n$. For each $n$, one can find by the definition of $f'(x_n)$, $y_n\in (x_n, x_n+1/n)$ so that
$$\left| \frac{f(y_n)-f(x_n)}{y_n-x_n} - f'(x_n)\right| < \frac 12 \epsilon_0.$$
Then $y_n\to 0$, $x_n < y_n$. Also,
\begin{align}
\epsilon_0 &< |f'(x_n) - f'(0)|\\
& <\left| \frac{f(y_n)-f(x_n)}{y_n-x_n} - f'(x_n)\right| +\left|\frac{f(y_n)-f(x_n)}{y_n-x_n} - f'(0)\right| \\
&< \frac 12 \epsilon_0 +\left|\frac{f(y_n)-f(x_n)}{y_n-x_n} - f'(0)\right|
\end{align}
and this implies
$$\left| \frac{f(y_n)-f(x_n)}{y_n-x_n} - f'(0)\right|> \frac 12  \epsilon_0.$$
Thus $ \frac{f(y_n)-f(x_n)}{y_n-x_n}$ does not converge to $f'(0)$.
Together with what you did, the limit holds for all such sequences $(x_n), (y_n)$ if and only if $f'$ is continuous at $0$.
