Integral of |x|: Formula, Derivation and Examples
The integral of |x| is x|x|/2 + C. See how to split at zero, why the answer is not |x²/2|, and how to evaluate definite integrals like |x - 1| from 0 to 4.
Powers, roots and rational functions Updated 3 min read
At a glance
- Antiderivative
- \dfrac{x\lvert x\rvert}{2} + C
- For x ≥ 0
- \dfrac{x^2}{2} + C
- For x < 0
- -\dfrac{x^2}{2} + C
- Symmetric interval
- \int_{-a}^{a}\lvert x\rvert\,dx = a^2
- Check
- \dfrac{d}{dx}\dfrac{x\lvert x\rvert}{2} = \lvert x\rvert
On this page
The integral of \lvert x\rvert is \dfrac{x\lvert x\rvert}{2} + C. Because \lvert x\rvert is defined in two pieces, the cleanest way to find its integral is to integrate each piece and then glue them together.
Graph of |x| and its antiderivative
The antiderivative always increases, since \lvert x\rvert \ge 0. It has a flat point at the origin, where \lvert x\rvert = 0, and it is smooth there even though \lvert x\rvert has a corner.
Derivation, piece by piece
- Split the function: \lvert x\rvert = x for x \ge 0 and \lvert x\rvert = -x for x < 0.
- Integrate each piece with the integral of x: \frac{x^2}{2} on the right, -\frac{x^2}{2} on the left.
- Make them meet at x = 0. Both pieces equal 0 there, so no extra constant is needed.
- Write both pieces as one formula. Since x\lvert x\rvert = x^2 for x \ge 0 and x\lvert x\rvert = -x^2 for x < 0, the antiderivative is \frac{x\lvert x\rvert}{2}.
- Add C.
You can also write the answer as \frac{x^2}{2}\operatorname{sgn}(x) + C, where \operatorname{sgn}(x) is the sign of x.
Check by differentiating
For x > 0: \frac{d}{dx}\frac{x^2}{2} = x = \lvert x\rvert. For x < 0: \frac{d}{dx}\left(-\frac{x^2}{2}\right) = -x = \lvert x\rvert. At x = 0 both one-sided slopes are 0, so the derivative is 0 = \lvert 0\rvert. The check passes everywhere. Compare with the derivative of |x|, which does not exist at 0.
Definite integrals: split at the sign change
For a definite integral you rarely need the antiderivative formula. Split the interval where the inside of the bars is zero, then use definite integral properties.
Example 1. \int_{-2}^{3}\lvert x\rvert\,dx = \int_{-2}^{0}(-x)\,dx + \int_{0}^{3}x\,dx = 2 + \frac{9}{2} = \frac{13}{2}.
Example 2. \int_{-a}^{a}\lvert x\rvert\,dx = a^2 for any a > 0. The function is even, so it is twice \int_0^a x\,dx = \frac{a^2}{2}.
Example 3: shifted inside. For \int_0^4\lvert x - 1\rvert\,dx, the inside is zero at x = 1:
Example 4: total distance. If velocity is v(t) = t - 2 on [0, 5], the displacement is \int_0^5 (t - 2)\,dt = \frac{5}{2}, but the total distance is \int_0^5\lvert t - 2\rvert\,dt = 2 + \frac{9}{2} = \frac{13}{2}. This is the most common reason to integrate an absolute value.
Substitution variant
For a linear inside, \int\lvert ax + b\rvert\,dx = \frac{(ax + b)\lvert ax + b\rvert}{2a} + C. For instance, \int\lvert 2x - 3\rvert\,dx = \frac{(2x - 3)\lvert 2x - 3\rvert}{4} + C.
Common mistakes
- Answering \frac{x^2}{2} + C. That is only correct for x \ge 0.
- Answering \left\lvert\frac{x^2}{2}\right\rvert + C. Its derivative is x, which is negative for x < 0.
- Getting 0 for \int_{-a}^{a}\lvert x\rvert\,dx. \lvert x\rvert is even, not odd. Nothing cancels.
- Splitting at the wrong point. For \lvert x - 1\rvert, split at x = 1, not at x = 0.
Practise this kind of split on the definite integral problems.
Practice it now
Evaluating definite integrals
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