Evaluate $\frac{1}{2 \pi} \int^{0}_{2 \pi}\frac{d \theta}{1-2r \cos\theta+r^2}$. 
Evaluate $$\frac{1}{2 \pi}\displaystyle \int^{0}_{2 \pi}\frac{d \theta}{1-2r \cos\theta+r^2}$$
for $0<r<1$ by writing $\cos \theta=\frac{1}{2}(e^{i\theta}+e^{-i\theta})$ and reducing the integral to a complex integral over the unit circle.

I  put $z=e^{i\theta}$ and $\cos\theta=\frac{1}{2}(e^{i\theta}+e^{-i\theta})$ and after some calculation get the given integral is equal to $\displaystyle \frac{1}{2\pi i} \int_{|z|=1}\frac{dz}{z(1+r^2)-r(z^2+1)}.$ Next what do I have to do?
Actually I'm not understanding what is the procedure I have to consider(especially the meaning of the question). Please someone help.
Thank you..
 A: Let$$f(z)=\frac1z\times\frac1{1-r(z+z^{-1})+r^2}=\frac1{-rz^2+(1+r^2)z-r}.$$and let $\gamma\colon[0,2\pi]\longrightarrow\mathbb C$ be the loop defined by $\gamma(t)=e^{it}$. Then$$\int_\gamma f=\int_0^{2\pi}\frac1{1-2r\cos\theta+r^2}\,\mathrm d\theta.$$The roots of $-rz^2+(1+r^2)z-r$ are $r$ and $\frac1r$. Only the first one is in the region of $\mathbb C$ bounded by the image of $\gamma$. So, now it's only a matter of using the residue theorem in order to compute $\int_\gamma f$.
A: From your last expression,
$$\frac{1}{2\pi i} \int_{|z|=1}\frac{dz}{z(1+r^2)-r(z^2+1)}=\frac1{1-r^2}\frac{1}{2\pi i} \int_{|z|=1}\Big(\frac1{z-r}-\frac1{z-\frac1r}\Big)\,dz = \frac1{1-r^2}(1-0)$$
since $\frac1r>1$ and is outside of the unit circle which makes the second integral vanish, while the first integral gives $1$ as $r<1$ and is inside the unit circle.
A: we need to find the poles that are inside the contour $|z| = 1$
$-rz^2 + (1+r^2)z - r = -r(z-\alpha)(z-\beta)\\
\alpha = \frac 1r\\
\beta = r$
$\oint \frac {1}{-r(z-r)(z-\frac 1r)} dz$
$\frac {1}{(2\pi i)(1-r^2)} \oint \frac {1}{z-r} - \frac 1{(z-\frac 1r)} dz$
By the residual theorem, if r is inside the contour
$\oint \frac {1}{z-r} =  2\pi i$
and zero if it is outside.
For all $r \ne 1$ one of our poles is inside the contour and one is outside.
If $r<1, \frac {1}{(1-r^2)}$
and if $r>1, \frac {1}{(r^2-1)}$
if $r = 1$ the integral won't converge.
