Absolute value rule

Away from the corner, the absolute value is a straight line of slope \(\pm 1\).

\[\frac{d}{dx}\left|x\right| = \operatorname{sgn} x, \; x \neq 0\]

What it says

\(\left|x\right|\) is \(x\) for positive \(x\) and \(-x\) for negative \(x\), so its slope is \(+1\) on the right and \(-1\) on the left. That is exactly the sign function, \(\operatorname{sgn} x\).

At \(x = 0\) there is no derivative at all. Approaching from the right the difference quotient is \(+1\), from the left \(-1\); the one-sided limits disagree, so the two-sided limit does not exist. The graph has a corner, not a tangent.

For a compound argument the chain rule applies as usual: \(\frac{d}{dx}\left|u\right| = \operatorname{sgn}(u)\,u'\), valid wherever \(u \neq 0\).

When it applies

  • \(\left|x\right|\) or \(\texttt{abs(x)}\), alone or inside a larger expression.
  • Anywhere the argument is nonzero — the answer is undefined at the zeros of the argument.
  • Also covers \(\sqrt{x^{2}}\), which is \(\left|x\right|\) rather than \(x\).

Five worked examples

Every line is the step the calculator would show, in the order it applies them. Each graph is live: hover it to read both curves and see the tangent whose slope is the derivative, drag to pan, scroll to zoom.

Example 1
\[\frac{d}{dx}\left[\left|x\right|\right]\]
  1. Split by sign: the graph is \(-x\) then \(x\).

    \[\left|x\right| = \begin{cases} x & x > 0 \\ -x & x < 0\end{cases}\]
  2. Each piece is a line, with slope \(+1\) or \(-1\).

    \[\frac{d}{dx}\left|x\right| = \operatorname{sgn} x\]
Answer
\[\operatorname{sgn}\left(x\right)\]

The V and its step. f′ jumps from \(-1\) to \(+1\) at the origin with no value in between, and that gap is the whole point: a corner has no tangent. Hover just either side and the readout flips sign without passing through anything.

Undefined at \(x = 0\), where the two slopes meet at a corner.

Open abs(x) in the calculator
Example 2
\[\frac{d}{dx}\left[\left|x - 3\right|\right]\]
  1. Chain rule with \(u = x - 3\), and \(u' = 1\).

    \[= \operatorname{sgn}\left(x - 3\right)\cdot 1\]
Answer
\[\operatorname{sgn}\left(x - 3\right)\]

The same pair shifted to \(x = 3\), where the step in f′ marks the corner in f.

The corner has moved to \(x = 3\); the derivative jumps from \(-1\) to \(+1\) there.

Open abs(x-3) in the calculator
Example 3
\[\frac{d}{dx}\left[x \left|x\right|\right]\]
  1. Product rule.

    \[= 1\cdot\left|x\right| + x\operatorname{sgn} x\]
  2. Since \(x\operatorname{sgn} x = \left|x\right|\), this is \(2\left|x\right|\).

    \[= 2\left|x\right|\]
Answer
\[\left|x\right| + x \operatorname{sgn}\left(x\right)\]

No corner here — multiplying by x has ironed it out, and f′ is the V \(2\left|x\right|\) touching zero smoothly at the origin.

Unusually, this one is differentiable at \(0\): the product smooths the corner out, and the derivative there is \(0\).

Open x abs(x) in the calculator
Example 4
\[\frac{d}{dx}\left[\left|x^{2} - 1\right|\right]\]
  1. Chain rule with \(u = x^{2} - 1\).

    \[= \operatorname{sgn}\left(x^{2} - 1\right)\cdot 2x\]
Answer
\[2 x \operatorname{sgn}\left(x^{2} - 1\right)\]

A parabola whose middle has been reflected upwards into an arch, with f′ breaking at both folds.

Two corners, at \(x = \pm 1\), where the parabola crosses the axis.

Open abs(x^2-1) in the calculator
Example 5
\[\frac{d}{dx}\left[\left|\sin\left(x\right)\right|\right]\]
  1. Chain rule with \(u = \sin x\).

    \[= \operatorname{sgn}\left(\sin x\right)\cos x\]
Answer
\[\cos\left(x\right) \operatorname{sgn}\left(\sin\left(x\right)\right)\]

A row of identical arches sitting on the axis, with f′ jumping sign at the foot of every one.

A corner at every multiple of \(\pi\) — the rectified sine wave.

Open abs(sin(x)) in the calculator

Watch out for

  • There is no derivative at the zeros of the argument, only on either side of them.
  • \(\sqrt{x^{2}} = \left|x\right|\), not \(x\), so its derivative is \(\operatorname{sgn} x\).
  • \(\operatorname{sgn}\) itself has derivative \(0\) away from the origin — it is locally constant, not linear.