Double Integral $\int\limits_0^\pi \int\limits_0^\pi|\cos(x+y)|\,dx\,dy$ First off, I apologize for any English mistakes.I've come across a double integral problem that I haven't been able to solve: Find 
$$\int_0^\pi \int_0^\pi|\cos(x+y)|\,dx\,dy$$
Intuitively, I thought it could be solved in a similar manner to what you would do for a regular integral with and absolute value. For example, to solve $\int_0^\pi |\cos(x)| \,dx$, you just take the interval where $\cos(x)$ is positive and multiply it by two:
$$\int_0^\pi |\cos(x)|\,dx = 2\int_0^{\frac{\pi}{2}} \cos(x) \, dx$$
So I naively assumed my initial problem could be solved in a similar manner, that is:
$$\int_0^\pi \int_0^\pi |\cos(x+y)| \,dx\,dy = 4\int_0^{\frac{\pi}{4}}\int_0^{\frac{\pi}{4}}\cos(x+y) \,dx\,dy$$
However, this does not give me the right answer. I'm not really sure how this integral is actually solved.
Thanks a lot for your help!
 A: For the single integral case, "take the interval where $\cos x$ is positive and multiply it by two" is rather misleading: what you are actually doing is splitting the region of integration into a part where $\cos x$ is positive and a part where $\cos x$ is negative, working out both and adding them.  The two integrals are the same in this case, so you can just multiply by $2$.
You can do the same for the double integral, but there is no guarantee that you will be adding equal integrals.  You will need to subdivide the square of integration into bits where $\cos(x+y)$ has a single sign.  So you will need to take
$$0\le x+y\le\frac\pi2\quad\hbox{and}\quad
  \frac\pi2\le x+y\le\frac{3\pi}2\quad\hbox{and}\quad
  \frac{3\pi}2\le x+y\le2\pi\ .$$
Good luck!
A: 
We have $\int_{x=0}^{\pi/2}\int_{y=0}^{\pi/2-x}\cos(x+y)\ dy\ dx-\int_{x=0}^{\pi/2}\int_{y=\pi/2-x}^{\pi}\cos(x+y)\ dy\ dx-\int_{x=\pi/2}^{\pi}\int_{y=0}^{3\pi/2-x}\cos(x+y_\ dy\ dx+\int_{x=\pi/2}^{\pi}\int_{y=3\pi/2-x}^{\pi}\cos(x+y)\ dy\ dx$.
The first term is $\int_0^{\pi/2}(1-\sin x)\ dx=\pi/2-1$. The second term is $-\int_0^{\pi/2}(-1-\sin x)\ dx=\pi/2+1$. The third term is $-\int_{\pi/2}^{\pi}(-1-\sin x)\ dx=\pi/2+1$, and the last term is $\int_{\pi/2}^{\pi}(1-\sin x)\ dx=\pi/2-1$. Adding, we get $2\pi$ for the original integral.
A: A handful of hints to get you started, each for different directions. 
Most require you to just use some alternative definition of $\cos(x)$, as mentioned in the comments...


*

*Use the piecewise definition of $\left|\cos(x+y)\right|$, and add together the separate integrands

*Note that if $x,y\in\Bbb R$, then $\left|\cos(x+y)\right|=\sqrt{\cos^2(x+y)}$

*$\cos(x+y)=\cos(x) \cos(y)-\sin(x) \sin(y)$

*You could always use the definition $\cos(x+y)=\frac 12 e^{-i x-i y}+\frac 12 e^{i x+i y} $, but that can end up being much more difficult.


Start with the first suggestion, though. Try to redefine the function as a piecewise one. Here's a basic example of how a simple integral of an absolute value works from Paul's Online Notes (example 5):
$$\int_0^3\left|3t-5\right|\mathrm{d}t=\int_0^{\frac 5 3} 5-3t\,\mathrm{d}t+\int_{\frac 5 3}^3 3t-5\,\mathrm{d}t$$
