im trying to understand how to evalutate the following integral by using complex integrals and the complex substitute described. with the simple substitute i always get to $\frac{1}{z}$ in the bottom frac and i dont know how to advance from there
the question is:
Evaluating $$\int_{[0,2\pi]}\frac{1}{(2+ \cos( x))^2}dx$$ using complex substitute (such as $z = {e}^{ix} \Rightarrow \cos(x) = \frac{z+{z}^{-1}}{2})$
The integrand transforms to
$$\begin{align} \frac{1}{(2+\cos(x))^2} &= \frac{1}{\left(2+\frac{z+\frac1z}2\right)^2} \\ & = \frac{1}{4 +2 z + \frac2z + \frac{z^2+2+\frac1{z^2}}4} \\& = \frac{4z^2}{z^4+8z^3+18z^2+8z+1} \\&=\frac{4z^2}{(z^2+4z+1)^2} \end{align}$$
while the differential term is
$$z=e^{ix} \implies dz = ie^{ix}\, dx \implies dx = \frac{dz}{iz}$$
So the given integral is reinterpreted as the contour integral
$$-4i \int_\gamma \frac{z}{(z^2+4z+1)^2} \, dz$$
where $\gamma$ is the unit circle.