# What is the derivative of $|x^3|$?

Let $f(x)=|x^3|$.

I found two ways to differentiate this function. Apparently method 2 is wrong, but I cannot figure out why. So the question is, is method two wrong and why?

### Method 1 (according to wolfram mathematica)

$$f(x)=|x^3|=|x|^3$$

$$f'(x)=3|x|^2 \text{Sgn}(x)=3|x^2|\frac{x}{|x|}=3|x|x$$

### Method 2 (using chain-rule)

$$f'(x)= \text{Sgn}(x^3)\cdot3x^2$$

With method 2 it seems $f'(0)$ is not defined, since $\text{Sgn}(0)$ is not defined. However, this is not true according to WolframAlpha.

• Using the limit definition of the derivative might help. – Khallil Aug 13 '15 at 9:57
• You must come to the same conclusion with Method 1 as well ! – Yves Daoust Aug 13 '15 at 10:35
• Added note: as a function of a complex variable, $|x^3|$ is not differentiable anywhere. – GEdgar Aug 13 '15 at 12:39

This is a nice question as it highlights an important subtlety in the chain rule, although it's a subtlety that comes up rarely. The chain rules tells us that $$\frac{d}{dx} (f \circ g)(a) = f'(g(a)) \cdot g'(a),$$ provided that $g$ is differentiable at $a$ and $f$ is differentiable at $g(a)$.

It may happen that $f \circ g$ is differentiable at $a$ even if one of these hypotheses does not hold. This question is an example. Here, $g(x) = x^3$ and $f(x) = |x|$. Since $f$ is not differentiable at $g(0) = 0$, the hypotheses of the chain rule do not apply at $0$ and it is illegitimate to use it to conclude anything about the derivative there. Therefore, you must find another way. As you see, when we compute in the other direction, we see that in fact the derivative exists at the origin and is zero.

• So strictly speaking the first method is also wrong, since that also involves dividing by zero in case of x=0? – GambitSquared Aug 13 '15 at 10:17
• that's right, the first method is not a rigorous proof. To rigorously prove this, you should start from the definition of the derivative as a limit. – hunter Aug 13 '15 at 10:19
• Yeah, but still wolframalpha gives that solution (method 1) including a step-by-step explanation where they cancel out the |x| in the nominator and the denominator – GambitSquared Aug 13 '15 at 10:22
• @ImreVégh it is not rigorous, but I would say it's not so bad. To make it rigorous would take a little work though! (What is being used is that if a function $f$ is differentiable away from a point $a$, and the function $f'$ has a limit at $a$, then you can conclude that $f$ is differentiable at $a$ and $f'(a)$ is equal to that limit.) – hunter Aug 13 '15 at 10:27
• @ImreVégh (in the little lemma I mention in the previous comment, you also need the hypothesis that $f$ is continuous at $a$.) – hunter Aug 13 '15 at 10:34

Undisputably,

$$\lim_{x\to0^+}\frac{|x^3|-|0^3|}{x-0}=\lim_{x\to0^+}\frac{x^3}x=\lim_{x\to0^+}x^2=0,$$ $$\lim_{x\to0^-}\frac{|x^3|-|0^3|}{x-0}=\lim_{x\to0^-}\frac{-x^3}x=\lim_{x\to0^-}-x^2=0.$$

Other $x$ cause no real difficulty.

• You might want to add for completeness of the answer that $f'(x) = \pm 3x^2$ away from $0$ and that only issue might arise at $0$, thus needs to be resolved as you wrote. – Ennar Aug 13 '15 at 11:24

I learned that, ...

... whenever you want to compute the derivative of a function involving an absolute value, first convert the absolute value into its definition $$|x| = \sqrt{x^2} = (x^2)^{\frac{1}{2}}.$$

So, $f$ can be re-written as $$f(x) = |x^3| = ((x^3)^2)^{\frac{1}{2}}.$$ If we now apply the chain rule multiple times to compute its derivative, we obtain $$\begin{eqnarray} \dfrac{df(x)}{dx} &=& \left( \dfrac{df(x)}{d((x^3)^2)} \right) \cdot \left( \dfrac{d((x^3)^2)}{dx} \right) \\ &=& \left( \dfrac{df(x)}{d((x^3)^2)} \right) \cdot \left( \dfrac{d((x^3)^2)}{d(x^3)} \right) \cdot \left( \dfrac{d(x^3)}{dx} \right) \\ &=& \left( \dfrac{1}{2} \dfrac{1}{((x^3)^2)^{\frac{1}{2}}} \right) \cdot \left( 2x^3 \right) \cdot \left( 3x^2 \right) \\ &=& \dfrac{3x^5}{((x^3)^2)^{\frac{1}{2}}}. \end{eqnarray}$$ Now there are two options of how to proceed:

1. Combine $(x^3)^2 = x^6$ to yield $\dfrac{df(x)}{dx} = \dfrac{3x^5}{\sqrt{x^6}}$.
2. Or use again the definition of the absolute value to yield $\dfrac{df(x)}{dx} = \dfrac{3x^5}{|x^3|}$.

The computer algebra system Maple seems to prefer the first option; I would prefer the second one, because we started with an absolute value in the original function and end with an absolute value in its derivative. Nonetheless, both are equivalent.

• Still in your answer f'(x) is not defined for x=0, while it should be f'(0)=0, how come? – GambitSquared Aug 13 '15 at 12:43
• No, as you said: $\dfrac{df(0)}{dx}$ is not defined. You can see that the expression $\dfrac{3 \cdot 0^5}{|0^3|}$ would lead to a division by zero. Consequently, $\dfrac{df(0)}{dx} = 0$ is a wrong. It should not be a true statement. – Björn Friedrich Aug 13 '15 at 12:57
• I think it is defined, since the left and right limit of f'(x) for x->0 are both 0 – GambitSquared Aug 13 '15 at 12:58
• Well, the point is that the undisputable computation of the limit above is false. $$\lim_{x \to 0} \dfrac{|x^3| - |0^3|}{x - 0} = \lim_{x \to 0} \dfrac{|x^3|}{x} = \dfrac{ \lim_{x \to 0} |x^3| }{ \lim_{x \to 0} x } = \dfrac{0}{0}.$$ So, we apply l'Hospitals rule and compute $$\lim_{x \to 0} \dfrac{\frac{1}{2}\frac{1}{|x^3|}}{1} = \lim_{x \to 0} \dfrac{1}{2}\dfrac{1}{|x^3|}.$$ But this limit diverges!!! – Björn Friedrich Aug 13 '15 at 13:35