Integrating around 2 branch points, trouble with a -i factor. The problem is to find $\int_{-1}^1 {1\over \sqrt{1-x^2}}$ by integrating $(z^2-1)^{-1/2}$ on a contour around $-1$, $1$ in the complex plane.
I managed to solve it by integrating $(1-z^2)^{-1/2}$, but when I do it as the problem tells me to I have an extra factor of -i.
This is a picture of the solution (as given by the lecturer), and I pointed exactly where I have my issue.
 A: If we define
$$
f(z)=\frac\pi2i+\int_i^z\left(\frac1{1+w}+\frac1{1-w}\right)\mathrm{d}w\tag{1}
$$
where the path from $i$ to $z$ does not cross the segment $[-1,1]$, then we get a well defined branch of
$$
f(z)=\log\left(\frac{1+z}{1-z}\right)\tag{2}
$$
on the complement of $[-1,1]$.  On top of $[-1,1]$, $f(z)$ is real, and by considering the residues in $(1)$, on the bottom of $[-1,1]$, $\mathrm{Im}(f(z))=2\pi$. Thus, on the real axis away from $[-1,1]$, $\mathrm{Im}(f(z))=\pi$. We can then define
$$
e^{f(z)/2}=\sqrt{\frac{1+z}{1-z}}\tag{3}
$$
Since $\mathrm{Im}(f(z))=\pi$ on the real axis away from $[-1,1]$, using $(3)$, we have that
$$
\lim_{|z|\to\infty}\sqrt{\frac{1+z}{1-z}}=i\tag{4}
$$
Using $(3)$, we can define
$$
g(z)=\frac1{\sqrt{1-z^2}}=\frac1{1+z}\sqrt{\frac{1+z}{1-z}}\tag{5}
$$
on the same domain. Using $(4)$ and $(5)$, we can see that the integral of $g(z)$ counterclockwise around $[-1,1]$ is $2\pi i\cdot i=-2\pi$.
With $(5)$, we get that
$$
\lim_{\substack{z\to x\\\text{from above}}}g(z)=\frac1{\sqrt{1-x^2}}\tag{6}
$$
and
$$
\lim_{\substack{z\to x\\\text{from below}}}g(z)=-\frac1{\sqrt{1-x^2}}\tag{7}
$$
We will use the clockwise contour
$\hspace{3.4cm}$
Noting that $\left|\frac1{\sqrt{1-z^2}}\right|\sim\frac1{\sqrt{2|1-z|}}$ near $z=1$ and $\left|\frac1{\sqrt{1-z^2}}\right|\sim\frac1{\sqrt{2|1+z|}}$ near $z=-1$, the integral around the circular parts of the contour vanish. Then we get that
$$
2\int_{-1}^1\frac{\mathrm{d}x}{\sqrt{1-x^2}}=2\pi\tag{8}
$$
and therefore,
$$
\int_{-1}^1\frac{\mathrm{d}x}{\sqrt{1-x^2}}=\pi\tag{9}
$$
