Derivative of the Absolute Value
Definition
The derivative of the absolute value function |x| is the sign function: $$ D[ \: |x| \: ] = \frac{x}{|x|} = \frac{|x|}{x} $$
You can write the sign function either with |x| in the numerator or in the denominator.
Both forms ultimately give the same result.
Proof
The absolute value function
$$ f(x)=|x| $$
can also be written in the equivalent form
$$ f(x)=\sqrt{x^2} $$
Note. The absolute value of a variable |x| is equal to the square root of x squared.
Since the derivative of a square root is
$$ D[\sqrt{x}]=\frac{1}{2 \sqrt{x}} $$
we can apply this rule to f(x):
$$ D[\sqrt{x^2}]=\frac{2x}{2 \sqrt{x^2}}= \frac{x}{\sqrt{x^2}}$$
This yields the derivative of f(x):
$$ f'(x) = \frac{x}{\sqrt{x^2}}$$
Recognizing that the square root of \( x^2 \) is simply |x|, we can rewrite f'(x) as:
$$ f'(x) = \frac{x}{|x|}$$
Thus, we arrive at the derivative of |x|, which is the sign function, also denoted as sgn(x).

The sign function takes the value 1 when \( x \) is positive (x > 0) and -1 when \( x \) is negative (x < 0).
Note. The sign function is not differentiable at x = 0.
Alternative Method
There’s also an alternative way to prove the derivative of the absolute value function.
We can rewrite \( f(x) = |x| \) as a piecewise function:
$$ f(x) = \begin{cases} f(x)=x \:\: \text{if} \:\: x \gt 0 \\ f(x)=-x \:\: \text{if} \:\: x \lt 0 \end{cases} $$
Differentiating each piece separately, we get:
$$ f'(x) = \begin{cases} f'(x)=1 \:\: \text{if} \:\: x \gt 0 \\ f'(x)=-1 \:\: \text{if} \:\: x \lt 0 \end{cases} $$
This leads us to the same result: the derivative is the sign function:
$$ f'(x) = sgn \: x $$
And so on.
