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}}$$
 A: Alternatively
$$I(n)= \int\limits_{0}^{2\pi}\frac{dx}{\left ( 1+n^2\sin^2 x \right )^2}=\frac4{n^4}\int_{0}^{\pi /2}\frac{dx}{\left ( a-\cos^2 x \right )^2},\>\>\>\>\>a= 1+\frac1{n^2}$$
Note that
$$J(a)= \int_{0}^{\pi/2}\frac{dx}{ a- \cos^2 x }
= \int_{0}^{\pi/2}\frac{d(\tan x)}{ a\tan^2x  +(a-1)}dx= \frac\pi{2\sqrt{a(a-1)}}
$$
Then
$$I(n)= -\frac4{n^4} \frac{dJ(a)}{da}\bigg|_{a= 1+\frac1{n^4}}=\frac{\pi(2+n^2)}{ (1+n^2)^{3/2}}
$$
A: Just for the fun !
When there is a square in denominator, we never know ! Trying
$$\int\frac{dx}{\left ( 1+n^2\sin^2 (x) \right )^2}=\frac{P(x)}{ 1+n^2\sin^2 (x)} $$ Differentiate both sides and remove the denominators
$$(1+n^2 \sin ^2(x))P'(x)-n^2 \sin(2x) P(x)=1$$ which is not very difficult to integrate. So, by the end
$$\frac{P(x)}{ 1+n^2\sin^2 (x)}=\frac{n^2+2 }{2
   \left(n^2+1\right)^{3/2}}\tan ^{-1}\left(\sqrt{n^2+1} \tan (x)\right)-\frac{n^2 \sin (2 x)}{2 \left(n^2+1\right) \left(n^2 \cos (2 x)-n^2-2\right)} + C $$ Integrating between $0$ and $\frac \pi 2$ and multiplying by $4$, the result
$$\int\limits_{0}^{2\pi}\frac{dx}{\left ( 1+n^2\sin^2 (x) \right )^2}=\frac{ \left(n^2+2\right)}{\left(n^2+1\right)^{3/2}}\, \pi$$
A: 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}$$
