# Introduction

A short post. Firstly, $$\left|x\right|$$ is not simply $$\sqrt{x^2}$$. Secondly, no, you should not differentiate $$\sqrt{x^2}$$ to get the derivative of $$\left|x\right|$$. Why? Semantics. Also, it encourages bad practice when thinking about the absolute value function. Furthermore, it misses entirely the point of the definition of $$\left|x\right|$$ as a piecewise function. This is, of course, assuming $$\left|x\right|$$ is in fact piecewise and is defined by its piecewise representation.

Another issue arises when one tries to think about the absolute value function over the complex numbers. In essence: the principal-valued root varies based on the root and the complex number; $$\sqrt{z^2}\neq\sqrt{z^4}$$ over $$\mathbb{C}$$. You might be thinking - but, hey, we've only defined $$\left|x\right|$$ over the reals, why does this matter when we don't care about the complex numbers? And you're right, it shouldn't, but when we do try to consider an extension, how do we consider the best way to go about it? And so realistically, any of the possible functions we can derive in $$\mathbb{R}$$ that so happen to satisfy the definition of the absolute value should not necessarily be candidates for these extensions.

In fact, I'll show that a particular property of certain functions leads to a class of functions satisfying the definition of the absolute value over $$\mathbb{R}$$.

Additionally, I should not see proofs on major proof-sharing sites that encourage this practice.

# Class of Functions

Let $$f:\mathbb{R}\to\mathbb{R}$$ be a function for which there exists a partial inverse $$I:\mathbb{R}^+\cup\left\{0\right\}\to\mathbb{R}^+\cup\left\{0\right\}$$, such that:

$x=\begin{cases} I(f(x)) & x\geq 0 \\ -I(f(x)) & x\leq 0 \end{cases}$

From there:

\begin{align} &x=\begin{cases} I(f(x)) & x\geq 0 \\ -I(f(x)) & x\leq 0 \end{cases}\\ \implies&\begin{cases} I(f(x)) & x\geq 0 \\ -I(f(x)) & x\leq 0 \end{cases}-x=0\\ \implies&\begin{cases} I(f(x))-x & x\geq 0 \\ I(f(x))+x & x\leq 0 \end{cases}=0\\ \implies&\begin{cases} I(f(x)) & x\geq 0 \\ I(f(x)) & x\leq 0 \end{cases}=\begin{cases} x & x\geq 0 \\ -x & x\leq 0 \end{cases}\\ \implies&I(f(x))=\left|x\right| \end{align}

Hence, functions that satisfy this also satisfy associated properties with absolute value function. For example:

\begin{align} \frac{dI}{dx}(f(x))\frac{df}{dx}=\frac{\left|x\right|}{x}&& x\neq0 \end{align}

$\int_{0}^{x}{I(f(t))dt}=\frac{1}{2}x\left|x\right|$

Examples of $$f(x)$$: $${(ax)}^{2n}+b$$, for $$n\in\mathbb{Z}_{>0},\ a\in\mathbb{R}_{>0},\ b\in\mathbb{R}$$ and $$\cosh(x)$$. In fact, $$|x|$$ satisfies this for $$I(x)=x$$ (well, duh, haha).

$$f(x)$$ not included: $$\cos(x)$$ locally on $$[-\pi, \pi]$$.

# Derivative of $$\left|x\right|$$ via First Principles

Firstly, we consider:

$\left|x\right|=\begin{cases} x & x\geq 0 \\ -x & x\leq 0 \end{cases} = \begin{cases} x & x>0 \\ 0 & x=0 \\ -x & x<0 \end{cases}$

Since $$x=0$$ is a degenerate interval, we'll have to consider this case separately; hence we differentiate $$\left|x\right|$$ on $$\mathbb{R}\setminus\left\{0\right\}$$. Therefore:

\begin{align} \frac{d}{dx}\left|x\right|\biggr\rvert_{x=a}&=\lim_{x\to a}{\frac{\left|x\right|-\left|a\right|}{x-a}}\\ &=\lim_{x\to a}{\frac{1}{x-a}\begin{cases} x-a & x>0 & a>0 \\ x+a & x>0 & a<0 \\ -x-a & x<0 & a>0 \\ -x+a & x<0 &a<0 \end{cases}}\\ &=\lim_{x\to a}{\frac{1}{x-a}\begin{cases} 1 & x>0 & a>0 \\ x+a & x>0 & a<0 \\ -x-a & x<0 & a>0 \\ -1 & x<0 &a<0 \end{cases}}\\ \end{align}

Then consider that the middle two pieces are impossible. For $$a<0$$, $$x\in\left(a-\epsilon,a+\epsilon\right)$$ for $$\epsilon>0$$ and $$a+\epsilon<0$$, implying $$x>0$$. Likewise for the third piece, $$a>0$$, $$x\in\left(a-\epsilon,a+\epsilon\right)$$, and $$a-\epsilon>0$$, implying $$x>0$$. Therefore we have:

$\frac{d}{dx}\left|x\right|\biggr\rvert_{x=a}=\lim_{x\to a}{\begin{cases} 1 & x>0 & a>0 \\ -1 & x<0 &a<0 \end{cases}}=\begin{cases} 1 & a>0 \\ -1 &a<0 \end{cases}$

Finally, considering the $$x=0$$ case we have the limit:

$\frac{d}{dx}\left|x\right|\biggr\rvert_{x=0}=\lim_{x\to0}{\frac{\left|x\right|}{x}}$

This limit does not exist; consider substitutions $$x\mapsto t^2$$ and $$x\mapsto -t^2$$ which give different limits.

The derivative of $$\left|x\right|$$ at $$a$$ is therefore $$\frac{\left|a\right|}{a}$$ for non-zero $$a$$.