# 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.

Source: https://practicecalculus.com/integrals/absolute-value-of-x
Updated: 2026-11-06

$$ \int \lvert x\rvert\,dx = \frac{x\lvert x\rvert}{2} + C $$

## 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$

## Key takeaways

- The integral of $\lvert x\rvert$ is $\frac{x\lvert x\rvert}{2} + C$.
- For definite integrals, split the interval where the inside of the absolute value changes sign.
- $\int_{-a}^{a}\lvert x\rvert\,dx = a^2$, two triangles each of area $\frac{a^2}{2}$.
- $\frac{x^2}{2} + C$ is only right for $x \ge 0$. For $x < 0$ you need $-\frac{x^2}{2}$.

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.

$$\int \lvert x\rvert\,dx = \frac{x\lvert x\rvert}{2} + C$$

## Graph of |x| and its antiderivative

```graph
title: 'Area under y = |x| from -1 to 2, with the antiderivative y = x|x|/2'
caption: 'The shaded region is two triangles with areas $\frac{1}{2}$ and $2$, for a total of $\frac{5}{2}$. The dashed antiderivative is $-\frac{x^2}{2}$ on the left and $\frac{x^2}{2}$ on the right.'
x: [-2.5, 2.5]
y: [-2.5, 3]
functions:
  - expr: abs(x)
    label: y = |x|
  - expr: x*abs(x)/2
    label: y = x|x|/2 (antiderivative)
    dashed: true
shade: {expr: abs(x), from: -1, to: 2}
points:
  - [0, 0, '(0, 0)']
```

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

1. Split the function: $\lvert x\rvert = x$ for $x \ge 0$ and $\lvert x\rvert = -x$ for $x < 0$.
2. Integrate each piece with the [integral of x](/integrals/x): $\frac{x^2}{2}$ on the right, $-\frac{x^2}{2}$ on the left.
3. Make them meet at $x = 0$. Both pieces equal $0$ there, so no extra constant is needed.
4. 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}$.
5. 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|](/derivatives/absolute-value-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](/rules/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$:

$$\int_0^1 (1 - x)\,dx + \int_1^4 (x - 1)\,dx = \frac{1}{2} + \frac{9}{2} = 5$$

**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

1. **Answering $\frac{x^2}{2} + C$.** That is only correct for $x \ge 0$.
2. **Answering $\left\lvert\frac{x^2}{2}\right\rvert + C$.** Its derivative is $x$, which is negative for $x < 0$.
3. **Getting $0$ for $\int_{-a}^{a}\lvert x\rvert\,dx$.** $\lvert x\rvert$ is even, not odd. Nothing cancels.
4. **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-problems/definite-integrals).

## Frequently asked questions

### What is the integral of |x|?

It is $\frac{x\lvert x\rvert}{2} + C$. That equals $\frac{x^2}{2}$ for $x \ge 0$ and $-\frac{x^2}{2}$ for $x < 0$.

### What is the integral of |x| from -1 to 1?

It is $1$. The graph forms two triangles, each with area $\frac{1}{2}$.

### Why is the integral of |x| not |x²/2|?

$\left\lvert\frac{x^2}{2}\right\rvert = \frac{x^2}{2}$, whose derivative is $x$. For negative $x$ that is negative, but $\lvert x\rvert$ is positive. You need the sign change that $x\lvert x\rvert$ provides.

### Is |x| integrable even though it has a corner?

Yes. $\lvert x\rvert$ is continuous, and every continuous function on a closed interval is integrable. The corner only stops it from being differentiable at $0$.
