I try to calculate the following integral but am a bit confused with the |x|
$$\int_{-1}^1 (2-\left |x \right |)dx$$
The antiderivative should be:
$\begin{cases} 2x-\frac{x^2}{2} & x \geq 0 \\ 2x + \frac{x^2}{2} & x \lt 0 \end{cases}$
Is that correct? So it would mean:
$\left ( 2-\frac{1}{2}\right ) - \left ( 2+\frac{1}{2}\right ) = 1.5 - 2.5 = -1$
But that is not correct. It is supposed to be 3. Where did I do the mistake?