Derivatives of functions involving absolute value

I noticed that if the absolute value definition $\lvert{x}\rvert=\sqrt{x^2}$ is used, we can get derivatives of functions with absolute value, without having to redefine them as piece-wise.

For example, to get the derivative of $f(x)=x\lvert{x}\rvert$ we write $f(x)=x(x^2)^\frac{1}{2}$ and thus

$$ \begin{align} f'(x) &= \sqrt{x^2}+x\frac{1}{2}(x^2)^{-\frac{1}{2}}(2x) \\ &=\sqrt{x^2}+\frac{x^2}{\sqrt{x^2}} \\ &=\frac{2x^2}{\sqrt{x^2}} \\ &=\frac{2x^2}{\lvert{x}\rvert} \\ &=2\lvert{x}\rvert \\ \end{align} $$

which is correct. You just have to avoid using the law of exponents to simplify $\lvert{x}\rvert = (x^2)^\frac{1}{2}=x^{2(\frac{1}{2})}=x$.

My question is, why does using $\lvert{x}\rvert=\sqrt{x^2}$ to get derivatives work, and why does the law of exponents seem to show that $\lvert{x}\rvert=x$ ?


$\lvert x\rvert$ is partially-differentiable function, since piece-wise notation is more clear and natural for it. By expressing and differentiating it as $\sqrt{x^2}$ you introduce $\sqrt x$ function that is still non-differentiable in point $x=0$. So, writing smooth analytical formulas that work towards disguising the fact of non-differentiable points doesn't introduce any great value.

If you merely don't like piece-wise notation form, then follow the first commenter's note and use $sgn (x)$ representing $\lvert x\rvert'$ for $x\ne0$.