# integral from 0 to $2\pi$ of $|\cos x|\operatorname{d}x$ not integrating as I'd expect

I drew a rough sketch of $|\cos x|$ and would guess the correct answer to this integral is $4$ because I know the area under the curve of $\cos x$ from $0$ to $\pi/2$ is $1$, and there are $4$ such areas under $|\cos x|$ between $0$ and $2\pi$.

So if I rewrite the integral as ($4$ $\times$ integral from $0$ to $\pi/2$ $|\cos x|\operatorname{d}x$) I get the answer I expect. What I don't understand is why this evaluates correctly when the original form does not. Does it have something to do with the antiderivative of an absolute trig function? I've been saying it's $|\sin x|$ in this case - is this actually incorrect?

What is it that I need to look out for in cases like this?

-
As you seem to have guessed, your antiderivative is wrong. A way of seeing this is to observe that $|\sin x|$ is often decreasing - for example, when $\sin x$ is decreasing and positive. In such intervals its derivative is negative, so cannot be equal to $|\cos x|$. – Jyrki Lahtonen Aug 9 '11 at 5:52
I don't understand what you mean by "the original form does not." What's the original form, and why do you think it doesn't agree with the correct answer? And no, $|\sin x|$ is definitely not a primitive (antiderivative) of $|\cos x|$ - the graph of $|\sin x|$ has parts where it is decreasing and therefore has negative derivative during some intervals, whereas $|\cos x|$ is never negative. – anon Aug 9 '11 at 5:54
You might as an exercise try to come up with an expression for an antiderivative of $|\cos x|$. Doable. But $|\sin x|$ is not it. Your first approach was good: In principle handle $\cos x \ge 0$ and $\cos x \lt 0$ separately, but be on the lookout for symmetry. – André Nicolas Aug 9 '11 at 6:05

Yes, it is incorrect to try to take $|\sin x|$ as an antiderivative. For example, notice that $|\sin(x)|$ is decreasing on $(\pi/2,\pi)$, so its derivative there is negative, while $|\cos(x)|$ is never negative. Your guess is correct about the value being 4 times the integral from $0$ to $\pi/2$.
One way to evaluate it is by writing the integral as $$\int_0^{\pi/2}|\cos x|dx +\int_{\pi/2}^{3\pi/2}|\cos x|dx +\int_{3\pi/2}^{2\pi}|\cos x|dx,$$ the intervals having been chosen where $\cos$ has constant sign. In each integral, the absolute value signs can be removed, and a minus sign should be added where appropriate.