# Evaluate ʃ(superscript π)(subscript 0) abs(cosx) dx. If x>0, then |x|=x

If x<0, then |x|= -x

In general, the way to deal with an absolute value in the integral is to split the interval of integration into the places where the integrand would be positive vs negative, if the absolute value weren't there.

So, we look at where cos(x) is positive and negative.

Just looking between 0 and `pi` , we have that, in the interval `(0,pi/2)`  , cos(x) is positive, and in `(pi/2, pi)` , cos(x) is negative.

Thus, we can write:

`int_0^pi | "cos" (x) | dx = `

`int_0^(pi/2) |"cos"(x)|dx + int_(pi/2)^pi |"cos"(x)|dx =`

`int_0^(pi/2) "cos" (x) dx + int_(pi/2)^pi -"cos" (x) dx`

And now that the || is gone, we can just integrate:

`"sin" x | _0^(pi/2) " - " "sin" x |_(pi/2)^pi =`

(1-0) - (0 - 1) = 2

Note: this is a more general way of dealing with || in an integral

But with this problem, you might also notice:

cos(x) is symmetric about `pi/2`

Which means |cos(x)| looks like:

Thus, to find the area under the curve, you only need to do:

`2 int_0^(pi/2) "cos" (x) dx = 2[ "sin" x |_0^(pi/2) ] = 2(1) = 2`

Approved by eNotes Editorial Team