In which point is the function not differentiable? $$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$

 A: 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.
A: Recall that for a real valued function differentiability implies continuity, but the converse  it is not true (i.e., continuity does not implies differentiability). Since we have a piecewise function so we need check directly using the definition of differentiability.
We have $s(0)=2$ and $s(2)=4$. Then,

*

*For $x<0$, we have $$\frac{s(x)-s(0)}{x-0}=\frac{x^2+1-2}{x}=\frac{x^2-1}{x}\to +\infty,\quad x\to 0^-$$
so $f$ is not differentiable at $x=0$.


*For $x<2$, we have $$\frac{s(x)-s(2)}{x-2}=\frac{x+2-4}{x-2}=\frac{x-2}{x-2}\to 1, \quad x\to 2^-$$
We need continue since we have a real number, then for $x>2$, we have
$$\frac{s(x)-s(2)}{x-2}=\frac{x^2-4}{x-2}=\frac{(x-2)(x+2)}{x-2}\to 4,\quad x\to 2^+$$but it is not matches the limit found above, then $f$ is not differentiable at $x=2$.
A: people above has explained your question, let me tell you one more thing that you are wrong saying that "It is my understanding that a function is differentiable if the point is continuous", it is wrong, let me explain it using a curve of f(x) = |x|.
f(x) = |x| is continuous everywhere but it is non-differentiable at x=0. because at x=0 graph is not smooth, there's a sharp turn, and whenever you have to find slope at sharp turn of graph, it'll always come to be undefined meaning it's non-differentiable, let me show it using graph:
https://www.geogebra.org/graphing/envhph4n (play this using play button or using slider)
you can clear see how slope changes at sharp turns.
Summary: at smooth curve: slope is defined but at sharp points: slope is undefined or we can say function is non-differentiable.
