Problem with multiple integrals of $\cos(x+y)$ I have a problem with this integral
$\int_{0}^{\pi}\int_{0}^{\pi}\mid \cos\left(x+y\right)\mid dxdy$
I work with this problem, but the result of the book does not match with my result
Note: The book is Calculus. Tom Apostol
$\begin{cases}
\int_{0}^{\pi}\int_{0}^{\pi}\cos\left(x+y\right)\,dx\,dy\\
\int_{0}^{\pi}\int_{0}^{\pi}-\cos(x+y)
\end{cases}
 $
$\int\int \cos(x+y)\,dx\,dy$
$\int_{0}^{\pi}\left(\int_0^\pi\cos\left(x\right)\cos\left(y\right)-\sin\left(x\right)\sin\left(y\right)\,dx\right)\,dy
 $
$\int_{0}^{\pi}\left(\cos\left(y\right)\int_{0}^{\pi}\cos\left(x\right)dx-\sin\left(y\right)\int_{0}^{\pi}\sin\left(x\right)\,dx\right)\,dy$
$\int_{0}^{\pi}\left(\left.(\cos\left(y\right)\sin\left(x\right)+\sin\left(y\right)\cos\left(x\right))\right|_{~0}^{~\pi}\right)\,dy$
$\int_{0}^{\pi}\left(\sin\left(y\right)-\sin\left(y\right)\right)\,dy$
$= 0$
$\int_{0}^{\pi}\int_{0}^{\pi}-\cos\left(x+y\right)\,dx\,dy=-\int_{0}^{\pi}\int_{0}^{\pi}\cos\left(x+y\right)\,dx\,dy=0$
 A: $$\int_0^\pi \int_0^\pi |\cos(x+y)| dx dy$$
$$=\int_0^{\pi\over2} \int_0^\pi |\cos(x+y)| dx dy+\int_{\pi\over2}^\pi \int_0^\pi |\cos(x+y)| dx dy$$
$$
=\int_0^{\pi\over2}
    \int_0^{\frac\pi 2-y} |\cos(x+y)| dx
    +\int_{\frac\pi 2-y}^\pi |\cos(x+y)| dx
dy$$$$
+\int_{\pi\over2}^\pi
    \int_0^{\frac{3\pi}2-y} |\cos(x+y)| dx
    +\int_{\frac{3\pi}2-y}^\pi |\cos(x+y)| dx
dy
$$
$$
=\int_0^{\pi\over2}
    \int_0^{\frac\pi 2-y} +\cos(x+y) dx
    +\int_{\frac\pi 2-y}^\pi -\cos(x+y) dx
dy$$$$
+\int_{\pi\over2}^\pi
    \int_0^{\frac{3\pi}2-y} -\cos(x+y) dx
    +\int_{\frac{3\pi}2-y}^\pi +\cos(x+y) dx
dy
$$
I split like that to ensure:


*

*The function has only one sign on one interval $\Rightarrow$ eliminate absolute value sign (you can only eliminate the absolute value sign this way!)

*Make sure that lower bound $\leq$ upper bound


Edit: I am not change integration limit, since $\int_a^b f(x)dx + \int_b^c f(x)dx = \int_a^c f(x) dx$ for $a\leq b \leq c$.
Edit2: If you change like this, for example, in
$$\int_0^{\pi\over2}
    \int_0^{\frac\pi 2-y} |\cos(x+y)| dx
dy$$
It is obvious that $x+y\geq 0$ and $x \leq \frac \pi 2 - y \iff x + y \leq \frac \pi 2$, so in this limit, $\cos (x+y) \geq 0 \Rightarrow |\cos (x+y)| = +\cos (x+y)$.
