How to reverse the integration order of the double integral $\int_{\theta=0}^{2\pi}\int_{r=0}^{1+\cos\theta}r^2(\sin\theta+\cos\theta)drd\theta$. I am given the integral $$ \iint\limits_H \, (x+y) \mathrm{d} A $$
where $H$ is the area of the cardioid $r=cos(\theta)+1$.
I have translated the double integral to polar coordinates in order to solve it, where $\mathrm{d} A$ equals $r\mathrm{d}r\mathrm{d}\theta$, $x=r\cos\theta$ and $y=r \sin\theta$:
$$\int_{\theta=0}^{2\pi}\int_{r=0}^{1+\cos\theta}r^2(\sin\theta+\cos\theta)\mathrm{d}r\mathrm{d}\theta$$ which equals:
$$ \frac{1}{3} \int_{\theta=0}^{2\pi} (\sin\theta + \cos\theta + 3 \sin\theta \cos\theta + 3\cos^2 \theta + 3\sin\theta \cos^2\theta \\+3 \cos^3\theta + \sin\theta \cos^3\theta + \cos^4\theta )\mathrm{d} \theta. $$
After some calculations, this integral is equal to the solution which is $\frac{5\pi}{4}$. 
My question is now how to solve the double integral $$\int_{\theta=0}^{2\pi}\int_{r=0}^{1+\cos\theta}r^2(\sin\theta+\cos\theta)\mathrm{d}r\mathrm{d}\theta$$ in the form of $$\int_{r=?}^{?}\int_{
\theta=?}^{?}(r^2\sin\theta+r^2\cos\theta )\mathrm{d}\theta \mathrm{d}r.$$ So in essence, how to reverse the order of integration of this double integral. Thank you in advance for any help.
 A: Note that for $0\le \theta \le \pi$, the relationship $r=1+\cos(\theta)$ implies the inverse relationship $\theta=\arccos(r-1)$.  
And for $\pi\le\theta\le2\pi$, $r=1+\cos(\theta)$ implies the relationship $\theta = 2\pi -\arccos(r-1)$.
Therefore, we can write 
$$\begin{align}
\int_0^{2\pi}\int_0^{1+\cos (\theta)}r^2(\sin(\theta)+\cos(\theta))\,dr\,d\theta&=\int_0^2\int_0^{\arccos(r-1)} r^2(\sin(\theta)+\cos(\theta))\,d\theta\,dr\\\\
&+\int_0^2\int_{2\pi-\arccos(r-1)}^{2\pi}r^2(\sin(\theta)+\cos(\theta))\,d\theta\,dr\\\\
&=2\int_0^2\int_0^{\arccos(r-1)} r^2\cos(\theta)\,d\theta\,dr\\\\
&=2\int_0^2r^2\sqrt{r(2-r)}\,dr\\\\
&=\frac{5\pi}{4}
\end{align}$$
which agrees with the result obtained in the OP.
A: What I like to do is to make the limits generic. Note that $1+cos\theta \in [0,2]$. Write $1(\cdot)$ for the indicator function. So, informally, write
$$ \int_{\theta=0}^{2\pi} \int_{r=0}^{1+\cos\theta}
= \int_{\theta=0}^{2\pi} \int_{r=0}^2 1(r \le 1+\cos\theta).$$
You can now swap the integrals without any concern about the limits*. Now, we know that $r \le 1+\cos\theta \iff \cos\theta \ge r-1$ so this becomes
$$ \int_{\theta=0}^{2\pi} \int_{r=0}^{1+\cos\theta}
= \int_{r=0}^2 \int_{\theta=0}^{2\pi} 1(\cos\theta \ge r-1)
= \int_{r=0}^2 \int_{\theta \in \Theta}$$
where $\Theta$ is the range of $\theta$ for which $\cos\theta \ge r-1$, where $r \in [0,2]$, which I'll leave for you to calculate. This will then give you the result.
*Note that sometimes you can't actually swap the order of integration, but this is a different question to what you're saying.
