$$s(x)=\begin{cases} x^2+1 \quad\quad x<0 \\ x+2 \,\,\quad\quad0\leq x<2\\ x^2 \,\,\,\quad\quad\quad x \ge2 \end{cases} $$ In which points is the function differentiable?
It is my understanding that a function is differentiable if the point is continuous, so I am asking if I need to check if s(x) is continuous when x=0 and x=2? But I know that the function is continuous for all x's otherwise except these two points. To check if x=0 is continuous I need to make sure this applies:
$\lim_{x \to 0} x^2 + 1 = s(0)$
But I don't know how to simplify $x^2 + 1$ more, do I just put x=0 and check? In that case I get $1 \neq s(0)=2$?
I did same thing for x=2 and found out that $\lim_{x \to 2} x + 2 = 2+2= 4 = s(0)= 2^2=4$?
My answer was then that x was differentiable for all $x \neq 0$. But the answer is that x is differentiable for $x \neq 0$ and $x \neq 2$
Continuity is a requirement for differentiability; e.g., $$f(x) = \begin{cases}1, & x \ge 0 \\ -1, & x < 0 \end{cases}$$ is not differentiable at $x = 0$ because $$\lim_{h \to 0^+} \frac{f(h) - f(0)}{h} = \lim_{h \to 0} \frac{1 - 1}{h} = 0,$$ but $$\lim_{h \to 0^-} \frac{f(h) - f(0)}{h} = \lim_{h \to 0^-} \frac{-1-1}{h} = \infty.$$
However, continuity is not in itself sufficient for differentiability; e.g.,
$$g(x) = |x| = \begin{cases}x, & x \ge 0 \\ -x, & x < 0 \end{cases}$$ is continuous everywhere, but not differentiable at $x = 0$:
$$\lim_{h \to 0^+} \frac{g(h) - g(0)}{h} = \lim_{h \to 0^+} \frac{h - 0}{h} = 1,$$ but $$\lim_{h \to 0^-} \frac{g(h) - g(0)}{h} = \lim_{h \to 0^-} \frac{-h - 0}{h} = -1.$$ The fact that the limit from above and from below are not equal implies $$\lim_{h \to 0} \frac{g(h) - g(0)}{h}$$ does not exist.
Now you can see where the flaw is: for your function $$s(x) = \begin{cases} x^2 + 1, & x < 0 \\ x+2, & 0 \le x < 2 \\ x^2, & x \ge 2 \end{cases}$$ you must not only consider whether $s$ is continuous at $x = 0$ and $x = 2$, but you need to determine whether the two-sided limits $$\lim_{h \to 0} \frac{s(h) - s(0)}{h}, \quad \lim_{h \to 0} \frac{s(2+h) - s(2)}{h}$$ exist.