Using the residue theorem, calculate $\int_{0}^{2\pi}\frac{1}{1-2a\cos{\theta}+a^2}d\theta$ So I have some troubles for the following question:
Using the residue theorem, calculate :
$\int_{0}^{2\pi}\frac{1}{1-2a\cos{\theta}+a^2}d\theta$ with 
i. $|a|$ < 1 , ii. |a| > 1
I guess that i. and ii. would give us different residues to calculate given that the surface isn't the same.
First I solved for a in the denominator. I get a= $\cos{\theta}\pm\sin{\theta}$. Now I could use the fact that $\cos{\theta}=\frac{e^{i\theta}+e^{-i\theta}}{2}$ but I don't really see what to do next. I have seen other questions like Evaluating $\int_0^{2 \pi} \frac {\cos 2 \theta}{1 -2a \cos \theta +a^2}$ but the conditions and the function aren't exactly the same and I'm still stuck.
Thanks for your help !
 A: Make the change of variables $z=e^{i\theta}$ so 
$$\cos\theta=\frac{z+z^{-1}}{2}.$$
Then, the integral is 
$$\int_0^{2\pi} \frac{d\theta}{1-2a\cos\theta+a^2}=\int_{C(0;1)} \frac{dz}{1-a(z+z^{-1})+a^2}\frac{1}{iz}=-i\int_{C(0;1)} \frac{dz}{z-a(z^2+1)+a^2z}=i\int_{C(0;1)} \frac{dz}{(z-a)(z-1/a)a}$$

If $a\in(0,1)$, then $z=1/a >1$, so it doesn't belong to $C(0;1)$ and $I(C(0;1), z)=0$. For $z=a$ we have that $$\text{Res}(f,a)=(z-a)\left.\frac{i}{(z-a)(z-1/a)a} \right|_{z=a}=\frac{i}{a^2-1}$$
  so 
  $$\int_0^{2\pi} \frac{d\theta}{1-2a\cos\theta+a^2}=2\pi i \text{Res}(f,a) =\frac{-2\pi}{a^2-1}$$
If $a>1$, then $z=a >1$, so it doesn't belong to $C(0;1)$ and $I(C(0;1), z)=0$. For $z=1/a$ we have that $$\text{Res}(f,1/a)=(z-1/a)\left.\frac{i}{(z-a)(z-1/a)a} \right|_{z=1/a}=\frac{i}{1-a^2}$$
  so 
  $$\int_0^{2\pi} \frac{d\theta}{1-2a\cos\theta+a^2}=2\pi i \text{Res}(f,1/a) =\frac{2\pi}{a^2-1}$$

A: It is probably a little off topic but, given that you already had an explanation on how to calculate that integral by Residue theorem, I think that it's worth mentioning the following path using Fourier series in order to calculate that integral, which I report just in case you're interested in.
Assuming first that $a\in(0,1)$. It is obvious that: $$\frac{1}{1-2a\cos(\vartheta)+a^2}=\left|\frac{1}{1-ae^{i\vartheta}}\right|^2,$$
and, by geometric series, we know that: $$\frac{1}{1-ae^{i\vartheta}}=\sum_{n=0}^\infty a^ne^{in\vartheta},$$
so the Fourier coefficients of $$f:\mathbb{T}\rightarrow\mathbb{C}, \vartheta\mapsto\frac{1}{1-ae^{i\vartheta}}$$
are given by: $$\forall n\in\mathbb{Z}, \hat{f}(n)=\begin{cases}
               a^n\ \ if \ \ n\ge0\\
               0\ \ otherwise
            \end{cases}$$
Then, by Plancherel, we get: $$\int_0^{2\pi}\frac{1}{1-2a\cos(\vartheta)+a^2}\operatorname{d}\vartheta=\int_0^{2\pi}|f(\vartheta)|^2\operatorname{d}\vartheta=\\=2\pi\sum_{n=-\infty}^{+\infty}|\hat{f}(n)|^2=2\pi\sum_{n=0}^{+\infty}|a|^{2n}=\frac{2\pi}{1-|a|^2}=\frac{2\pi}{1-a^2}.$$
Then, denoting the unit disk by $D$ and noticing that the functions $$D\rightarrow\mathbb{C}, a\mapsto\frac{2\pi}{1-a^2}$$
and
$$D\rightarrow\mathbb{C}, a\mapsto\int_0^{2\pi}\frac{1}{1-2a\cos(\vartheta)+a^2}\operatorname{d}\vartheta$$
are both analytic and coincide by what we have shown on $(0,1)$, by the identity principle for analytic functions, we get that: $$\forall a\in D, \int_0^{2\pi}\frac{1}{1-2a\cos(\vartheta)+a^2}\operatorname{d}\vartheta=\frac{2\pi}{1-a^2}.$$
With a similar argument you can also address the case $|a|>1$.
A: HINT: 
Let $z=e^{it},t \in [0,2\pi]$
Then $\cos{t}=\frac{z+\frac{1}{z}}{2}$ and $dt=\frac{1}{iz}dz$
So now substituting,you have to compute an integral of a function of $z$ on the unit circle $C_0(1)$
So you can use the residue theorem by taking cases for $a$
