Evaluating a definite integral with a complex exponent How is it possible to evaluate the following integral:
$$
\int_0^{2\pi}\frac{1}{|1-ae^{-it}|^2}dt
$$ 
with $|a| < 1$.
The answer should be something like $\frac{1}{1-|a|^2}$.
 A: $$\frac1{|1-ae^{-it}|^ 2} = \frac1{(1-ae^{-it})(1-\bar ae^{it})} = \sum_{n = 0}^{\infty}\sum_{m=0}^\infty a^n\bar a^m e^{(m-n)it}$$ Since $|a| < 1$ we can intervert sum and integral $$\int_0^{2\pi} \frac1{|1-ae^{-it}|^ 2} \mathrm dt =  \sum_{n = 0}^{\infty}\sum_{m=0}^\infty a^n\bar a^m \underbrace{\int_{0}^{2\pi} e^{i(m-n)t}\mathrm dt}_{\left\{\begin{array}{cc}0 & \text{if $n\neq m$} \\ 2\pi & \text{if $n=m$}\end{array}\right.} = \sum_{n=0}^{\infty} 2\pi (a\bar a)^n = \frac{2\pi}{1-|a|^2}$$
A: Hint. We have that $e^{it}=\cos(t)+i\sin(t)$ and
$$I=\int_0^{2\pi}\frac{dt}{|1-ae^{-it}|^2}=2\int_0^{\pi}\frac{dt}{1+a^2-2a\cos(t)}$$
Now let $s = \tan(t/2)$. Then 
$$\cos(t) = \frac{1-s^2}{1+s^2}\quad,\quad dt=\frac{2 ds}{1+s^2}$$
and you are left to integrate a rational function,
$$I=4\int_0^{+\infty}\frac{ds}{(1-a)^2+(1+a)^2s^2}.$$
You may also take a look here: How do you integrate $\int \frac{1}{a + \cos x} dx$?
A: Note that $e^{it}$ for $t\in[0,2\pi]$ parameterizes a unit circle drawn anti-(counter-) clockwise about $0$, so with substitution $z = e^{it}$ and
$dz = ie^{it}\,dt = iz\,dt$,
\begin{align}\int_{0}^{2\pi} \frac{dt}{|1-ae^{-it}|^2}
= \oint_C \frac{dz \,/ (iz)}{|1-a\overline{z}|^2}
&= \frac{1}{i} \oint_C \frac{dz}{z(1-a\overline{z})\overline{(1-a\overline{z})}}\\
&= \frac{1}{i} \oint_C \frac{1}{z-a} \underbrace{\frac{1}{1-\overline{a} z}}_{\equiv \;f(z)}\;dz\\
&\overset{(*)}{=} \frac{1}{i} 2\pi i \; f(a)
= \frac{2\pi}{1-|a|^2} 
\end{align}
where $(*)$ is Cauchy Integral Formula, which is valid as $f$ is holomorphic, because $|\overline{a}z| = |a||z| < (1)(1) = 1$ so $|1-\overline{a}z| \neq 0$ in the disk.
