<s>[INST] Residue Formula application Using the Residue formula, I've been trying to prove $$\int_0^{2\pi}\frac{1}{a^2\cos^2\theta+b^2\sin^2\theta}\,d\theta=\frac{2\pi}{ab},\quad\quad a,b\in\Bbb R.$$First, it seems like the formula should be wrong (unless perhaps we assume $a,b\in\Bbb R^+$) since the right-hand side can be negative, but the integrand on the left is always non-negative. Currently I'm assuming the additional requirement $a,b>0$.
With that said, to approach it, I use Euler's formulas on the trig. functions in the denominator and make a change of variables, $$z=e^{i\theta},\quad \frac{1}{iz}\,dz=d\theta.$$Now, if I have calculated correctly, the integral reduces to $$\int_{|z|=1}\frac{1}{iz}\cdot\frac{1}{\frac{a^2}{4}\left(z+z^{-1}\right)^2-\frac{b^2}{4}\left(z-z^{-1}\right)^2}\,dz.$$We can factor $z^{-2}$ from the right-side denominator to get $$\int_{|z|=1}\frac{z}{i}\cdot\frac{1}{\frac{a^2}{4}\left(z^2+1\right)^2-\frac{b^2}{4}\left(z^2-1\right)^2}\,dz.$$Since the denominator is a difference of squares, we can factor the denominator as $$\int_{|z|=1}\frac{4z}{i}\cdot\left(\frac{1}{a(z^2+1)-b(z^2-1)}\right)\cdot\left(\frac{1}{a(z^2+1)-b(z^2-1)}\right)\,\,dz. $$This is where I really started running into trouble. I tried solving when the denominator of the right term vanished and I found $$z=\pm\sqrt{\frac{b+a}{b-a}}.$$ This didn't seem right because it doesn't always have to be inside the unit circle (I don't think), so I think I might have made an error in calculation.
Is my method so far correct, or is there a far better way to calculate this integral using the residue formula? This isn't homework, just prepping for an exam. Thanks!
 [/INST] You can use trigonometric substitution to solve this problem. 
Suppose $a<b$. Let $k=\frac{b}{a},t=\tan\frac{\theta}{2}$. Then $k>1$ and
$$ \sin\theta=\frac{2t}{t^2+1}, \cos\theta=\frac{t^2-1}{t^2+1},d\theta=\frac{2t}{t^2+1}dt $$
and hence
\begin{eqnarray*}
\int_0^{2\pi}\frac{1}{a^2\cos^2\theta+b^2\sin^2\theta}d\theta&=&\frac{2}{a^2}\int_{-\infty}^\infty\frac{t^2+1}{(t^2-1)^2+4k^2t^2}dt\\
&=&\frac{2}{a^2}\int_{-\infty}^\infty\frac{t^2+1}{t^4+2(2k^2-1)t^2+1}dt\\
&=&\frac{2}{a^2}\int_{-\infty}^\infty\frac{t^2+1}{(t^2+(2k^2-1))^2+4k^2(1-k^2)}dt\\
&=&\frac{2}{a^2}\int_{-\infty}^\infty\frac{t^2+1}{(t^2+\alpha)(t^2+\beta)}dt\\
&=&\frac{2}{a^2}\int_{-\infty}^\infty\left(\frac{A}{t^2+\alpha}+\frac{B}{t^2+\beta}\right)dt\\
&=&\frac{2}{a^2}(\frac{A\pi}{\sqrt{\alpha}}+\frac{B\pi}{\sqrt{\beta}})\\
&=&\frac{2\pi}{ab}
\end{eqnarray*}
where
$$ \alpha=(2k^2-1)+2k\sqrt{k^2-1},\beta=(2k^2-1)-2k\sqrt{k^2-1},A=\frac{\alpha-1}{\alpha-\beta}, B=\frac{1-\beta}{\alpha-\beta},$$
Suppose $a>b$. Let $k=\frac{b}{a},t=\tan\frac{\theta}{2}$. Then $k>1$ and hence
\begin{eqnarray*}
\int_0^{2\pi}\frac{1}{a^2\cos^2\theta+b^2\sin^2\theta}d\theta&=&2\int_0^{\pi}\frac{1}{a^2\cos^2\theta+b^2\sin^2\theta}d\theta\\
&=&2\int_0^{\pi}\frac{1}{a^2\frac{1+\cos2\theta}{2}+b^2\frac{1-\cos2\theta}{2}}d\theta\\
&=&4\int_0^{\pi}\frac{1}{(a^2+b^2)+(a^2-b^2)\cos2\theta}d\theta\\
&=&2\int_0^{2\pi}\frac{1}{(a^2+b^2)+(a^2-b^2)\cos\theta}d\theta\\
&=&\frac{2}{a^2-b^2}\int_0^{2\pi}\frac{1}{\alpha+\cos\theta}d\theta\\
&=&\frac{2}{a^2-b^2}\int_{-\infty}^{\infty}\frac{1}{\alpha+\frac{t^2-1}{t^2+1}}\frac{2}{t^2+1}dt\\
&=&\frac{2}{a^2-b^2}\int_{-\infty}^{\infty}\frac{2}{\alpha(t^2-1)+t^2-1}dt\\
&=&\frac{4}{a^2-b^2}\int_{-\infty}^{\infty}\frac{2}{(\alpha+1)t^2+\alpha-1}dt\\
&=&\frac{4}{(a^2-b^2)(\alpha+1)}\int_{-\infty}^{\infty}\frac{1}{t^2+\frac{\alpha-1}{\alpha+1}}dt\\
&=&\frac{4}{(a^2-b^2)(\alpha+1)}\sqrt{\frac{\alpha+1}{\alpha-1}}\pi\\
&=&\frac{2\pi}{ab}.
\end{eqnarray*}
where
$$ \alpha=\frac{a^2+b^2}{a^2-b^2}>1. $$
</s>