$\int_0^{2\pi}\frac{\sin^2x}{5+4\cos x}\ dx$ Using complex integration Here is the integral I am trying to evaluate:
$$\int_0^{2\pi}\dfrac{\sin^2x}{5+4\cos x}\ dx$$
I am getting the final answer as $-{\pi}/8$ but the correct answer is ${\pi}/4$
Here are the steps I did:
$$\begin{align}
\dfrac{\sin^2x}{5+4\cos x} dx &= \\\\
 &=\dfrac{\left(\dfrac{z-1/z}{2i}\right)^2}{5+4\dfrac{z+1/z}{2}} \dfrac{dz}{iz} \\\\
&=\dfrac{-1}{4i}\dfrac{{z^2+1/z^2-2}}{5z+2(z^2+1)} dz \\\\
&=\dfrac{-1}{4i}\dfrac{{z^4+1-2z^2}}{{z^2}(5z+2({z^2+1}))} dz \\\\
&=\dfrac{-1}{4i}\dfrac{{z^4+1-2z^2}}{{z^2}(2z+1)(z+2)} dz
\end{align}$$
Clearly, singularities within $|z|=1$ are $0$, and $\frac{-1}{2}$. After applying Residue theorem, I am getting $\frac{-\pi}{8}$
Are my steps correct?

So far the steps you showed are correct except for a little typo I corrected.
But you didn't show the calculation of the residues.
With $f(z) =\frac{-1}{4i}\frac{{z^4+1-2z^2}}{{z^2}(2z+1)(z+2)}$ I get
$$\operatorname{Res}_{z=0}f(z)= -\frac{5}{16}i \mbox{ and }\operatorname{Res}_{z=-\frac 12}f(z)= \frac{3}{16}i$$
Hence,
$$\int_0^{2\pi}\frac{\sin^2x}{5+4\cos x}\ dx = 2\pi i\left( -\frac{5}{16}i + \frac{3}{16}i\right) =\frac{\pi}{4}$$
