Calculating $\int_{-1}^1 (2-|x|)dx$ 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?
 A: You've evaluated at the bounds incorrectly: Since you have $2x + x^2/2$, the second term should be $(-2 + \frac 1 2)$, which gives the correct answer.
A: Since $2-|x|$ is even function, we can obtain:
$$\int_{-1}^1 (2-\left |x \right |)dx=2\int_0^1(2-|x|)dx=2\int_0^1(2-x)dx$$
A: $$\int_{-1}^1 (2-\left |x \right |)dx = \int_{-1}^0 (2-|x| )dx+ \int_{0}^1 (2-\left |x \right |)dx =\int_{-1}^0 (2+x  )dx +\int_{0}^1 (2-x )dx$$
Hope this helps
A: It will be
$$(2x+(1/2)x^2)\bigg|_{-1}^{0}+(2x-(1/2)x^2)\bigg|_{0}^{1}=0-(-2+(1/2))+(2-(1/2))=4-1=3.$$
A: You missed out a minus sign for the second $2$ in your equation. :)
An alternative is to split the integrals so that you can see from an easier light.
$$\int_{-1}^{1}(2-|x|)\ dx=\int_{-1}^{1}2\ dx-\int_{-1}^{1}|x|\ dx=2*(1+(-1))-\int_{-1}^{1}|x|\ dx$$
It all boils down to evaluating $$\int_{-1}^{1}|x|\ dx$$
Notice from the graph of $y=|x|$ that the area under the curve from $-1$ to $1$ is just simply the sum of two triangles with base and height $1$, which gives us a total area of $1$.
So  $$\int_{-1}^{1}(2-|x|)\ dx=4-1=3$$
