# is this continuous and differentiable

Let $I=\{1\}\cup\{2\}$, for $x\in\mathbb{R}$,$f(x)=\operatorname{dist}(x,I)=\inf\{|x-y|:y\in I\}$ Then

1.$f$ is discontinuous some where on $\mathbb{R}$

2.$f$ is continuous on $\mathbb{R}$ but not differentiable only at $1$

3.$f$ is continuous on $\mathbb{R}$ but not differentiable only at $1,2$

4.$f$ is continuous on $\mathbb{R}$ but not differentiable only at $1,2,3/2$

What I think is $f(x)=0$ when $x=1,2$ and $f(x)>0$ when $x\in \mathbb{R}\setminus\{1,2\}$ so it is continuous on $\mathbb{R}$ and it is not differentiable at $1,2$. Am I right?

-
The graph of your function has W-shape. I am not sure what you mean by $f(x)=0$. It is definitely not zero everywhere, only for $x\in I$. – Martin Sleziak Jun 11 '12 at 16:30
sorry I missed writing that point, I have drawn that. – La Belle Noiseuse Jun 11 '12 at 16:33
What about $x=\frac32$? (Sorry for the typo before, I'll delete the previous comment.) – Martin Sleziak Jun 11 '12 at 16:46
ah! at that point it has a pick again so its non differentiable there also! – La Belle Noiseuse Jun 11 '12 at 16:49
The graph you sketched should look like the graph here. – Martin Sleziak Jun 11 '12 at 16:58

If $x \in (-\infty,1)$, we have $f(x) = 1-x$, which is differentiable. Similar reasoning shows that $f$ is differentiable on $(1,1.5)$, $(1.5,2)$ and $(2,\infty)$.

Now check differentiability of $f$ at $\{1,1.5,2\}$:

If $x=1$, and $|h|<\frac{1}{2}$, we have $f(1+h)=|h|$, this gives $\lim_{h\downarrow 0} \frac{f(1+h)-f(1)}{h} = +1$, but $\lim_{h\uparrow 0} \frac{f(1+h)-f(1)}{h} = -1$, hence $f$ is not differentiable at $x=1$.

If $x=1.5$, then if $|h|<\frac{1}{2}$, we have $f(1.5+h) = .5-|h|$; similar reasoning applies.

Finally, at $x=2$, if $|h|<\frac{1}{2}$, we have $f(2+h) = |h|$, which is the same as the $x=1$ case, hence not differentiable at this $x$.

-
thank you............ – La Belle Noiseuse Jun 11 '12 at 18:22

Option $4$ is the correct one. The function isn't differentiable at $\frac{3}{2}$.

How do you see this. Well, first try to sketch the graph of $f$ and then it should be clear.

If you want to be more precise, you could try to write down an expression for $f$. So $$f(x) = \begin{cases} 1 - x & \text{for } x \leq 1 \\ ??_1 & \text{for } 1 < x \leq \frac{3}{2} \\ ??_2 & \text{for } \frac{3}{2} < x < 2 \\ x - 2 & \text{for } 2 \leq x \end{cases}$$ (fill in $??_1$ and $??_2$.)

Then you could use this expression to check the differentiability by definition. I.e. you would for example check whether (considering the point $x = 2$)

\begin{align} \lim_{h\to 0^{+}} \frac{f(2 + h) - f(2)}{h} &= \lim_{h\to 0^{-}} \frac{f(2 + h) - f(2)}{h} \quad \quad\Leftrightarrow \\ \lim_{h\to 0^{+}} \frac{2+h - 2 - 0}{h} &= \lim_{h\to 0^{-}} \frac{??_2(2 + h) - 0} {h}. \end{align}

-

To point out an issue with your reasoning, consider the function $g(x)=(x-1)^2(x-2)^2$. Then $g(x)=0$ for $x=1,2$ and $g(x)>0$ when $x\in\Bbb R\smallsetminus\{1,2\}$, but $g$ is in fact infinitely differentiable on all of $\Bbb R$.

-
thank you........... – La Belle Noiseuse Jun 11 '12 at 18:22