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?


  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?
  • 2
    $\begingroup$ Note that $f(x)=x+x=2x$ when $x>0$ and $f(x)=0$ otherwise, Since both are individually differentiable, the only point that we should check would be the point where the definition of $f$ changes, i.e $x=0$ $\endgroup$ – Nikunj May 21 '16 at 12:04
  • 1
    $\begingroup$ Yes it is wrong because that expression of $f'(x)$ in the wrong solution does not evaluate to 2 at 0. It is $0/0$ which is undefined so we would need to check left and right limits. $\endgroup$ – mathreadler May 21 '16 at 12:04

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$.


The best thing to do is to simplify the function before you use the definition of the derivative. For $x\geq 0$, $f(x)=x+|x|=x+x=2x$, while, for $x <0$, $f(x)=x-x=0$. Hence, we have the following:

$$ \begin{aligned} f(x)= \begin{cases} 2x &\text{ if }x\geq 0\\ 0 &\text{ if }x < 0 \end{cases}. \end{aligned} $$

From this, we can see right away that $f$ is differentiable for all $x\not=0$. So, we only need to focus on $x=0$.

$$ \lim_{h\to 0^{-}}\frac{f(0+h)-f(0)}{h}=\lim_{h\to 0^{-}}\frac{f(h)}{h}=\lim_{h\to 0^{-}}\frac{0}{h}=0, $$ while $$ \lim_{h\to 0^{+}}\frac{f(0+h)-f(0)}{h}=\lim_{h\to 0^{+}}\frac{f(h)}{h}=\lim_{h\to 0^{+}}\frac{2h}{h}=2. $$

Since these limits aren't equal, $f$ is not differentiable at $0$.

For your second question: you cannot take the derivative using the usual rules since $|x|$ itself is not differentiable at $0$.

  • $\begingroup$ Just out of curiosity are there any other functions where differentiation rules break down, besides piece-wise functions? $\endgroup$ – Perturbative May 21 '16 at 12:22
  • $\begingroup$ Whenever you can isolate an interval in which all components of the function are differentiable, you can apply the usual laws. In this case, all parts of the function are differentiable on $(-\infty,0)\cup(0,\infty)$, which is why we can apply the usual laws there. $\endgroup$ – ervx May 21 '16 at 13:08

If $x\lt 0$ then $f(x)=0$ and if $x\ge 0$ then $f(x)=2x$. Thus the function $f$ is differentiable in all points excepting for $x=0$ where, it is clear, there is not a well defined tangent. Another way is take $f$ as being the sum of $x$ plus $|x|$ and it is well known that $|x|$ is not differentiable in $x=0$


$f$ is differentiable in $a \in \mathbb{R}$ if and only if $f-\text{id}$ is differentiable in $a$, so $f$ is differentiable in $a$ if and only if the absolute value function is differentiable in $a$. Now the absolute value function is differentiable in $a$ for $a \neq 0$, basically because if $a>0$, to get $$|\frac{|a+h|-|a|}{h}-1|$$ small, one chooses $|h|$ so small that $a+h$ is positive for all $h$ that small (an analogous argument applies to $a<0$). This trick cannot be done for $a=0$ of course, and one easily checks that $$\lim_{h \to 0^+} \frac{|a+h|-|a|}{h}=1 \neq -1 = \lim_{h \to 0^-} \frac{|a+h|-|a|}{h}, $$ so that the limit does not exist for $a =0$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.