<s>[INST] Calculate integral $\int\limits_{0}^{2\pi}\frac{dx}{\left ( 1+n^2\sin^2 x \right )^2}$ I recently saw the integral problem
$$\int\limits_{0}^{2\pi}\frac{dx}{\left ( 1+n^2\sin^2 x \right )^2}$$
and tried to solve it. Below is what I did.
Interesting to look at other easier solutions.
$$\int\limits_{0}^{2\pi}\frac{dx}{\left ( 1+n^2\sin^2 x \right )^2}=4\int_{0}^{\pi /2}\frac{dx}{\left ( 1+n^2\sin^2 x \right )^2}\\\overset{t=\operatorname{tg} x}{=}\int\limits_{0}^{\infty }\frac{1+t^2}{\left ( 1+\left ( 1+n^2 \right )t^2 \right )^2}dt\\ 
\overset{t=\frac{y}{\sqrt{1+n^2}}}{=}\frac{4}{\left ( 1+n^2 \right )\sqrt{1+n^2}}\int\limits_{0}^{\infty }\frac{1+n^2+y^2}{\left ( 1+y^2 \right )^2}dy\\ \overset{y=\operatorname{tg} \theta }{=}\frac{4}{\left ( 1+n^2 \right )\sqrt{1+n^2}}\int_{0}^{\pi /2}\left ( 1+n^2\cos^2 \theta  \right )d\theta \\
=\frac{\pi \left ( 2+n^2 \right )}{\left ( 1+n^2 \right )\sqrt{1+n^2}}$$
 [/INST] Back to serious
At a point you wrote
$$\int \frac{1+n^2+y^2}{(1+y^2)^2}\, dy$$ Write $(1+y^2)=(y+i)(y-i)$ and use partial fraction decomposition to obtain
$$\frac{1+n^2+y^2}{(1+y^2)^2}=\frac{2+n^2}4 i\left(\frac 1{y+i} -\frac 1{y-i}\right)-\frac {n^2}4 \left(\frac 1{(y+i)^2} +\frac 1{(y-i)^2}\right)$$ and use the logarithmic representations to get
$$\int \frac{1+n^2+y^2}{(1+y^2)^2}\, dy=\frac{2+n^2}2 \tan^{-1}(y)+\frac{ n^2}{2 }\frac{y}{1+y^2}$$
</s>