Double integral with variable change, why the $2\pi$? I've seen a lot of examples from my textbook where the result of an integration is $2\pi$ instead of $0$, as I would expect it to be. And several of my results will match the correct result if I multiply my answer with $2\pi$, hence, it's something I've missed...
This example from my textbook demonstrates it:
Decide
$$
I = \int\int_D(x^2+y^2)\,dx\,dy
$$
where
$D = \{ (x,y) ; x^2 + y^2 + 2x \le 0 \}$
Answer:
Rewrite as
$$
x^2+y^2 + 2x = (x+1)^2 + y^2 - 1
$$
where a suitable change of variables is:
\begin{cases}
x = & -1 + r\cos(\gamma) \\
y = & r\sin(\gamma),
\end{cases}
\begin{cases}
0 \le r \le 1\\
0 \le \gamma \le 2\pi
\end{cases}
where the functional determinant will be $r$,
solving it by replacing the variables, gives:
$$
\int_0^1 \left(\int_0^{2\pi}((-1+r\cos(\gamma))^2 + r^2\sin^2(\gamma))r\, d\gamma\right)\,dr =
$$
$$
\int_0^1 \left(\int_0^{2\pi} r(1+r^2-2r\cos(\gamma))\,d\gamma\right)\,dr
$$
this I get.. But the book then rewrites this to:
$$
2\pi\int_0^1r(1 + r^2)\,dr = 3\pi/2
$$
but, how does:
$$
- \int_0^{2\pi}2r\cos(\gamma) \,d\gamma
$$
become $2\pi$? I would evaluate the above to zero, since $\int \cos = \sin$ and both $\sin(0)$ and $\sin(2\pi)$ is $0$.
 A: You are correct in your evaluation of that integral. But:
\begin{align}
    \int_0^1\left(\int_0^{2\pi} r(1+r^2-2r\cos\gamma\,d\gamma\right)dr
        &= \int_0^1 \left(\int_0^{2\pi} r(1+r^2)\,d\gamma + \int_0^{2\pi} (-2r^2(1+r^2))\cos\gamma\,d\gamma\right)dr \\
        &= \int_0^1 \left(\int_0^{2\pi} r(1+r^2)\,d\gamma\right)dr.
\end{align}
Now the inner integral does not depend on $\gamma$, so we get for its value simply $2\pi r(1+r^2)$.
A: You have two terms when integrating over $\theta$. One is $\int_0^{2\pi}\cos\theta\,d\theta$ (which indeed vanishes). The other is $\int_{0}^{2\pi} 1\, d\theta=\ldots$?
A: I think you are correct in evaluating that integral to be zero, but you might have confused another bit:
$$
\int_0^1 \int_0^{2 \pi} r(1+r^2 - 2r \cos(\gamma) )d \gamma dr = \int_0^1 \int_0^{2 \pi} r(1+r^2) d \gamma dr \ \ -\int_0^1 \int_0^{2 \pi} 2r^2 \cos(\gamma) )d \gamma dr \\  $$
The second integral goes to zero, and then the first integral is multiplied by $ 2 \pi $ when we integrate out $ \gamma $.
does that help?
A: $$
\int_0^{2\pi} \underbrace{r(1+r^2)}_{\text{No $\gamma$ appears here!}}\,d\gamma
$$
In this integral, the function being integrated does not depend on the variable with respect to which you are integrating.  In other words, it's a constant.  The integral of a constant function is the area of a rectangle, which is base times height.  The base is $2\pi-0$ and the height is the constant value $r(1+r^2)$.  So the integral is $2\pi r(1+r^2)$.
