Analytic domains in an integral Consider the integral
$$
\int_0^{2\pi} \frac{d\theta}{w+\cos\theta} = \frac{2\pi}{\sqrt{w^2-1}},\quad w\ \in\mathbb{C}-[-1,1],
$$
where the right-hand side of the identity corresponds to the branch of $\sqrt{w^2-1}$ that is positive on the real interval $(1,+\infty)$.
I have some questions. 


*

*If I write $\sqrt{w^2-1}=\sqrt{w-1}\sqrt{w+1}$, and for the first term  I choose the branch $(-\infty,0]$, and for the second the branch $[0,+\infty)$, then $w\in \mathbb{C}-[-1,1]$, is this right?

*I don't understand the statement "where the right-hand side of the identity corresponds to the branch of $\sqrt{w^2-1}$ that is positive on the real interval $(1,+\infty)$". I am confused because I have already chosen branches for each $\sqrt{w\pm1}$.

*If $w$ is a real variable, then the integral is the same. Is this because of analytic continuation?
 A: In order to avoid poles along the integration path we need that $w$ does not belong to the range of $\cos\theta$, hence $w\not\in[-1,1]$. In such a case, by exploiting symmetry
$$I(w)=\int_{0}^{2\pi}\frac{d\theta}{w+\cos\theta} = \int_{0}^{\pi}\frac{2w\,d\theta}{w^2-\cos^2\theta}=4\int_{0}^{\pi/2}\frac{w\,d\theta}{w^2-\cos^2\theta} $$
and by the substitution $\theta=\arctan t$ we get
$$ I(w) = 4w\int_{0}^{+\infty}\frac{dt}{(1+t^2)w^2-1}=2w\int_{-\infty}^{+\infty}\frac{dt}{(w^2-1)+t^2 w^2} $$
so $I(w) = 2\int_{-\infty}^{+\infty}\frac{dt}{(w^2-1)+t^2}$. By the residue theorem it follows that
$$ I(w) =  \frac{2\pi}{\sqrt{w^2-1}} $$
where $\sqrt{w^2-1}$ is the standard (real and positive) determination over $(1,+\infty)$.
You are not allowed to pick some determinations for $\sqrt{w-1}$ and $\sqrt{w+1}$ then wonder if they fit your needs: both the constraints on $w$ and the meaning of $\sqrt{w^2-1}$ in the final formula are fixed by the problem itself. For instance $w\in(1,+\infty)$ implies $I(w)=\frac{2\pi}{\sqrt{w^2-1}}$ and $w\in(-\infty,-1)$ implies $I(w)=-\frac{2\pi}{\sqrt{w^2-1}}$. If $w=i$, then $I(w)=-\pi i\sqrt{2}$.
A: It is not necessarily a great idea to define $\sqrt{z^2-1}$ as a product of $\sqrt{z-1}$ and $\sqrt{z+1}$, since things get messy, when you exclude lines, where $\sqrt{z-1}$ and $\sqrt{z+1}$ can not be defined, and then you try to show that their product is continuous along parts of these lines.
The most elegant and clean way  of defining $\sqrt{z^2-1}$ is using the following Lemma:
Lemma. If $U$ is a region, and $a$ and $b$ belong to the same connected component of $\mathbb C\cup\{\infty\}\setminus U$, then 
$$
g(z)=\log\left(\frac{z-a}{z-b}\right),
$$
can be defined as an analytic function in $U$.
In our case $U=\mathbb C\setminus[-1,1]$, $a=-1$ and $b=1$, and 
$$
\sqrt{z^2-1}=(z-1)\exp\left(\frac{1}{2}\log\Big(\frac{z+1}{z-1}\Big)\right)
$$
Proof of Lemma. Note that 
$$
g'(z)=\frac{1}{z-a}-\frac{1}{z-b},
$$
and $\int_\gamma g'(z)\,dz=\mathrm{Ind}_\gamma(a)-\mathrm{Ind}_\gamma(b)=0$, for every closed curve $\gamma$ in $U$, since $a$ and $b$ lie in the same connected component of $U$.
