Finding a mistake in the result $\int_{-1}^1 \frac{dz}{\sqrt{1-z^2}(2+z)}=0$ earned by contour integral We want to compue $I=\int_{-1}^1 \frac{dz}{\sqrt{1-z^2}(2+z)}$, so we consider the following countor integral. Since there is a branch cut $(-1,1)$, if we take the contour $C$ (resembling the image below, ignoring the captions)

around this cut wrapping around $z=1$ with a small circle of radius $\epsilon$ and extending to the left and closing up in the $z\rightarrow \infty$, we end up in (since the contour does not include the simple pole at $-2$)
$$\oint_C \frac{dz}{\sqrt{1-z^2}(2+z)}=2I=0$$
However, $I$ is definitely not zero. What's wrong here? Is it correct to think that $(-\infty, -1)$ part does not cancel due to divergence near $-2$?
 A: Indeed, choose the branch of $\sqrt{1-z^2}$ so that its branch cut is $[-1,1]$. For example, we may let
$$\sqrt{1-z^2} = \exp\left(\frac{1}{2}\log(z-1)+\frac{1}{2}\log(z+1) - \frac{i\pi}{2}\right),$$
where $\log(\cdot)$ is the principal complex logarithm. Then for $-1 < x < 1$,
\begin{align*}
\lim_{\epsilon \to 0^+} \sqrt{1-(x+i\epsilon)^2} &= \sqrt{1-x^2} \\
\lim_{\epsilon \to 0^+} \sqrt{1-(x-i\epsilon)^2} &= -\sqrt{1-x^2},
\end{align*}
So, the integral of $ f(z) = \frac{1}{(z+2)\sqrt{1-z^2}} $ along the dog bone contour (red contour in the image below)

is $2I$:
$$ \oint_{\color{red}{\text{dogbone}}} f(z) \, \mathrm{d}z = 2I. $$
So, if $R > 2$ and $\epsilon > 0$ is small enough, then
\begin{align*}
\oint_{|z| = R} f(z) \, \mathrm{d}z
&= \oint_{|z+2| = \epsilon} f(z) \, \mathrm{d}z + \oint_{\color{red}{-\text{dogbone}}} f(z) \, \mathrm{d}z \\
&= 2\pi i \, \underset{z=-2}{\mathrm{Res}} \, f(z) - \oint_{\color{red}{\text{dogbone}}} f(z) \, \mathrm{d}z \\
&= \frac{2\pi}{\sqrt{3}} - 2I
\end{align*}
As you see, you first forgot to take account of the pole of $f(z)$ at $z=-2$. When its contribution is properly accounted as in the computation above, then by using that
$$ \oint_{|z| = R} f(z) \, \mathrm{d}z
= \lim_{R\to\infty} \oint_{|z| = R} f(z) \, \mathrm{d}z
= 0, $$
we end up with
$$ I = \frac{\pi}{\sqrt{3}}. $$
