Compute $\int_{0}^{2\pi}\frac{\sin^2\theta}{5+3\cos\theta}\,d\theta$ I''m stuck in a exercise in complex analysis concerning integration of rational trigonometric functions. I have the solution but I don't understand a specific part. Here it goes: 
We want to find $\int_{0}^{2\pi}\frac{\sin^2\theta}{5+3\cos\theta}\,d\theta$. 
Let $z=e^{i\theta}$ so that $d\theta=dz/iz$, $\cos \theta = \frac12 (z+z^{-1})$ and $\sin \theta = \frac {1}{2i}(z-z^{-1})$.  We have 
$$\begin{align}
I&=\int_0^{2\pi} \frac{\sin^2\theta}{5+3\cos \theta}d\theta\\\\
&=\oint_C \frac{-\frac14(z-z^{-1})^2}{5+3\frac12 (z+z^{-1})}\frac{dz}{iz}\\\\
&=\oint_C \frac{\frac i4 (z^2-2+z^{-2})}{5z+ \frac32 z^2 + \frac32}dz\\\\
&=\oint_C \frac{\frac i2 (z^2-2+z^{-2})}{3z^2 + 10z + 3}dz\\\\
&=\frac i2 \oint_C \frac{z^4-2z^2+1}{z^2(3z^2 + 10z + 3)}dz \quad (1)
\end{align}$$
where $C$ is the unit circle in the complex $z$-plane. 
If I understand the last step correctly we multipliy numerator/denominator by $z^2$ in order to get rid of the negative power of $z$. 
Now for the part that I don't understand in the solution. It is said that 
$$(1) = \frac i2 \oint_C \frac{z^4-2z^2+1}{z^23(z+3)(z+\frac13)}dz = \frac i6 \oint_C \frac{z^4-2z^2+1}{z^2(z+3)(z+\frac13)}dz$$
Where does this $3$ come from in the denominator? If I factor out $3z^2 + 10z + 3$ I simply get $(z+3)(z+\frac13)$. 
What is even stranger to me is that, after the computation of residues, the author is getting the correct solution of $\frac{2\pi}{9}$ (I verified with Wolfram) while I'm getting $\frac{2\pi}{3}$  so I'm missing a factor of $\frac13$ (i.e. I'm missing that $3$ in the denominator).
Can someone help me with this?
 A: $$\begin{align*} 3z^2 + 10z + 3 
&= 3 \left(z^2 + \frac{10}{3}z + 1\right) \\ 
&= 3\left(z^2 + 3z + \frac{1}{3}z + 1\right) \\
&= 3\left(z(z + 3) + \frac{1}{3}(z + 3)\right) \\
&= 3\left(z + \frac{1}{3}\right)(z+3). \end{align*}$$
You are missing a factor of $2$ when you go from step $3$ to step $4$.  The denominator should be $3z^2 + 10z + 3$.
A: $$I=\int_{0}^{2\pi}\frac{\sin^2\theta}{5+3\cos\theta}\,d\theta=\int_{0}^{\pi}\sin^2(\theta)\left(\frac{1}{5+3\cos\theta}+\frac{1}{5-3\cos\theta}\right)\,d\theta$$
hence:
$$ I = 10 \int_{0}^{\pi}\frac{\sin^2\theta}{25-9\cos^2\theta}\,d\theta = 20\int_{0}^{\pi/2}\frac{\cos^2\theta}{25-9\sin^2\theta}d\theta $$
and by setting $\theta=\arctan t$ we get:
$$ I = 20\int_{0}^{+\infty}\frac{dt}{(1+t^2)(25+16t^2)}=\frac{20}{9}\int_{0}^{+\infty}\left(\frac{1}{1+t^2}-\frac{16}{25+16t^2}\right)\,dt=\color{red}{\frac{2\pi}{9}}. $$
A: I think your error comes from the wrong use of the quadratic formula for factoring a second order polynomial. Factoring a polynomial and using the quadratic formula are two different things. Recall that for a quadratic polynomial
$$\color{blue}{ax^2+bx+c = a(x-x_1)(x-x_2)}$$
where you are missing the coefficient $a=3$. The quadratic formula will only give you the solutions of the quadratic equation.
