Evaluating a trigonometric integral using residues Finding the trigonometric integral using the method for residues:
$$\int_0^{2\pi} \frac{d\theta}{ a^2\sin^2 \theta + b^2\cos^2 \theta} = \frac{2\pi}{ab}$$ where $a, b > 0$.
I can't seem to factor this question
I got up to  $4/i (z) / ((b^2)(z^2 + 1)^2 - a^2(z^2 - 1)^2 $
I think I should be pulling out $a^2$ and $b^2$ out earlier but not too sure how.

Letting $z = e^{i\theta},$ we get
$$\int_0^{2\pi} \frac{1}{a^2\sin^2\theta + b^2\cos^2\theta} d\theta =
\int_{|z|=1} \frac{1}{iz} \frac{4}{-a^2(z-1/z)^2+b^2(z+1/z)^2} dz \\=
\int_{|z|=1} \frac{1}{iz} \frac{4z^2}{-a^2(z^2-1)^2+b^2(z^2+1)^2} dz =
-i\int_{|z|=1} \frac{4z}{-a^2(z^2-1)^2+b^2(z^2+1)^2} dz.$$
Now the location of the four simple poles of the new integrand is given by
$$z_{0, 1} = \pm \sqrt{\frac{a+b}{a-b}}
\quad \text{and} \quad
z_{2, 3} = \pm \sqrt{\frac{a-b}{a+b}}.$$
We now restrict ourselves to the case $a > b > 0,$ so that only $z_{2,3}$ are inside the contour. The residues $w_{2,3}$ are given by
$$ w_{2,3} =\lim_{z\to z_{2,3}} \frac{4z}{-2a^2(2z)(z^2-1)+2b^2(2z)(z^2+1)} =
\lim_{z\to z_{2,3}} \frac{1}{-a^2(z^2-1)+b^2(z^2+1)} \\
= \lim_{z\to z_{2,3}} \frac{1}{z^2(b^2-a^2)+b^2+a^2}=
\frac{1}{-(a-b)^2+b^2+a^2} = \frac{1}{2ab}.$$
It follows that the value of the integral is given by
$$-i \times 2\pi i \times 2 \times \frac{1}{2ab} = \frac{2\pi}{ab}.$$
The case $b > a > 0$ is left to the reader. (In fact it is not difficult to see that even though in this case the poles are complex, it is once more the poles $z_{2,3}$ that are inside the unit circle.)
