Residue Calculus evaluation of definite integral 
Find the integral of $$\int_0^1 \frac{dx}{\sqrt{x^2 - 1}}$$ by considering a dumbbell contour and finding the residue of the branch of $$\frac{1}{\sqrt{z^2 - 1}}$$ at $\infty$.

Now the dumbbell contour consists of a small circle about $z=-1$ (oriented anticlockwise), a small circle about $z=1$ (oriented anticlockwise) and two line segments joining the circles: one above the real axis (directed from $1$ to $-1$) and one below (directed from $-1$ to $1$).
Apparently, the answer is $\dfrac{-\pi \cdot i}{2}$ or  $\dfrac{\pi \cdot i}{2}$ depending on what branch is used. 
I have been struggling with this integral for some time so if someone could provide a fairly detailed answer, I would be very grateful. 
 A: Let
$$
f(z)=\frac{1}{\sqrt{z^2-1}}, \quad z\in\mathbb C\setminus[-1,1].
$$
First choose the branch with $f(2)=\frac{1}{\sqrt{3}}$. (You can choose the opposite one too.)
Next observe (not trivial) that $f$ is odd and we have the Laurent series
$$
f(z)=\frac{1}{z}+{\mathcal O}(z^{-3}),
$$
and hence 
$$
\int_C f(z)\,dz=2\pi i,
$$
where $C$ is the dumbell contour (or any closed simple curve containing $[-1,1]$ in its interior).
In particular, 
$$
\int_C\frac{dz}{\sqrt{z^2-1}}=\lim_{t\searrow0}\left(\int_{-1}^1\frac{dx}{\sqrt{(x-it)^2-1}}-\int_{-1}^1\frac{dx}{\sqrt{(x+it)^2-1}}\right) \\
\overset{\text{$f$ odd}}{=}2\lim_{t\searrow0}\int_{-1}^1\frac{dx}{\sqrt{(x-it)^2-1}} =4\lim_{t\searrow0}\int_{0}^1\frac{dx}{\sqrt{(x-it)^2-1}}.
$$
Finally,
$$
\int_0^1\frac{dx}{\sqrt{x^2-1}}=\frac{1}{4}\int_C f(z)\,dz=\frac{\pi i}{2}.
$$
A: Let's pick a branch cut on $\Re(z)\in [-1,1]$ such that $\arg(z-1) \in (-\pi,\pi]$ and $\arg(z+1)\in (-\pi,\pi]$. Under this branch cut, we have a continuous function for $x <-1$ $$f(z) = (|z+1|e^{\pm i\pi}|z-1|e^{\pm i\pi})^{-1/2} = \frac{-1}{\sqrt{|z+1||z-1|}} $$
With that in mind, the contour consists of two half-circles and two line segments
$$ \begin{align}
&C_1: z = -1 + re^{i\theta_1}, \ \theta_1 \in (\pi/2,\pi) \cup (-\pi, -\pi/2] \\ 
&C_2: z = x + ri, \ x \in (-1,1) \\
&C_3: z = 1 + re^{i\theta_2}, \ \theta_2 \in (-\pi/2,\pi/2) \\ 
&C_4: z = x - ri, \ x \in (-1,1) 
\end{align} $$
in the limit $r\to 0$. The integral looks like
$$ \int_C = \int_{C_1} + \int_{C_2} + \int_{C_3} - \int_{C_4} $$
Using the estimation lemma, you can prove that both half-circles go to $0$
$$ \left|\int_{C_1,\ C_3} \frac{1}{\sqrt{z^2-1}} dz\right| \le \frac{\pi r}{\sqrt{r^2+1}} \to 0 $$
For the two line segments, observe that
$$ f(C_2) \to (|z+1|e^{i0}|z-1|e^{i\pi})^{-1/2} = \frac{-i}{\sqrt{|z+1||z-1|}} $$
$$ f(C_4) \to (|z+1|e^{i0}|z-1|e^{-i\pi})^{-1/2} = \frac{i}{\sqrt{|z+1||z-1|}} $$
Thus
$$ \int_C f(z)\ dz \to -2i\int_{-1}^1 \frac{1}{\sqrt{|x^2-1|}}\ dx = -4 \int_0^1 \frac{1}{\sqrt{x^2-1}}\ dx $$
To finish off the integral, we find the residue of $f$ at infinity, which is the same as finding the residue at $0$ of
$$ g(w) = -\frac{1}{w^2}f\left(\frac{1}{w}\right) = -\frac{1}{w\sqrt{1-w^2}} $$
You can tell this is a single pole, so
$$ \operatorname*{Res}_{w=0} g(w) = \lim_{w\to 0} \big(w g(w)\big) = -1 $$
Altogether this gives a result of 
$$ \int_0^1 \frac{1}{x^2-1}\ dx = -\frac{1}{4}(-2\pi i) = \frac{\pi i}{2} $$
for this branch

For the other branch, the branch cut is on $\Re(z) \in [1,\infty) \cup (-\infty,-1]$, such that $\arg(z+1)\in (-\pi,\pi]$ and $\arg(z-1) \in [0,2\pi)$. Of course this forces you to invert the contour entirely so the two line segments are parallel to the branch cut, so it may not be as straightforward
