practicecalculus
Powers, roots and polynomials

Derivative of |x|: Formula, Proof and Examples

The derivative of |x| is x/|x|: 1 for x > 0, -1 for x < 0, and undefined at 0. See the proof, the corner at 0 and the chain rule for |u|.

Powers, roots and polynomials Updated 2 min read

At a glance

\frac{d}{dx}\,\lvert x\rvert = \frac{x}{\lvert x\rvert}
Derivative
\dfrac{x}{\lvert x\rvert} for x \ne 0
Piecewise form
1 for x > 0, -1 for x < 0
At x = 0
Does not exist, the graph has a corner
Chain rule form
\dfrac{d}{dx}\lvert u\rvert = \dfrac{u}{\lvert u\rvert}\,u'
Integral version
\int \lvert x\rvert\,dx = \frac{x\lvert x\rvert}{2} + C
On this page
  1. Graph of |x| and its derivative
  2. Proof, piece by piece
  3. Why there is no derivative at 0
  4. The chain rule version: derivative of |u|
  5. A function built from |x| that is differentiable
  6. Common mistakes

The derivative of \lvert x\rvert is \dfrac{x}{\lvert x\rvert}. In plain terms, the slope is 1 to the right of 0, -1 to the left of 0, and there is no slope at 0 itself.

\frac{d}{dx}\,\lvert x\rvert = \frac{x}{\lvert x\rvert} = \begin{cases} 1, & x > 0 \\ -1, & x < 0 \end{cases}

Graph of |x| and its derivative

Graph of y = |x| and its derivative
The V shape has slope -1 on the left and 1 on the right. The derivative jumps at x = 0, where it is undefined.

Proof, piece by piece

Split \lvert x\rvert into its two pieces. For x > 0, \lvert x\rvert = x, so the derivative is 1. For x < 0, \lvert x\rvert = -x, so the derivative is -1. In both cases the answer equals \frac{x}{\lvert x\rvert}: dividing a number by its absolute value just gives its sign.

Why there is no derivative at 0

Look at the difference quotient at x = 0:

\frac{\lvert 0 + h\rvert - \lvert 0\rvert}{h} = \frac{\lvert h\rvert}{h}

From the right (h > 0) this is 1. From the left (h < 0) it is -1. The one-sided limits disagree, so the limit does not exist. The graph has a sharp corner, and no single tangent line fits it. This is the textbook example in the lesson on differentiability.

Another way to write the result is \frac{d}{dx}\lvert x\rvert = \frac{x}{\sqrt{x^2}}, since \lvert x\rvert = \sqrt{x^2}. Differentiating \sqrt{x^2} with the chain rule gives \frac{2x}{2\sqrt{x^2}}, the same formula.

The chain rule version: derivative of |u|

\frac{d}{dx}\,\lvert u\rvert = \frac{u}{\lvert u\rvert}\cdot u', \qquad u \ne 0

Example 1. \frac{d}{dx}\lvert 3x\rvert = \frac{3x}{\lvert 3x\rvert}\cdot 3, which is 3 for x > 0 and -3 for x < 0.

Example 2. \frac{d}{dx}\lvert x^2 - 4\rvert = \frac{(x^2 - 4)\cdot 2x}{\lvert x^2 - 4\rvert}. For \lvert x\rvert > 2 this is 2x. For \lvert x\rvert < 2 it is -2x. At x = \pm 2 the graph has corners and no derivative.

Example 3. \frac{d}{dx}\lvert\sin x\rvert = \frac{\sin x\cos x}{\lvert\sin x\rvert}, undefined wherever \sin x = 0.

A function built from |x| that is differentiable

Multiplying by x smooths the corner. Take f(x) = x\lvert x\rvert. For x > 0 it is x^2, for x < 0 it is -x^2, so f'(x) = 2\lvert x\rvert. At 0 the difference quotient is \frac{h\lvert h\rvert}{h} = \lvert h\rvert \to 0, so f'(0) = 0 exists. This f is also an antiderivative of 2\lvert x\rvert, which is how the integral of |x| is found.

Common mistakes

  1. Answering \lvert 1\rvert = 1. The derivative is not 1 everywhere. On the left side it is -1.
  2. Saying f'(0) = 0. The corner has no tangent line, so the derivative at 0 does not exist.
  3. Thinking continuous means differentiable. \lvert x\rvert is continuous at 0 but still has no derivative there.

For the function itself, see the absolute value function page.

Practice it now

When derivatives fail

Solve real problems on this topic with instant feedback, hints and a step-by-step walkthrough for every answer. Free, no sign-up needed to start.

Practice this lesson

Frequently asked questions

What is the derivative of |x|?

It is \frac{x}{\lvert x\rvert}, which equals 1 when x > 0 and -1 when x < 0. It does not exist at x = 0.

Why is |x| not differentiable at 0?

The slope from the right is 1 and the slope from the left is -1. The two one-sided limits of the difference quotient are different, so the derivative does not exist.

What is the derivative of |x| at x = 3?

It is 1, because near x = 3 the function is just x.

What is the derivative of |x - 2|?

It is \frac{x - 2}{\lvert x - 2\rvert}: 1 for x > 2, -1 for x < 2, and undefined at x = 2.

Written by the PracticeCalculus team

We build interactive calculus lessons and write every page to be clear and correct. Spotted something off? Tell us and we will fix it.