<s>[INST] 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.
 [/INST] 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:


*

*Combine $(x^3)^2 = x^6$ to yield $\dfrac{df(x)}{dx} = \dfrac{3x^5}{\sqrt{x^6}}$.

*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.
</s>