How to integrate cos3θ/(5−4cosθ) from 0 to 2π? How do you find the following integral using the theory of Residue?
$$\int_{0}^{2\pi}\frac{\cos(3\theta)d\theta}{5-4\cos(\theta)}$$
I've substituted $\cos(\theta)$ and $\cos(3\theta)$ for $\frac{z+1/z}{2}$ and $\frac{z^3+1/z^3}{2}$ as well as the $d\theta$ with $\frac{dz}{iz}$ but I can't seem to get the correct answer which is $\pi/12$.
 A: It is easier to consider the integral

$$I =  \int_{0}^{2\pi}\frac{e^{i3\theta }d\theta}{5-4\cos(\theta)} $$

where your integral corresponds to the real part of $I$. 
Added: 

$$ I = \int_{|z|=1} \frac{z^3}{5-2(z+1/z)}\frac{dz}{iz}. $$

Can you finish it?
A: An elementary antiderivative is obtainable without complex analysis, but since you specifically asked for a solution using residue theory, I won't elaborate too much on such a method.  The idea is to write $$\cos 3\theta = 4\cos^3 \theta - 3 \cos \theta,$$ then use polynomial long division to get $$\frac{\cos 3\theta}{5-4\cos\theta} = \frac{65}{16} \cdot \frac{1}{5-4\cos \theta} - \cos^2 \theta  - \frac{5}{4}\cos \theta - \frac{13}{16}.$$  Then with the substitution $$\cos \theta = \frac{1-u^2}{1+u^2}, \quad d\theta = \frac{2}{1+u^2} \, du,$$ the first term gives $$\int \frac{d\theta}{5-4\cos\theta} = 2 \int \frac{1}{1+9u^2} \, du.$$  The rest is just computation.  It is altogether quite tractable, though perhaps not the most elegant approach.
