# What is the integral of |x|?

Let's take $a < 0$ and $b > 0$, then ${\int}_{a}^{b} | x | \mathrm{dx} = {\int}_{a}^{0} - x \mathrm{dx} + {\int}_{0}^{b} x \mathrm{dx} = {\int}_{0}^{-} a x \mathrm{dx} + {\int}_{0}^{b} x \mathrm{dx} = {\left[\frac{1}{2} {x}^{2}\right]}_{0}^{-} a + {\left[\frac{1}{2} {x}^{2}\right]}_{0}^{b} = \frac{1}{2} {\left(- a\right)}^{2} + \frac{1}{2} {b}^{2} = \frac{1}{2} {a}^{2} + \frac{1}{2} {b}^{2}$