Rational trigonometric integral

I am asked to show that $\int \limits_{0}^{2\pi} \frac{\sin(x)^2}{5+4\cos(x)} dx=\frac{\pi}{4}$.

I substitute in $\sin(x)=\frac{1}{2i}(z-\frac{1}{z})$, $\cos(x)=\frac{1}{2}(z+\frac{1}{z})$ and $dx=\frac{1}{z i}dz$ to get: $\int_{|z|=1} \frac{i (z^2-1)^2}{4z^2(z+2)(2z+1)} dz$.

Now, the pole inside the unit circle are $z=0$ (double pole), $z=-\frac{1}{2}$. I get residues $-\frac{5i}{16}$ and $\frac{3}{8i}$, respectively. So the integral should be $2 \pi i (-\frac{5}{16i}+\frac{3}{8i})=\frac{\pi}{8}$. Where am i wrong? Calculating the residues?

Thanks

[I know a similar question has been already asked. However, I would like a pious man to check my calculation of the residues. I don't know where everything went tits up.]

• I've posted a request to reopen this question. – joriki May 6 '13 at 19:11
• @joriki thank you very much! I cannot see where the error in my calculation is. – user39280 May 6 '13 at 19:12
• I also added this answer to the meta thread that raised the problem of non-duplicates being closed as duplicates. Thanks to everyone who voted to reopen. – joriki May 6 '13 at 19:30

There are two errors. The minor error is that you got the signs wrong on both residues. The more important error that I've made and seen made before that you'll want to watch out for in the future is that you apparently dropped the factor $2z+1$ in calculating the residue at $z=-1/2$, whereas you need to drop a factor $z+1/2$, leaving a factor $2$. If you take that into account, everything works out right.