Calculus – Differentiability of f(x) = x + |x|

calculuscontinuityderivativeslimitsreal-analysis

Problem : Given $f(x) = x + |x|$ for what values of $x$ is $f$ differentiable?

For the sake of generality, let's assume that it is unknown to us that $|x|$ is not differentiable at $x = 0$

Attempted Solution :

Using the definition of differentiability, a function is differentiable over an interval $I$ $\text{iff}$

$$f'(x) = \lim_{h \to 0} \frac{f(x+h)-f(x)}{h}, \ \ \forall x\in I$$

Now implicitly this definition of differentiability requires $$\lim_{h\to 0^+} \frac{f(x+h)-f(x)}{h} = \lim_{h\to 0^-} \frac{f(x+h)-f(x)}{h}$$

Therefore $f$ will be differentiable only when

$$\lim_{h\to 0^+} \frac{(x + h + |x+h|)-(x + |x|)}{h} = \lim_{h\to 0^-} \frac{(x – h + |x-h|)-(x + |x|)}{h}$$

But it is unclear what to do next as $x$ is just arbitrary
$$
\begin{equation}
\begin{aligned}
|x+h| &= \begin{cases}x+h & \text{if} & x \geq -h\\ -x-h & \text{if} & x < -h \end{cases} \\
&= \begin{cases}x+h & \text{if} & x \geq 0\\ -x-h & \text{if} & x < 0 \end{cases}
\end{aligned}
\end{equation}$$


A Wrong Solution :

We could take the derivative of $f$, (and evaluate the domain of the derivative $f'(x)$ to values for which it is defined), using the rules of differentiation, but we would get a wrong answer.

$$f'(x) = \frac{|x| + x}{|x|}$$
$$\implies f'(x) = \begin{cases}
2 & \text{if} & x \geq 0 \\
0 & \text{if} & x < 0
\end{cases}$$

This implies the derivative $f'(0)$ exists, when it does not as per the definition of differentiability. Why is that so?


Questions:

  1. How can a solution be found using the definition of differentiablity?
  2. Why does taking the derivative of $f$, $f'(x)$ and evaluating it's domain, not give the correct values of $x$ for which $f$ is differentiable?

Best Answer

Given $f(x) = x + |x|$ for what values of $x$ is $f$ differentiable?

One may observe that $$ f(x) = \begin{cases} 2x & \text{if $x\geq 0$,} \\[2ex] 0 & \text{if $x<0$.} \end{cases} $$ Then one may apply the definition of differentiability, obtaining easily that $f$ is differentiable over $(-\infty,0)\cup (0,\infty)$.

At $x=0$, one has, as $h \to 0$, $$ \frac{f(h)-f(0)}{h}= \begin{cases} 2 & \text{if $h>0$,} \\[2ex] 0 & \text{if $h<0$,} \end{cases} $$ and the given function is not differentiable at $0$.