[Math] Differentiable function that is not continuous

calculuslimits

I was told that all differentiable functions are also continuous.
But I came across this function:

$$ f(x) =
\begin{cases}
2x+5, & x\ge0 \\
(x+1)^2, & x\lt0
\end{cases}$$

Where I seem to be able to prove that it is differentiable:

$(2x+5)$ and $(x+1)^2$ are polynomials and are differentiable everywhere.

For $x = 0$,

Right Derivative:

$$\lim\limits_{h \to 0^+} \frac{f(0+h) – f(0)}{h} = \lim\limits_{h \to 0^+} \frac{2h+5-5}{h} =\lim\limits_{h \to 0^+} \frac{2h}{h} = \lim\limits_{h \to 0^+} 2 = 2$$

Left Derivative:

$$\lim\limits_{h \to 0^-} \frac{f(0+h) – f(0)}{h} = \lim\limits_{h \to 0^-} \frac{(h+1)^2-1}{h} = \lim\limits_{h \to 0^-} \frac{h^2+2h+1-1}{h} \\= \lim\limits_{h \to 0^-} \frac{h^2+2h}{h} = \lim\limits_{h \to 0^-} h+2 = 2$$

Since Right Derivative = Left Derivative, thus $f(x)$ is differentiable.
But since $2(0) + 5 \ne (0+1)^2$, the function is not continuous.
So I'm confused. What went wrong in my working?

Best Answer

Since $f(0)=5$, the left derivative at $0$ is$$\lim_{x\to0}\frac{(x+1)^2-5}x=\lim_{x\to0}\frac{x^2+2x-4}x$$and this limit does not exist (in $\mathbb R$).