# Double integration from polars to Cartesians

I have the following integral over the unit circle $$\int_0^{2\pi}d\varphi\int_0^1 rdr \ \varphi =\pi^2$$ where $$\varphi$$ is the azimuthal angle and $$r$$ is the radial distance. If I try to convert this into Cartesian coordinates, I get $$\int_{-1}^1dx\int_{-\sqrt{1-x^2}}^{\sqrt{1-x^2}}dy \arctan{\frac{y}{x}}=0$$

what am I doing wrong in the conversion from polars to Cartesians? Thanks.

## 2 Answers

You can try using this formula for $$\varphi$$ on quadrants (excluding the $$x$$-axis):

$$\varphi(x,y) =\begin{cases} \arctan\frac{y}x, &\text{ if (x,y) is in the first quadrant}\\ \arctan\frac{y}x+\pi, &\text{ if (x,y) is in the second or third quadrant}\\ \arctan\frac{y}x+2\pi, &\text{ if (x,y) is in the fourth quadrant}\end{cases}$$

so your integral is $$\int_0^1 \int_0^{\sqrt{1-x^2}} \arctan\frac{y}x\,dydx + \int_{-1}^0 \int_{-\sqrt{1-x^2}}^{\sqrt{1-x^2}} \left(\arctan\frac{y}x + \pi\right)\,dydx + \int_0^1 \int_{-\sqrt{1-x^2}}^{1} \left(\arctan\frac{y}x+2\pi\right)\,dydx$$ which is equal to $$\frac{\pi^2}{16} + \frac{\pi^2}2+ \frac{7\pi^2}{16}= \pi^2$$.

• Thank you. My problem actually arose while coding on Python. I was using the function arctan2, which I was told takes into account the quadrant, and the integral gave 0. Then I checked the actual array produced by the arctan2 function and for some reason it messes up the third and fourth quadrants so I had to correct for those. Cheers. – martin Jul 18 at 11:36
• @martin I believe you should use the atan2 function in Python for this. – mechanodroid Jul 18 at 12:45

The formula $$\phi=\arctan(y/x)$$ is not true in the whole integration range $$0 \le \phi < 2\pi$$.

(Which you can see, for example, from the fact that the arctan function always returns a value less than $$\pi/2$$.)