TITLE: Help with Coordinate Transformation from Polar Coordinates?
QUESTION [6 upvotes]: I want to evaluate the integral $$\frac{1}{2\pi} \int_0^{2\pi} \frac{1}{1 - 2r \cos \theta + r^2} d\theta. $$  I thought first to substitute $\cos(\theta)$ for $\frac{1}{2} (e^{i\theta} + e^{-i\theta} ) $, reducing the problem to a complex integral over the unit circle, then using the $ z = re^{i\theta}$ to change the polar coordinate of $d\theta$ to $dz$.  However, I am stuck with the r in the term when I try to change coordinates using $dz = ire^{i\theta} d\theta$.
Basically I want to be able to integrate over $dz$ instead of $d\theta$ but for some reason I'm finding it difficult to transform the coordinate planes, due to the lingering polar terms when I try to to make the transformation. Is there some generic method that I can generally use when I'm faced with the problem of making coordinate changes?

REPLY [2 votes]: Here's a way that one might be "led by the nose" to the correct contour integral.. Looking at the denominator $r^2 - 2r\cos\theta + 1$ as a function of $r$, you can use the quadratic formula to get the roots, given by 
$$r = \cos(\theta) \pm {1 \over 2}\sqrt{4\cos^2(\theta) - 4}$$
$$= \cos(\theta) \pm {1 \over 2}\sqrt{-4\sin^2(\theta)}$$
$$ = \cos(\theta) \pm i \sin(\theta)$$
$$ = e^{i\theta}, e^{-i\theta}$$
So your integral is the same as 
$${1 \over 2\pi} \int_0^{2\pi} {d\theta \over (r - e^{i\theta})(r - e^{-i\theta})}$$
This suggests doing a contour integral over the unit circle, with $z = e^{i\theta}$, 
${1 \over z} = e^{-i\theta}$, and $dz = ie^{i\theta}d\theta$, so that $d\theta = {dz \over iz}$. The resulting contour integral is
$${1 \over 2\pi i} \int_{|z| = 1}{dz \over z(r - z)(r - {1 \over z})}$$
$$= {1 \over 2\pi i} \int_{|z| = 1}{dz \over (r - z)(rz - 1)}$$
Note this is the same contour integral Didier Piau got, and as he indicated it's a pretty routine application of the residue theorem.