Computing $ \int_0^{2\pi} \frac{1}{a^2\cos^2 t+b^2 \sin^2 t} dt \;; a,b>0$. 
Using Residue Theorem find $\displaystyle \int_0^{2\pi} \frac{1}{a^2\cos^2 t+b^2 \sin^2 t} dt \;; a,b>0$.

My Try:
So, I am going to use the ellipse $\Gamma = \{a\cos t+i b \sin t: 0\leq t\leq 2\pi\}$. 
On $\Gamma$, $z=a\cos t+i b \sin t$, so $|z|^2=z\bar{z}=a^2\cos^2 t+b^2 \sin^2 t$. 
Now, $dz=-a\sin t+i b \cos t dt$. 
Hence, the integral becomes $\displaystyle \int_\Gamma \frac{dz}{z(iab+(\sin t \cos t)(b^2-a^2))}$. I know that $\displaystyle \int_\Gamma \frac{dz}{z}=2\pi i$. Now, how do I get rid of $\sin t \cos t$ part? I am stuck here. Can somebody please explain how?
 A: Note that we have for $z=a\cos t+ib\sin t$,
$$\begin{align}
\frac{1}{z}\,dz&=\frac{\bar z}{|z|^2}\,dz\\\\
&=\frac{\left(a\cos t-ib\sin t\right)}{a^2\cos^2 t+b^2\sin^2 t}\,\left(-a\sin t+ib\cos t\right)\,dt\\\\
&=\left(\frac{(b^2-a^2)\sin t\cos t}{a^2\cos^2 t+b^2\sin^2 t}\right)\,dt+i\left(\frac{ab}{a^2\cos^2 t+b^2\sin^2 t}\right)\,dt
\end{align}$$
Therefore, we have
$$\begin{align}\int_0^{2\pi}\frac{1}{a^2\cos^2 t+b^2\sin^2 t}\,dt&=\frac{1}{ab}\text{Im}\left(\oint_C \frac{1}{z}\,dz\right) \tag 1\\\\
&=\frac{2\pi}{ab}
\end{align}$$
where $C$ is the elliptical contour around the origin and we used the Residue Theorem to evaluate the integral on the right-hand side of $(1)$.
A: Enforcing the change of variables $x= t-π$  leads to 
$$I=\int_{0}^{2\pi} \frac{dx}{a^2\sin^2x+b^2\cos^2x}=2\int_{0}^{\pi} \frac{dx}{a^2\sin^2x+b^2\cos^2x}=4\int_{0}^{\pi/2} \frac{dx}{a^2\sin^2x+b^2\cos^2x}$$
and we have  \begin{align}\frac{1}{a^2\sin^2x+b^2\cos^2x}&=\frac1{ab}\cdot\frac{b^2\cos^2x}{b^2\cos^2x+a^2\sin^2x}\cdot\frac{a}{b\cos^2x}\\&=\frac1{ab}\cdot\frac1{1+\left(\frac ab \tan x\right)^2}\cdot \frac a{b\cos^2x}\\&=\frac1{ab}\left[\arctan{\left(\frac ab\tan x\right)}\right]'\end{align}

$$I=4\int_{0}^{\pi/2}\frac1{ab}\left[\arctan{\left(\frac ab\tan x\right)}\right]'dx = \frac{2π}{ab} $$

