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

• Well, why shouldn't differentiating $\sqrt{x^2}$ using the ordinary rules work, as long as you stay away from $x=0$ of course? After all, you are composing perfectly differentiable functions. Though it is somewhat easier to differentiate $\lvert x\rvert$ as $x/\lvert x\rvert$, or $\operatorname{sgn}x$ if you wish. – Harald Hanche-Olsen Dec 4 '12 at 20:28
• The problem with the law of exponents there is that the square root function isn't totally well-defined. Every nonzero number has two square roots, a positive one and a negative one; when you say $|x| = \sqrt{x^2}$, you're always taking the positive one; when you say $x = \sqrt{x^2}$, you're taking the one with the same sign as $x$. These issues become a lot more apparent over the complex numbers, where every fractional power involves a choice of 'branch'. – Paul VanKoughnett Dec 4 '12 at 20:57

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