# Differentiable function that is not continuous?

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?

• When computing the left derivative, you unwittingly substituted $f(0)=1$, which is not true. By definition, we should have $f(0) =5$ and this can be used to show that the left derivative is undefined. – Sangchul Lee Jul 28 '17 at 10:27
• @SangchulLee I dont quite understand why $f(0)$ in the left derivative should be 5 tho. Shouldn't $f(0)$ in the left derivative be $(0+1)^2$ which is equals to 1? – Evitan Retla Jul 28 '17 at 10:48
• Your function is defined to take value $5$ at $x=0$. Why do you bother to use the left limit $\lim_{x\to 0^-} f(x) = 1$ instead of the function value $f(0)=5$? I would like to remind you that the equality $f(x)=(x+1)^2$ holds a priori for $x<0$ by definition. – Sangchul Lee Jul 28 '17 at 10:51
• @SangchulLee Ah I see. It all makes sense now. Thanks for the help! ᶘ ᵒᴥᵒᶅ – Evitan Retla Jul 28 '17 at 11:13

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$).
• You mean $f(0) = 5$. :-) But the conclusion remains the same. – Andre Jul 28 '17 at 10:23
$$\lim_{x\rightarrow0+}f(x)=5$$ but $$\lim_{x\rightarrow0-}f(x)=1$$ Therefore the limit at $x=0$ doesn't exist. Although the one-sided derivatives exist at $x=0$, that doesn't mean that the function is differentiable there because it is discontinuous.