Compute $\int_{a}^{b}\left|x\right|\mathrm{d}x$ The reason I ask this is because $$\int_{x=a}^{x=b}\left|x\right|\mathrm{d}x$$  gives exactly the same result as $$\int_{x=a}^{x=b}x\mathrm{d}x=\frac{b^2}{2}-\frac{a^2}{2}=\int_{x=a}^{x=b}\left|x\right|\mathrm{d}x$$ when $0 \leq a \leq b$
But for a non trivial case could someone please show the steps of integration of $$\int_{x=a}^{x=b}\left|x\right|\mathrm{d}x$$ for $-7\le a\le 8$ and $0\le b\le 12$.
Thank you.

Note that $|x| = \frac{d}{dx}\frac{x^2 (\text{sgn}\ x)}{2}$. Here, $\text{sgn}:\Bbb R → \Bbb R$ is the sign function, 
$$ \text{sgn}\ (x) = \begin{cases} +1 & x>0 \\ 0 & x=0 \\ -1 & x<0 \end{cases} $$
Thus we see that 
$$ ∫_a^b |x| \ dx = \frac{b^2 (\text{sgn}\ b) - a^2 (\text{sgn}\ a)}{2}$$
This formula works for all $a,b\in\Bbb R$. For example, if $a,b>0$ it does indeed reduce to $\frac{a^2 - b^2}{2}$. We also obtain if $0<a=-b$, $\int_a^b |x| \ dx = \frac{a^2 + b^2}{2}$. These are the special cases given by the other answers. 
