# How does one calculate the integral of the sum of two absolute values?

I know how to find the integral of just one absolute value, but this problem presents the integral of the sum of two absolute values. Help!

I want to evaluate:

$$\int_a^b{(|x-1| + |x+1|) dx}$$

-
Do you know how to integrate the sum of two functions? –  Erick Wong Feb 26 '13 at 2:35
use additivity of integrals and see where the two functions change signs. –  Mathematician Feb 26 '13 at 2:37

You need to separate the integral into cases like $x\in[a, -1], x\in(-1,1), x\in[1,b]$, assuming $a<-1<1<b$. Then, for each case, you can get rid of the absolute value and calculate the integral as usual.

It will be clear if you try to draw the graph of the function.

-

Absolute value represents a piecewise function.

$$|x| = \left\{ \begin{array}{lcr} x & : & x \geq 0 \\ -x & : & x < 0\end{array}\right.$$

As with integrating any piecewise function, break the interval of integration up into the separate regions for which you have something easier to handle and integrate each part separately.

In this case, suppose $a = -3$ and $b = 4$. Then

$$\int_{-3}^{4} |x-1| + |x+1| dx = \int_{-3}^{-1} -(x-1) -(x+1) dx + \int_{-1}^{1} -(x-1) + (x+1) dx + \int_{1}^{4} (x-1) + (x+1) dx$$

-

Note that $f(x) = |x-1| + |x+1|$ can be broken down into multiple cases:

$$f(x) = \begin{cases}(x-1)+(x+1)& \text{if }x\ge1 \\ -(x-1)+(x+1) & \text{if } -1\le x\le1 \\ -(x-1)+-(x+1) & \text{if } x\le-1 \end{cases}$$

Simplifying: $$f(x) = \begin{cases} 2x& \text{if }x\ge1 \\ 2 & \text{if } -1\le x\le1 \\ -2x & \text{if } x\le-1 \end{cases}$$

This is easily visualized with a graph (see Wolfram|Alpha).

So, to integrate, break up the interval $[a, b]$ with $-1$ and $1$.

An example will probably help: \begin{align} \int_{-3}^3|x-1|+|x+1|\;dx &= \int_{-3}^{-1}-2x\;dx+\int_{-1}^{1}2\;dx+\int_1^32x\;dx\\ &=-x^2\bigg|^{-1}_{-3} + 2x\bigg|_{-1}^1+x^2\bigg|_1^3\\ &=8+4+8\\ &=20 \end{align}