Discuss the continuity and differentiability of the $f(x)=|x|+|x-1|$ in the interval $(-1,2)$
Given : $f(x)=|x|+|x-1|$
$|x|=-x$ for $x<0$
$|x|=x$ for $x>0$
$|x-1|=-(x-1)=-x+1$ for $x-1<0$ or $x<1$
$|x-1|=x-1$ for $x-1>0$ or $x>1$
Now,
$f(x)=-x-x+1=-2 x+1 \quad x \in(-1,0)$
Or
$f(x)=x-x+1=1 \quad x \in(0,1)$
Or
$f(x)=x+x-1=2 x-1 \quad x \in(1,2)$
Now,
$\mathrm{LHL}=\lim _{x \rightarrow 0^{-}} f(x)=\lim _{x \rightarrow 0^{-}}-2 x+1=0+1=1$
$\mathrm{RHL}=\lim _{x \rightarrow 0^{+}} f(x)=\lim _{x \rightarrow 0^{+}} 1=1$
Hence, at $x=0, \mathrm{LHL}=\mathrm{RHL}$
Again,
$\mathrm{LHL}=\lim _{x \rightarrow 1^{-}} f(x)=\lim _{x \rightarrow 1^{-}} 1=1$
$\mathrm{RHL}=\lim _{x \rightarrow 1^{+}} f(x)=\lim _{x \rightarrow 1^{+}} 2 x-1=2-1=1$
Hence, at $x=1, \mathrm{LHL}=\mathrm{RHL}$
Now,
$f(x)=-x-x+1=-2 x+1 \quad x \in(-1,0)$
$\Rightarrow f^{\prime}(x)=-2 \quad x \in(-1,0)$
or
$f(x)=x-x+1=1 \quad x \in(0,1)$
$\Rightarrow f^{\prime}(x)=0 \quad x \in(0,1)$
or
$f(x)=x+x-1=2 x-1 \quad x \in(1,2)$
$\Rightarrow f^{\prime}(x)=2 \quad x \in(1,2)$
Now,
$\mathrm{LHL}=\lim _{x \rightarrow 0^{-}} f^{\prime}(x)=\lim _{x \rightarrow 0^{-}}-2=-2$ $\mathrm{RHL}=\lim _{x \rightarrow 0^{+}} f^{\prime}(x)=\lim _{x \rightarrow 0^{+}} 0=0$
Since, at $x=0, \mathrm{LHL} \neq \mathrm{RHL}$
Hence, $f(x)$ is not differentiable at $x=0$
Again,
$\mathrm{LHL}=\lim _{x \rightarrow 1^{-}} f^{\prime}(x)=\lim _{x \rightarrow 1^{-}} 0=0$ $\mathrm{RHL}=\lim _{x \rightarrow 1^{+}} f^{\prime}(x)=\lim _{x \rightarrow 1^{+}} 2=2$
Since, at $x=1, \mathrm{LHL} \neq \mathrm{RHL}$
Hence, $f(x)$ is not differentiable at $x=1$