Given the function:
$$f(x) = \begin{cases} x^2+1 & \text{if $x\ge0$} \\ x^2-1 & \text{if $x < 0$} \end{cases}$$
Question: are we justified to say that the derivative at $f(0)$ exists? If so, what is $f'(0)$? And how do we justify it?
Of course I do realize that the function isn't continuous at $x=0$ but still since the slope near $x=0$ seems equal near $0+$ and $0-$ I wondered why we can't say that $f'(0)=0$
What I tried is this:
$f_+'(0)=\lim\limits_{h \to 0+}\frac{(x+h)^2+1-(x^2+1)}{h}=\lim\limits_{h \to 0+}\frac{(0+h)^2+1-(0^2+1)}{h}=\lim\limits_{h \to 0+}\frac{h^2}{h}=h=0$ $f_-'(0)=\lim\limits_{h \to 0-}\frac{(x+h)^2+1-(x^2+1)}{h}=\lim\limits_{h \to 0-}\frac{(0+h)^2+1-(0^2+1)}{h}=\lim\limits_{h \to 0-}\frac{h^2}{h}=h=0$
My conclusion is that since both the right and left limit using the definition of the derivative exist and generate the same answer the limit exists such that $f'(0)=0$.
Apparently this is not true, so what is my mistake?