<s>[INST] Contour intergal of a rational trigonometric function, can't find my mistake. This is the integral :
$$I = \int_{0}^{2\pi} \frac{dx}{(5+4\cos x)^2}\ $$
Which, according to wolfram alpha, should evaluate to $\frac{10\pi}{27} $,
but the value i find is $\frac{20\pi}{27} $.

These are my calculations :
Using complex form of cosine i get $ \cos x = \frac{t^2+1}{2t}$
where $ t = e^{ix}$ and $ dx = \frac{dt}{it}$.
If $\partial{D} $ is the unit circle
$$ I = \int_{\partial{D}} \frac{-i}{t(\frac{5t+2t^2+2}{t})^2} dt = 
 -i \int_{\partial{D}}\frac{t}{(t+2)^2(t+1/2)^2}dt = -i I_a$$
$I_a = \pi i $ times the residue in -$\frac{1}{2}$ 
The residue is equal to 
\begin{align}
\lim_{z\to-\frac{1}{2}} \frac{d}{dz} \left( \frac{t(t+1/2)^2}{(t+2)^2(t+1/2)^2}\right) 
&= \lim_{z\to-\frac{1}{2}} \frac{d}{dz}  \frac{t}{(t+2)^2} 
\\&= \lim_{z\to-\frac{1}{2}} \frac{(t+2)^2-2t(t+2)}{(t+2)^4} 
\\&= \lim_{z\to-\frac{1}{2}} \frac{2-t}{(t+2)^3} 
= \frac{2+1/2}{(-1/2+2)^3} 
\\&= \frac{5/2}{27/9} = \frac{20}{27} 
\end{align}
so $ I_a = i\pi\frac{20}{27}$
So our original integral $$I = -i I_a   =  -i^2 \pi\frac{20}{27}  =  \frac{20\pi}{27}$$
 [/INST] You made an error in calculating the factorization of the denominator. You should get $$5t+2t^2+2=(2+t)(1+2t)=2(t+2)(t+1/2),$$ where you missed to transfer the leading factor $2$ to the factorized expression. The correction leads to $I=-\frac i4 I_a$ and the additional division by $4$ corrects the residuum that is computed with the correct factor $2\pi i$.

You could also use the geometric/binomial series to get the correct residual coefficient. Then, using $u=t+\frac12$,
$$
\frac{t}{(t+2)^2(t+\frac12)^2}=\frac{u-\tfrac12}{(u+\frac32)^2u^2}
=\frac49(u-\tfrac12)\sum_{k=0}^\infty (k+1)\left(-\frac23\right)^ku^{k-2}
$$
so that the coefficient for the power $u^{-1}=(t+\frac12)^{-2}$ is $\frac49(1+\frac12\cdot2\cdot\frac23)=\frac{20}{27}$. The integration over the unit circle adds the factor $2\pi i$, so that in the final result $I=\frac{10\pi}{27}$.
</s>