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 :(
 A: Write 
\begin{align}
\frac 1{a+\cos\theta}&=\frac 2{2a+e^{i\theta}+e^{-i\theta}}\\
&=\frac{2e^{i\theta}}{e^{2i\theta}+2ae^{i\theta}+1}\\
&=\frac 2i\frac{ie^{i\theta}}{e^{2i\theta}+2ae^{i\theta}+1},
\end{align}
and integrating
\begin{align}
\int_0^{2\pi}\frac 1{a+\cos\theta}&=\frac 2i\int_{C(0,1)}\frac 1{z^2+2az+1}dz\\
&=\frac 2i\frac 1{2\sqrt{a^2-1}}\int_{C(0,1)}\left(\frac 1{z-(a-\sqrt{a^2-1})}-\frac 1{z-(a+\sqrt{a^2-1})}\right)dz\\
&=\frac 1{2\pi i}\frac{2\pi}{\sqrt{a^2-1}}\int_{C(0,1)}\left(\frac 1{z-(a-\sqrt{a^2-1})}-\frac 1{z-(a+\sqrt{a^2-1})}\right)dz.
\end{align}
Now we use Cauchy's integral formula, noting that $a+\sqrt{a^2-1}$ is outside the unit circle. 
A: $$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}$
