Derivative of $x|x|$

I am trying to find the derivative of $f(x)=x|x|$ using the defition of derivative. For $x > 0$ I found that $f'(x)=2x$ and for $x<0$ the derivative is $f'(x)=-2x$. Everything is fine up to here. Now I want to check what happens when at $x=0$.

By the way, I know that $|x|$ is not differentiable at $x=0$.

So I am checking the left & right limits of $f$ when $x$ approaches $0$.

• $\lim_{x \to 0^-}\cfrac{x|x|}{x} = \lim_{x \to 0^-}\cfrac{x(-x)}{x}=\lim_{x \to 0^-}\cfrac{(-x)}{1} = -0? = 0.$

• $\lim_{x \to 0^+}\cfrac{x|x|}{x} = \lim_{x \to 0^4}\cfrac{x(x)}{x}=\lim_{x \to 0^+}\cfrac{(x)}{1} = 0.$

I think that $f$ is not differentiable at $x=0$ since $|x|$ is not differentiable at that point. So , what do I do wrong?

Should I write something like $\lim_{x \to 0^-}\cfrac{x|x|}{x} = -0^{-}$ and $\lim_{x \to 0^+}\cfrac{x|x|}{x} =0^{+}$ so that $f'$ does not exist at $x=0$?

• actually I got: $\lim_{x\to 0^{-}}=\lim_{x\to 0^{+}}=0$, so $f$ has derivative at $0$ and $f'(0)=0$. Mar 9 '17 at 22:08
• Neither of the functions $f(x)=\begin{cases}2 & x\geq0 \\ 1 & x<0\end{cases}$ and $g(x)=\begin{cases}1 & x\geq0 \\ 2 & x<0\end{cases}$ is differentiable at $x=0$, but their product $(f\cdot g)(x)=2$ is! Mar 9 '17 at 22:55

You did nothing wrong. Your calculated derivative is $$g(x)=\begin{cases}-2x & x<0\\ 2x & x>0 \\ 0& x=0\end{cases}$$

which is a continuous function, thus $f$ if differentiable.

What happens here is that the fact the zero of one function ($x \mapsto x$) smoothens out the undifferentiable point of the other function ($x \mapsto |x|$).

More generally, if $h_1(x_0)=0$ and $h_2$ is continuous in a neighborhood of $x_0$, then always $\lim_{x\rightarrow x_0}h_1(x)\cdot h_2(x)=0$, i.e. it doesn't matter how misbehaving $h_2$ is at $x_0$. Finally note that $x \mapsto |x|$ is continuously differentialble on any interval which does not include $x=0$.

• Thank you, especially for the generalization! Mar 9 '17 at 22:25
• The generalization should be taken with a grain of salt, however: The statement with the functions $h_1$ and $h_2$ is not wrong, but is it not a differential quotient. Mar 9 '17 at 22:36
• @Ninja By the way, it would be the wrong take-away to think that the derivative being continuous is always what makes it differentiable. There are examples like $x^2 \sin(1/x)$ where the value of the derivative oscillates wildly around $x=0$ but you can still calculate the derivative by definition and see that it's differentiable at $x=0$. That is why "differentiable" and "continuously differentiable" are distinct terms. Mar 9 '17 at 23:33

You didn't do anything wrong, you in fact shown that $f$ is differentiable at $x = 0$ and $f'(0) = 0$. The fact that $x \mapsto |x|$ is not differentiable at $x = 0$ doesn't mean that if you consider the product of this function with another function then the result won't be differentiable at $x = 0$, as you have just shown.

However, since you have shown that $f'(x) = 2|x|$ you can see that $f$ is not twice differentiable at $x = 0$.

\begin{eqnarray} g^\prime(x)&=&\lim_{h\to0}\frac{(x+h)\vert x+h\vert-x\vert x\vert}{h}\\ &=&\lim_{h\to0}\frac{(x+h)\vert x+h\vert-x\vert x\vert}{h}\cdot\frac{(x+h)\vert x+h\vert+x\vert x\vert}{(x+h)\vert x+h\vert+x\vert x\vert}\\ &=&\lim_{h\to0}\frac{(x+h)^4-x^4}{h((x+h)\vert x+h\vert+x\vert x\vert)}\\ &=&\lim_{h\to0}\frac{4x^3+6x^2h+4xh^2+h^3}{(x+h)\vert x+h\vert+x\vert x\vert}\\ &=&\frac{4x^3}{2x\vert x\vert}\\ &=&\frac{2x^2}{\vert x\vert}\\ &=&2x\cdot\frac{\vert x\vert}{x} \end{eqnarray}

For information, you have the following theorem which you can use

Let $I$ be an interval, $a\in I$. If a function $f$ is continuous on $I$, has a derivative on $I\smallsetminus\{a\}$ and if $f'(x)$ has a limit at $a$, then $f$ has a derivative at $a$, and $$f'(a)=\lim_{x\to a}f'(x).$$