Prove the function $f:\mathbb{R}\rightarrow\mathbb{R}$ defined by $f(x)= \begin{cases}x^2 & x\in\mathbb{Q}\\-x^2 & else\end{cases}$
is differentiable at $x=0$ and that $f'(0)=0$.
Hey everyone, this is a simple calculus problem I've encountered, but I don't really know how to prove this using the definition $lim_{x\to 0} \frac{f(x)-f(0)}{x-0}=f'(x)$ because of the cases. It is trivial that if $x\in\mathbb{Q}$ then $f'(x)=2x$, else $f'(x)=-2x \Rightarrow$ both limits of these functions are zero when $x$ is approaching zero, but how do I formally prove the function is differentiable at $0$? Thanks :)
$$\lim_{x \to 0} \left| \frac{f(x)-f(0)}{x}\right|=\lim_{x \to 0} \left| \frac{f(x)}{x}\right|=\lim_{x \to 0}\frac{x^2}{|x|}=\lim_{x \to 0}|x|=0$$
Hence $$\lim_{x \to 0} \frac{f(x)-f(0)}{x}=0$$