Evaluate the integral $\int_{0}^{2\pi}\frac{1}{2-\cos^2(x)} dx$ using complex analysis 
Evaluate $$\int_{0}^{2\pi}\frac{1}{2-\cos^2(x)} dx$$

For this problem I tried using residue theorem to find the value of the integral but the computation seems rather messy. Is there a better way to find the integral? Thanks.
 A: I would do it like this
$$I=\int_0^{2\pi} \frac1{2-\cos^2(x)} = \int_0^{2\pi} \frac2{3-\cos(2x)} = \int_0^{\pi} \frac4{3-\cos(2x)}.$$
We then introduce $z=e^{2ix}$ and obtain
$$ I= \oint_{|z|=1} \frac{dz}{2i z} \frac{4}{3 -(z+z^{-1})/2}=  \oint_{|z|=1} \frac{4i}{1-6 z +z^2}.$$
There is a single pole at $z^*= 3-2\sqrt{2}$ inside the unit circle. The second pole is at $z_2= 3+2\sqrt{2}$ with $z^2-6z+1=(z-z^*)(z-z_2)$. 
Using the residue theorem, we obtain
$$I= -8\pi \mathop{\rm Res}_{z=z^*} \frac{1}{(z-z^*)(z-z_2)}= -\frac{8\pi}{z^*-z_2} =\sqrt{2}\pi.$$
A: EDIT: I found my mistake. Here is another approach.
\begin{align*}\int\limits_{0}^{2\pi}\frac{\text{d}x}{2-\cos^2(x)}&=\begin{bmatrix}x=u+\pi \\ \text{d}x=\text{d}u\end{bmatrix}=\int\limits_{-\pi}^{\pi}\frac{\text{d}u}{2-\cos^2(u)}\overset{\overset{\text{even function}}{\big\downarrow}}{=}2\int\limits_{0}^{\pi}\frac{\text{d}u}{2-\cos^2(u)}\\&=2\int\limits_{0}^{\pi}\frac{\csc^2u}{2\csc^2u-\cot^2u}\text{d}u=\begin{bmatrix}\cot u=m \\ -\csc^2u\text{d}u=\text{d}m \\ \csc^2u=m^2+1\end{bmatrix}=-2\int\limits_{\infty}^{-\infty}\frac{\text{d}m}{m^2+2}\\&=2\left.\frac{\arctan\left(\frac{m}{\sqrt{2}}\right)}{\sqrt{2}}\right\vert_{-\infty}^{\infty}=\sqrt{2}\pi\end{align*}
