I've been learning about polar coordinates recently and had a question about the following example problem:
$$\int_{x=0}^{x=1}\int_{y=0}^{y=a}\frac{1}{(1+x^2+y^2)^2}dydx$$
where a is an arbitrary positive constant. I'm required to solve the above problem using polar coordinates. According to the example, the correct answer is supposed to be:
$$\frac{\sqrt2}{4}\arctan\frac{a\sqrt2}{2}+\frac{a}{2\sqrt{a^2+1}}\arctan\frac{1}{\sqrt{a^2+1}}$$
I'm lost as to how the above answer is derived. I tried splitting up the given rectangular region of $0 \leq x \leq 1$ and $0 \leq y \leq a$ and the integrand as follows, in terms of polar coordinates:
$$\int_{\theta=0}^{\theta=\arctan a}\int_{r=0}^{r=\sec \theta}\frac{r}{(1+r^2)^2}drd\theta+\int_{\theta=\arctan a}^{\theta=\pi/2}\int_{r=0}^{r=a\csc \theta}\frac{r}{(1+r^2)^2}drd\theta$$
but the evaluation of the second term above seems to diverge to infinity?
I'd appreciate any help on this. Thanks.