A Strange Mistake in Application of Residue theorem $\int_0^{2\pi}\frac {\cos(2\theta)} {5+4\cos(\theta)}\, d\theta.$ 
$$\int_0^{2\pi}\frac {\cos(2\theta)}  {5+4\cos(\theta)}\, d\theta.$$

While applying the calculus of residues to the above problem I'm getting the answer as
 $  19\pi/24$. I have tried many times and rechecked the calculations but getting the same answer.
However in my book the answer given is $\pi/6.$
Can someone check and tell me whether I'm correct or the book? Please help.
 A: Use substitutions $z=e^{i\theta}$ and $d\theta=\dfrac{dz}{iz}$ then
\begin{align}
\int_0^{2\pi}\frac {\cos(2\theta)}  {5+4\cos(\theta)}\, d\theta
&= {\bf Re}\int_{|z|=1}\dfrac{z^2}{5+4(z+1/z)}\dfrac{dz}{iz} \\
&= {\bf Re}\dfrac{1}{i}\int_{|z|=1}\dfrac{\frac{z^2}{2(z+2)}}{z+1/2}dz \\
&= {\bf Re}\dfrac{1}{i}2\pi i\dfrac{(-\frac12)^2}{3} \\
&= \color{blue}{\dfrac{\pi}{6}}
\end{align}
A: If $\varphi(x,y)=\frac{x^2-y^2}{5+4x}$, then your integral is$$\int_0^{2\pi}\varphi(\cos\theta,\sin\theta)\,\mathrm d\theta.\tag1$$Let$$f(z)=\frac1z\varphi\left(\frac{z+z^{-1}}2,\frac{z-z^{-1}}{2i}\right)$$and$$\begin{array}{rccc}\gamma\colon&[0,2\pi]&\longrightarrow&\mathbb C\\&\theta&\mapsto&e^{i\theta}.\end{array}$$Then$$\varphi(\cos\theta,\sin\theta)=\varphi\left(\frac{e^{i\theta}+e^{-i\theta}}2,\frac{e^{i\theta}-e^{-i\theta}}{2i}\right)=e^{i\theta}f\left(e^{i\theta}\right).$$Therefore\begin{align}(1)&=\frac1i\int_0^{2\pi}e^{-i\theta}\varphi\left(\frac{e^{i\theta}+e^{-i\theta}}2,\frac{e^{i\theta}-e^{-i\theta}}{2i}\right)ie^{i\theta}\,\mathrm d\theta\\&=-i\int_\gamma f(z)\,\mathrm dz.\end{align}This integral can be computed through the residue theorem: it is equal to$$2\pi\sum\operatorname{res}_{z=\chi}\bigl(f(z)\bigr),\tag2$$where the possible values of $\chi$ are the poles of $f$ in the open unit circle. But$$f(z)=\frac{z^4+1}{z^2(4z^2+10z+4)}.$$So, $f$ has $3$ poles, two of which are located at the open unit circle: $0$ and $-\frac12$ (the third one is $-2$) and the residue of $f$ at these points is $\frac{17}{24}$ and $-\frac58$ respectively. Therefore, your integral is equal to$$2\pi\left(\frac{17}{24}-\frac58\right)=\frac\pi6.$$
