Definite Integral: $\int_0^{2 \pi} \frac{d\phi}{z + b \cos(\phi)}$ During my work, I stumbled upon this definite integral
$$\int_0^{2 \pi} \frac{d\phi}{z + b \cos(\phi)} =  \mathrm{sgn}(\Re(z))\frac{2\pi}{\sqrt{z^2-b^2}} \qquad z \in \mathbb{C}$$
which result I cannot really verify. To be precise, for me, it isn't clear, how the sign of the real part of z comes in. In my calculation, I would get a different result.
Before I start describing how I tried to derive the result, I have to say, that here on the mathematics stackexchange, a very similar thread already exists (compute integral $\int_0^{2\pi} \frac{1}{z-\cos(\phi)} d\phi$), but it also leaves my question open.
I tried to solve this integral in the complex plane.
After the substitution $\cos(\phi)=\frac{1}{2}(e^{i \phi}+e^{-i \phi})$, $w=e^{i \phi}$ and identifying the poles to be located at $w_{1,2}=-\frac{z}{b}\pm \sqrt{\frac{z^2}{b^2}-1}$ I end up with
$$\int_0^{2 \pi} \frac{d\phi}{z + b\cos(\phi)}=-\frac{-2i}{b}\oint_{r<1}\frac{dw}{(w-w_1)(w-w_2)}.$$
Now comes the point, where I have to check, which when which poles contributes to the contourintegral (residual theorem). Therefore I have to check at which $ z = a + i \eta$ and b the poles $w_{1,2}$ lies within the unit circle. 
First question: Can I already judge from $w_{1,2}=-\frac{z}{b}\pm \sqrt{\frac{z^2}{b^2}-1}$, in which cases $\mathrm{Abs}(w_{1,2})<1$ and thus which pole contributes to the integral?
In order to proceed, I just plotted $\mathrm{Abs}(w_{1,2}(a,b,\eta))$ for identifying, where it is smaller than 1. And, what I get is the following
Click here to see the plot (i dont have enough reputation to post a image...)
Thus, the contour integral yields
$$
\oint ... = 2\pi i \mathrm{Res}(f,w1) = \frac{2\pi}{\sqrt{z^2-b^2}}, $$
when $b<a ,\, b>0 ,\,a>0$ 
or $b>a ,\, b<0 ,\,a<0$
and
$$
\oint ... = 2\pi i \mathrm{Res}(f,w2) = -\frac{2\pi}{\sqrt{z^2-b^2}}, $$
when $b<a ,\, b<0 ,\,a>0$
or $b>a ,\, b>0 ,\,a<0.$
Second question: Thus, it seems, that $\mathrm{sgn}(a/b)$ matters, and not $\mathrm{sgn}(\Re(z))=\mathrm{sgn}(a)$. Therefore, something must be wrong in my calculation. I could imagine, that the multi-valued $\sqrt{z^2/b^2-1}$, could be a problem. But I don't know, how to derive the correct result.
Third question: For the plots above, I assumed a small $\eta\approx10^{-5}$, which would be fine for the application, where I need this integral. But for general $\eta$, the the boundaries, where $\mathrm{Abs}(w_{1,2})<1$ shifts.
I hope, someone of you have an idea!
Thanks in advance,
Jürgen
 A: Assume $b=1$. The function
$$f(z):=\int_0^{2\pi}{d\phi\over z+\cos\phi}$$
is well defined and analytic in the annular domain $\Omega:={\mathbb C}\setminus[{-1},1]$. Therefore one may hope for an analytic expression for $f(z)$ that does not involve case distinctions. In particular, one should have $f(z)\sim{2\pi\over z}$ for $|z|\to\infty$.
As a preliminary remark we note that the function 
$z\mapsto 1-{1\over z^2}$ does not take values $\leq0$ in $\Omega$, and this implies that the principal value $${\root{\rm pv}\of {1-1/ z^2}}$$
is well defined and analytic in $\Omega$.
The substitution $w:=e^{i\phi}$ transforms the given integral into
$$f(z)={2\over i}\int_{\partial D}{dw\over w^2+2zw+1}\ .$$
Now the function
$$q(w):=w^2+2zw+1$$ has two reciprocal complex zeros $c$ and ${1\over c}$, where we may assume $0<|c|<1$. This $c$ is one of
$$-z\pm\sqrt{z^2-1}=z\left(-1\pm\sqrt{1-1/ z^2}\right)\ ,$$
and being the inverse image of the Joukowski map $\dot D\to\Omega$ is an analytic function of $z$ in $\Omega$. It turns out that
$$c=z\left(-1+{\rm pv}\sqrt{1-1/ z^2}\right)\ .$$
We therefore can write
$$f(z)={2\over i}\>2\pi i\>{\rm res}_{w:=c}\left({1\over q(w)}\right)={4\pi\over q'(c)}={2\pi\over c+z}={2\pi\over z\>\root{\rm pv}\of{1-1/ z^2}}\ .$$
This produces $f(z)\sim{2\pi\over z}$, as required.
