How to evaluate $\int^{2\pi}_0\frac{d\theta}{b^2\cos^2\theta + a^2 \sin^2\theta}$ for $a>0$ and $b>0$ 
How to evaluate $\int^{2\pi}_{0}\frac{d\theta}{b^2\cos^2\theta+a^2\sin^2\theta}$ for $a,b>0$

I came across this integral while solving a line integral problem . but it doesn't looks easier to integrate . I tried substitution of $\tan x$ .but i'm not sure tan can be used as the tan is discontinuous at $\pi/2$ i tried other substitution but none of them work.
 A: Your method works. We have
$$\begin{align*}
\int^{2\pi}_{0}\frac{\mathrm d\theta}{b^2\cos^2\theta+a^2\sin^2\theta}&=4\int^{\frac\pi 2}_{0}\frac{\mathrm d\theta}{b^2\cos^2\theta+a^2\sin^2\theta}\\&=4\int^{\frac\pi 2}_{0}\frac{\sec^2 \theta\mathrm d\theta}{b^2+a^2\tan^2\theta}\\
&=4\int^{\infty}_{0}\frac{\mathrm du}{b^2+a^2u^2}\\&=\frac4{ab}\arctan\left(\frac{au}{b}\right)\Big|^\infty_0\\&=\frac{2\pi} {ab}.
\end{align*}$$ Here's an another approach. We have
$$\begin{align*}
\int^{2\pi}_{0}\frac{\mathrm d\theta}{b^2\cos^2\theta+a^2\sin^2\theta}&=\int^{2\pi}_{0}\frac{\mathrm d\theta}{\frac{a^2+b^2}2+\frac{b^2-a^2}2\cos(2\theta)}\\&=\int^{2\pi}_{0}\frac{\mathrm d\theta}{\frac{a^2+b^2}2+\frac{b^2-a^2}2\cos\theta}\\
&=\frac{2\pi}{\sqrt{\left(\frac{a^2+b^2}2\right)^2-\left(\frac{b^2-a^2}2\right)^2}}\\
&=\frac{2 \pi}{ab}.
\end{align*}$$ Here, $$
\int^{2\pi}_{0}\frac{\mathrm d\theta}{\alpha+\beta\cos\theta}=\frac{2\pi}{\sqrt{\alpha^2-\beta^2}}, \quad \alpha>|\beta|\tag{*}
$$ is used. (See, for example, this earlier post. The first approach can be seen as a way of showing the integral $(*)$.)
A: A different approach:
$$J=\int_0^{2\pi}\frac{\mathrm dx}{a^2\sin(x)^2+b^2\cos(x)^2}=2\int_0^{\pi}\frac{\mathrm dx}{a^2\sin(x)^2+b^2\cos(x)^2}$$
Using $t=\tan\frac{x}2$, we have
$$J=2\int_0^{\infty}\frac{1}{a^2\left[\frac{2t}{1+t^2}\right]^2+b^2\left[\frac{1-t^2}{1+t^2}\right]^2}\frac{2\mathrm dt}{1+t^2}$$
$$J=4\int_0^{\infty}\frac{1+t^2}{4a^2t^2+b^2\left[t^2-1\right]^2}\mathrm dt$$
$$J=\frac{4}{b^2}\int_0^{\infty}\frac{1+t^2}{t^4+2gt^2+1}\mathrm dt$$
Where $g=\frac{2a^2-b^2}{b^2}$. We next split this integral up into two:
$$J=\frac{4}{b^2}\int_0^{\infty}\frac{\mathrm dt}{t^4+2gt^2+1}+\frac{4}{b^2}\int_0^{\infty}\frac{t^2\mathrm dt}{t^4+2gt^2+1}$$
Then we pay attention to $$N_{n}(s)=\int_0^\infty \frac{x^{2n}}{x^4+2sx^2+1}\mathrm dx$$
With the substitution $x=1/u$, we have 
$$N_n(s)=-\int_\infty^0 \frac{\frac1{u^{2n}}}{\frac1{u^4}+\frac{2s}{u^2}+1}\frac{\mathrm du}{u^2}$$
$$N_n(s)=\int_0^\infty \frac{u^{2-2n}\mathrm du}{u^4+2su^2+1}$$
$$N_n(s)=N_{1-n}(s)$$
So with $n=1$, 
$$J=\frac8{b^2}\int_0^{\infty}\frac{\mathrm dx}{x^4+2gx^2+1}$$
For this remaining integral, we recall that 
$$\begin{align}
\frac1{x^4+(2-c^2)x^2+1}&=\frac1{(x^2+cx+1)(x^2-cx+1)}\\
&=\frac1{4c}\frac{2x+c}{x^2+cx+1}-\frac1{4c}\frac{2x-c}{x^2-cx+1}+\frac14\frac1{x^2+cx+1}+\frac14\frac1{x^2-cx+1}
\end{align}$$
So we have that 
$$K(c)=\int_0^\infty \frac{\mathrm dx}{x^4+(2-c^2)x^2+1}$$
becomes
$$K(c)=\frac1{4c}\int_0^\infty\frac{2x+c}{x^2+cx+1}\mathrm dx-\frac1{4c}\int_0^\infty\frac{2x-c}{x^2-cx+1}\mathrm dx\\
+\frac14\int_0^\infty \frac{\mathrm dx}{x^2+cx+1}+\frac14\int_0^\infty \frac{\mathrm dx}{x^2-cx+1}$$
The first two integrals are easy, and turn out to be $0$, so we end up with 
$$K(c)=\frac14I(1,c,1)+\frac14I(1,-c,1)$$
Where 
$$I(a,b,c)=\int_0^\infty \frac{\mathrm dx}{ax^2+bx+c}=\frac2{\sqrt{4ac-b^2}}\arctan\frac{2ax+b}{\sqrt{4ac-b^2}}\bigg]_0^\infty\\
=\frac\pi{\sqrt{4ac-b^2}}-\frac2{\sqrt{4ac-b^2}}\arctan\frac{b}{\sqrt{4ac-b^2}}$$
And after a bit of algebra,
$$K(c)=\frac{\pi}{2\sqrt{4-c^2}}$$
And at long last, we have 
$$J=\frac8{b^2}K\left(\sqrt{2-2g}\right)$$
$$J=\frac{2\pi}{ab}$$
