An example of a function which is everywhere

Question:

An example of a function which is everywhere continuous but fails to be differentiable exactly at two points is ____________.

Solution:

Consider the function $g(x)=|x-1|+|x+1|$.

$|x-1|= \begin{cases}x-1, & x \geq 1 \\ -(x-1), & x<1\end{cases}$

$|x+1|= \begin{cases}x+1, & x \geq-1 \\ -(x+1), & x<-1\end{cases}$

$\therefore g(x)=|x-1|+|x+1|= \begin{cases}-(x-1)-(x+1), & x<-1 \\ -(x-1)+x+1, & -1 \leq x<1 \\ x-1+x+1, & x \geq 1\end{cases}$

$\Rightarrow g(x)=|x-1|+|x+1|= \begin{cases}-2 x, & x<-1 \\ 2, & -1 \leq x<1 \\ 2 x, & x \geq 1\end{cases}$

When $x<-1, g(x)=-2 x$ which being a polynomial function is continuous and differentiable.

When $-1 \leq x<1, g(x)=2$ which being a constant function is continuous and differentiable.

When $x \geq 1, g(x)=2 x$ which being a polynomial function is continuous and differentiable.

Let us check the continuity and differentiability of $g(x)$ at $x=-1$ and $x=1$.

At $x=-1$

$\mathrm{LHL}=\lim _{x \rightarrow-1^{-}} g(x)=\lim _{x \rightarrow-1}(-2 x)=-2 \times(-1)=2$

$\mathrm{RHL}=\lim _{x \rightarrow-1^{+}} g(x)=\lim _{x \rightarrow-1} 2=2$

$g(-1)=2$

Since $\lim _{x \rightarrow-1^{-}} g(x)=\lim _{x \rightarrow-1^{+}} g(x)=g(-1)$, so the function $g(x)$ is continuous at $x=-1$.

At $x=1$

$\mathrm{LHL}=\lim _{x \rightarrow 1^{-}} g(x)=\lim _{x \rightarrow 1} 2=2$

$\mathrm{RHL}=\lim _{x \rightarrow 1^{+}} g(x)=\lim _{x \rightarrow 1} 2 x=2 \times 1=2$

$g(1)=2 \times 1=2$

Since $\lim _{x \rightarrow 1^{-}} g(x)=\lim _{x \rightarrow 1^{+}} g(x)=g(1)$, so the function $g(x)$ is continuous at $x=1$.

Thus, the function g(x) is continuous everywhere i.e. for all x ∈ R.

Now,

$L g^{\prime}(-1)=\lim _{h \rightarrow 0} \frac{g(-1-h)-g(-1)}{-h}$

$\Rightarrow L g^{\prime}(-1)=\lim _{h \rightarrow 0} \frac{-2(-1-h)-2}{-h}$

$\Rightarrow L g^{\prime}(-1)=\lim _{h \rightarrow 0} \frac{2 h}{-h}$

$\Rightarrow L g^{\prime}(-1)=-2$

And

$R g^{\prime}(-1)=\lim _{h \rightarrow 0} \frac{g(-1+h)-g(-1)}{h}$

$\Rightarrow R g^{\prime}(-1)=\lim _{h \rightarrow 0} \frac{2-2}{-h}$

$\Rightarrow R g^{\prime}(-1)=\lim _{h \rightarrow 0} \frac{0}{-h}$

$\Rightarrow R g^{\prime}(-1)=0$

$\therefore L g^{\prime}(-1) \neq R g^{\prime}(-1)$

So, g(x) is not differentiable at x = −1.

Also,

$L g^{\prime}(1)=\lim _{h \rightarrow 0} \frac{g(1-h)-g(1)}{-h}$

$\Rightarrow L g^{\prime}(1)=\lim _{h \rightarrow 0} \frac{2-2 \times 1}{-h}$

$\Rightarrow L g^{\prime}(1)=\lim _{h \rightarrow 0} \frac{0}{-h}$

$\Rightarrow L g^{\prime}(1)=0$

And

$R g^{\prime}(1)=\lim _{h \rightarrow 0} \frac{g(1+h)-g(1)}{h}$

$\Rightarrow R g^{\prime}(1)=\lim _{h \rightarrow 0} \frac{2(1+h)-2 \times 1}{h}$

$\Rightarrow R g^{\prime}(1)=\lim _{h \rightarrow 0} \frac{2 h}{h}$

$\Rightarrow R g^{\prime}(1)=2$

$\therefore L g^{\prime}(1) \neq R g^{\prime}(1)$

So, g(x) is not differentiable at x = 1.

Thus, the function g(x) is differentiable everywhere except at x = −1 and x = 1.

An example of a function which is everywhere continuous but fails to be differentiable exactly at two points is $g(x)=|x-1|+|x+1|$