I was asked to calculate this:
$$\int_0^{2\pi}\! \frac{(1+2\cos x)^n \cos (nx)}{3+2\cos x} \, \mathrm{d}x. $$
My idea was to change the integration limits to $|z|=1$ in the complex plane and to use the residue theorem: $$\int\limits_{|z|=1}\!\frac{(1+z+z^{-1})^n\frac{1}{2}(z^n+z^{-n})}{3+z+z^{-1}} \,\frac{\mathrm{d}z}{iz} = -\frac{i}{2} \int\limits_{|z|=1}\!\frac{(z^2+z+1)^n(z^{2n}+1)}{z^{2n}(z^2+3z+1)} \,\mathrm{d}z$$ but this requires me to calculate $$\lim_{z \to 0}\frac{d^{2n-1}}{dz^{2n-1}}\left[\frac{(z^2+z+1)^n(z^{2n}+1)}{z^2+3z+1}\right]$$ in order to get the residue at $z=0$. Is there any other way of doing this?