TITLE: Calculate the integral $\int_{0}^{2\pi}\frac{1}{a^{2}\cos^2t+b^{2}\sin^{2}t}dt$, by deformation theorem.
QUESTION [12 upvotes]: I want to prove:
$$\int_{0}^{2\pi}\frac{1}{a^{2}\cos^2t+b^{2}\sin^{2}t}dt=\frac{2\pi}{ab}$$
by the deformation theorem of complex variable.
Then I consider a parameterization $\gamma:[0,2\pi]\rightarrow A$, traveled in the opposite direction of the clock hand, of the ellipse (in $\mathbb{C}$):
$$\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$$
I thought of searching for a function $f:A\rightarrow \mathbb{C}$ (analytic in $A$) and a curve $\lambda:[0,2\pi]\rightarrow A$ (homotopic to $\gamma$) and use the deformation theorem:
$$\int_{\gamma}f = \int_{\lambda}f$$
But I can not find a function $f(z)$ that meets what I need, can you help me to find the f? 
P.D: Necessarily I have to use the theorem of deformation

REPLY [14 votes]: Let the ellipse $\Gamma$
$$ \frac{x^2}{a^2} + \frac{y^2}{b^2} = 1$$
be parameterized by
$$ z = a\cos\theta + ib\sin\theta$$
with $\theta\in[0,2\pi].$
Consider the integral
$$ \int_\Gamma \frac{1}{z} dz.$$
This is equal to
$$ \int_0^{2\pi} \frac{1}{a\cos\theta + ib\sin\theta}
(-a\sin\theta + ib\cos\theta) \; d\theta\\ =
\int_0^{2\pi} 
\frac{a\cos\theta-ib\sin\theta}{a^2\cos^2\theta + b^2\sin^2\theta}
(-a\sin\theta + ib\cos\theta) \; d\theta.$$
which is
$$\int_0^{2\pi} 
\frac{(b^2-a^2)\sin\theta\cos\theta + iab(\cos^2\theta+\sin^2\theta)}
{a^2\cos^2\theta + b^2\sin^2\theta} \; d\theta
\\=\int_0^{2\pi} 
\frac{(b^2-a^2)\sin\theta\cos\theta + iab}
{a^2\cos^2\theta + b^2\sin^2\theta} \; d\theta.$$
This implies that
$$ \frac{1}{ab} \Im \int_\Gamma \frac{1}{z} dz =
\int_0^{2\pi} \frac{1} {a^2\cos^2\theta + b^2\sin^2\theta} \; d\theta.$$
Now apply the  deformation theorem, turning the ellipse  into a circle
round the origin of radius one, getting
$$ \frac{1}{ab} \Im \int_\Gamma \frac{1}{z} dz =
\frac{1}{ab} \Im \int_{|z|=1} \frac{1}{z} dz =
\frac{1}{ab} \Im (2\pi i) = \frac{2\pi}{ab}.$$
Verification. We can verify this result using the Cauchy residue theorem directly. Put $z=e^{i\theta}$ so that $dz = i e^{i\theta} \; d\theta$ and $d\theta = 1/(iz) \; dz$ to get
$$\int_0^{2\pi} \frac{1} {a^2\cos^2\theta + b^2\sin^2\theta} \; d\theta
= \int_{|z|=1} \frac{4}{a^2(z+1/z)^2 - b^2(z-1/z)^2} \frac{1}{iz} \; dz.$$
This gives
$$\frac{1}{i}\int_{|z|=1} \frac{4z}{a^2(z^2+1)^2 - b^2(z^2-1)^2}  \; dz$$
This has the following four simple poles:
$$\rho_{0,1} = \pm i\sqrt{\frac{a-b}{a+b}}
\quad\text{and}\quad
\rho_{2,3} = \pm i\sqrt{\frac{a+b}{a-b}}.$$
Now suppose that $a>b>0$ (the other cases are treated similarly). This leaves only $\rho_{0,1}$ inside the unit circle.
The residues are easy to calculate:
$$\mathrm{Res}\left(\frac{4z}{a^2(z^2+1)^2 - b^2(z^2-1)^2}; z=\rho_{0,1} \right)
= \left.\frac{4z}{2a^2(z^2+1)2z - 2b^2(z^2-1)2z}\right|_{z=\rho_{0,1}}
\\ = \left.\frac{2}{2a^2(z^2+1) - 2b^2(z^2-1)}\right|_{z=\rho_{0,1}}
= \left.\frac{1}{(a^2-b^2)z^2 + (a^2+b^2)}\right|_{z=\rho_{0,1}}.$$
Note that $$\rho_{0,1}^2 = - \frac{a-b}{a+b}$$ giving for the residues
$$ \frac{1}{-(a^2-b^2)(a-b)/(a+b) + (a^2+b^2)}
= \frac{1}{-(a-b)^2 + (a^2+b^2)}  = \frac{1}{2ab}.$$
Therefore the value of the integral is
$$2\pi i \times \frac{1}{i} \times 
\left(\frac{1}{2ab} + \frac{1}{2ab}\right)= \frac{2\pi}{ab},$$
QED.