TITLE: Find $\int_0^{2\pi}\frac{1-\frac{1}{4}\cos\theta}{1+\frac{1}{16}\cos^2\theta}d\theta$
QUESTION [5 upvotes]: How to evaluate the following integral?
$$\int_0^{2\pi}\frac{1-\frac{1}{4}\cos\theta}{1+\frac{1}{16}\cos^2\theta}d\theta$$
This is an exercise in complex analysis. It looks like a holomorphic function $f(z)$ that we integrate along a circle and take the real part, but I can't see which function could produce that. More precisely, by Cauchy Integral formula,
$$f(z)=\frac{1}{2\pi i}\int_0^{2\pi}\frac{f(e^{i\theta})}{e^{i\theta}-z}ie^{i\theta}d\theta$$
so I tried to find a holomorphic function and a $z\in\mathbb{C}$ such that $$\Re\left(\frac{f(e^{i\theta})}{e^{i\theta}-z}ie^{i\theta}\right)=\frac{1-\frac{1}{4}\cos\theta}{1+\frac{1}{16}\cos^2\theta}$$
but this attempt failed.

REPLY [5 votes]: The standard way to attack integrals of this sort (i.e., rational functions of sine and cosine over a complete cycle) is to sub $z=e^{i \theta}$; then $d\theta=-i dz/z$ and $\cos{\theta}=\frac12 (z+z^{-1})$, and the integral becomes
$$-i \oint_{|z|=1} \frac{dz}{z} \frac{1-\frac18 (z+z^{-1})}{1+\frac{1}{64} (z+z^{-1})^2}$$
which is equal to
$$i 8 \oint_{|z|=1} dz \frac{ z^2-8z+1}{z^4+66 z^2+1}$$
You may now use the residue theorem to evaluate the integral: find the poles of the integrand and evaluate the residues of those poles inside the unit circle.  The poles are where
$$z^4+66z^2+1=0 \implies z^2=-33\pm 8\sqrt{17} = -(\sqrt{17}\pm 4)^2$$
which means that either $z=\pm i \left (\sqrt{17}-4\right )$ or  $z=\pm i \left (\sqrt{17}+4\right )$.  Of these, only the former pair are within the unit circle, so we need only take residues at those poles.  The integral is $i 2 \pi$ times the sum of these residues, which may be taken to be twice the real part of one of the residues.  The expression for the residue is
$$i 8 \frac{z^2-8 z+1}{4 z^3+132 z}$$
Plug in $z= i \left (\sqrt{17}-4\right )$, take the real part, and multiply by two.  The arithmetic is messy but straightforward; the result is
$$\int_0^{2 \pi} d\theta \frac{1-\frac14 \cos{\theta}}{1+\frac{1}{16} \cos^2{\theta}} = \frac{8 \pi}{\sqrt{17}}$$