A problem when integrating $\int_{0}^{2\pi}\frac{d\theta}{(a+\cos \theta)^2}$. The exercise is computing $$\int_{0}^{2\pi}\frac{d\theta}{(a+\cos \theta)^2},a>1$$

I know that the exercise may be duplicated, but my problem is something strange when I am working with the residue of it.
We know the idea of solving this exercise is that we can change the variable and integrate along the unit circle. And I directly use the formula that is obtained by this approach in class.
$$
\int_{0}^{2\pi}R(\sin\theta ,\cos\theta)=2\pi\sum_{z_0\in\mathbb{D}}Res_{z_0}\frac{1}{z}R(\frac{z-\bar{z}}{2i},\frac{z+\bar{z}}{2})
$$with $z=e^{i\theta}$. Thus, our exercise becomes to compute the residue of$$\frac{1}{z}\frac{1}{(a+\frac{z+\bar{z}}{2})^2}.$$ I use two approach to compute the residue, both seems good to me but the result is different.

The first method is my naive idea$$\frac{1}{z}\frac{1}{(a+\frac{z+\bar{z}}{2})^2}=\frac{1}{z}\frac{1}{(a+Re(z))^2}$$Since $z$ is in the unit disc and $a>1$, $\dfrac{1}{(a+Re(z))^2}\neq0$, so the only pole is $z=0$.

The second method turns out to be correct.$$\frac{1}{z}\frac{1}{(a+\frac{z+\bar{z}}{2})^2}=\frac{4z}{az+\frac{z^2+1}{2}}=\frac{4z}{(z+a+\sqrt{a^2-1})^2(z+a-\sqrt{a^2-1})^2}$$Thus, the pole in the unit disc is $z_0=\sqrt{a^2-1}-a$.

It is very very strange for me, please help me if you find it usual or easy to explain.
 A: Your first method is incorrect as you are assuming that $a+\Re z$ is analytic at zero — this is not true since $2\Re z=z+1/z$. Therefore, the function $(z(a+\Re z)^2)^{-1}$ does not have a pole at zero, which you can think of as a removable singularity. This means we have to consider the poles of $z^2+2az+1$ instead, which is what your second method does.
A: The function $f(z)=\frac{1}{z\left(a+\left(\frac{z+z^{-1}}{2}\right)\right)^2}$ is meromorphic with second-order poles at $z=-a\pm \sqrt{a^2-1}$.
Recall that the residue theorem is not applicable if the integration contour passes through a singularity of the integrand.  So, the fact the $f(z)\ne 0$ for $|z|=1$ is actually required of the residue theorem to be applied to the contour integral $\oint_{|z|=1}f(z)\,dz$.
You correctly stated that $a+\frac{z+\bar z}{2}=a+\text{Re}(z)$.  And it is true that this expression cannot be $0$ when $|z|=1$ (i.e., in the integration of $f(z)$ over the unit circle, $f(z)\ne 0$).
But $\frac{z+z^{-1}}{2}$ is equal to $0$ for certain values of $z$ inside the unit circle, namely at values of $z=-a+\sqrt{a^2-1}$ for $a>1$.  Note that $z^{-1}=\bar z$ only for $|z|=1$ (i.e., only when $z$ is on the unit circle).
In regards to the naïve approach, the fact that the term $a+\text{Re}(z)$ is not $0$ for $z$ on the unit circle does not mean that there is no pole of $\frac{z+z^{-1}}{2}$ inside the unit circle.  Using that reasoning, the term $z$ itself is not $0$ for $z$ on the unit circle either.  And we surely would not conclude that $z$ cannot be $0$ inside the unit circle.
