<s>[INST] Using a circular contour integral I was having some problems preparing for an exam, and a friend of mine told me about this site :)
I have to prove this:
$$
 \int_0^{2\pi} \frac{d\theta}{a + \cos\theta} = \frac{2\pi}{\sqrt{a^2 - 1}}
$$
Using
$$
z = e^{i\theta}\\ 
a>1
$$
and integrating over the unit circle $|z| = 1$.
I know there are proofs of this relationship, but I can't manage to do it using the unit circle contour.
Afterwards I also have to proof a similar relation, with the integrand squared:
$$
\int_0^{2\pi} \frac{d\theta}{( a + cos\theta)^2} = \frac{2a\pi}{(a^2 - 1)^{3/2}}
$$
I've tried to put up the equations, but as far as I can tell there are no poles ($z = -a$ lies outside of the unit circle ). Then I can rewrite 
$$
\frac{1}{a + z} = \frac{1}{a + \cos\theta + i\sin\theta} 
$$
But then I'm stuck :(
 [/INST] $$I=
 \int _0^{2\pi} \frac{d\theta}{a + \cos\theta} 
$$   
$$
 =2\int _0^{\pi} \frac{d\theta}{a + \cos\theta} 
$$ 
as $\int _0^{2\pi} \frac{d\theta}{a + \cos\theta}=\int _0^{\pi} \frac{d\theta}{a + \cos\theta}+\int _\pi^{2\pi} \frac{d\theta}{a + \cos\theta}$
Now , $\int _\pi^{2\pi} \frac{d\theta}{a + \cos\theta}=-\int _\pi ^{0} \frac{dy}{a + \cos y}$  where $y=2\pi-\theta$ 
So, $\int _\pi^{2\pi} \frac{d\theta}{a + \cos\theta}=\int _0^\pi  \frac{dy}{a + \cos y}$ 
$I= 2\int _0^{\pi} \frac{d\theta}{a + \frac{(1-tan^2\frac{\theta}{2})}{(1+tan^2\frac{\theta}{2})}} $ 
$= 2\int _0^{\pi} \frac{sec^2\frac{\theta}{2}d\theta}{(a+1) + (a-1)tan^2\frac{\theta}{2}} $
Now putting $tan\frac{\theta}{2}=z$, $sec^2\frac{\theta}{2}d\theta=2dz$
$=\int _0^∞ \frac{4dz}{(a+1) + (a-1)z^2}$
$=\frac{4}{a-1}\int _0^∞\frac{dz}{\frac{a+1}{a-1} + z^2}$
$=\frac{4}{a-1}\sqrt{\frac{a-1}{a+1}}{}tan^{-1}(\frac{z(a-1)}{a+1})| _0^∞$
$=\frac{4}{\sqrt{a^2-1}}\frac{\pi}{2}$
</s>