Integral with branch cut ( Problem while calculating residue) While calculating this integral $\int_{-1}^{1}\frac{dx}{\sqrt{1-x^2}(1+x^2)}$ , I am really struggling to calculate the residue at (-i), I am getting the value of residue as $\frac{-1}{2\sqrt{2}i}$, but for the value of residue is $\frac{1}{2\sqrt{2}i}$ with no minus sign in it. Now, what I might have been doing wrong since I used $\frac{1}{\sqrt{2}(1+(e^{i.3\pi/2})^2}$. I think I might have been doing some wrong in branch cut. Help me to figure it out.
 A: The easier way is to rely on real analysis. Let $x=\sin(t)$. We then have the integral to be
\begin{align}
I & = \int_{-\pi/2}^{\pi/2} \dfrac{\cos(t)dt}{\cos(t) (1+\sin^2(t))}\\
& = \int_{-\pi/2}^{\pi/2} \dfrac{dt}{1+\sin^2(t)}\\
& = \sum_{k=0}^{\infty}(-1)^k \int_{-\pi/2}^{\pi/2} \sin^{2k}(t)dt\\
& = 2\sum_{k=0}^{\infty}(-1)^k \dfrac{\pi}{2^{2k+1}} \dbinom{2k}k\\
& = \pi \sum_{k=0}^{\infty} \left(-\dfrac14\right)^k \dbinom{2k}k
\end{align}
We have
$$\sum_{k=0}^{\infty} x^k \dbinom{2k}k = \dfrac1{\sqrt{1-4x}} \text{ for }-1/4\leq x < 1/4$$
Hence,
$$I = \dfrac{\pi}{\sqrt2}$$
A: What you need here is a dog bone contour.

Let $\Gamma$ be the circular contour and $\gamma$ be the dog bone. On the bottom part of the dog bone, we get the negative of the square root and a negative for the direction.
\begin{align}
2\int_{-1}^1\frac{dz}{(z^2+1)\sqrt{1-z^2}} &= 2\pi i\sum\text{Res}\\
\int_{-1}^1\frac{dz}{(z^2+1)\sqrt{1-z^2}} &= \pi i\sum\text{Res}
\end{align}
where the residues are at $z=\pm i$. By the estimation lemma (see your other post on branch cuts), as $\epsilon\to 0$, the integration of the small circles go to zero and the integral of $\Gamma$ is zero as $R\to\infty$. Now evaluate the residues and you are done.

Edit:
To add some detail, (u line is the upper line of the dog bone and l line is the lower line)
\begin{align}
\int_{-1}^1\frac{dz}{(z^2+1)\sqrt{1-z^2}} &= \int_{\Gamma}fdz + \int_{\gamma_1}fdz + \int_{\gamma_2}fdz + \int_{\text{u line}}fdz - \int_{\text{l line}}fdz\tag{1}\\
&= \int_{\text{u line}}f(z)dz + \int_{\text{l line}}f(z)dz\tag{2}\\
2\int_{-1}^1\frac{dz}{(z^2+1)\sqrt{1-z^2}} &= 2\pi i\sum\text{Res}\\
\int_{-1}^1\frac{dz}{(z^2+1)\sqrt{1-z^2}} &= \pi i\sum\text{Res}\\
&= \pi i\biggl[\lim_{z\to i}\frac{(z-i)}{(z^2+1)\sqrt{1-z^2}} - \lim_{z\to  -i}\frac{(z+i)}{(z^2+1)\sqrt{1-z^2}}\biggr]
\end{align}
The last integral in (1) is subtracted since we pick up the negative from the square root in the lower half. In (2), the integral is now positive due to the negative from the direction of motion. As $R\to\infty$, $\int_{\Gamma}\to 0$, and as $\epsilon\to 0$, $\int_{\gamma_1,\gamma_2}\to 0$.
A: We will do the residue  calculation since it is necessary to conclude on
this problem.
Suppose we seek to compute
$$Q = \int_{-1}^{+1} \frac{dx}{\sqrt{1-x^2}(1+x^2)}.$$
Re-write this as
$$\int_{-1}^{+1} 
\exp(-1/2\mathrm{LogA}(1+z))
\exp(-1/2\mathrm{LogB}(1-z))
\frac{1}{1+z^2} dz$$
and call the function $f(z).$
We  must choose  two  branches of  the  logarithm $\mathrm{LogA}$  and
$\mathrm{LogB}$ so that the cut is on the real axis from $-1$ to $+1.$
This is accomplished when $\mathrm{LogA}$  has the cut on the negative
real axis and $\mathrm{LogB}$ on the positive real axis. The poles are
simple  so to  compute the  residues we  merely need  to  evaluate the
logarithms at these two points.

For the first one at $\rho_0=i$ we put $$1+i = \sqrt{2} e^{1/4\pi i}$$
and $$1-i = \sqrt{2} e^{7/4\pi i}$$ to get the residue
$$\frac{1}{2i}
\exp(-1/2\times \log\sqrt{2} -1/2\times 1/4\pi i)
\exp(-1/2\times \log\sqrt{2} -1/2\times 7/4\pi i)
\\ = \frac{1}{2i} 
\exp(-\log\sqrt{2} - \pi i)
= - \frac{1}{2i\sqrt{2}}.$$

For  the  second  one  at  $\rho_1=-i$  we  put  $$1+(-i)  =  \sqrt{2}
e^{-1/4\pi  i}$$ and  $$1-(-i) =  \sqrt{2} e^{1/4\pi  i}$$ to  get the
residue
$$-\frac{1}{2i}
\exp(-1/2\times \log\sqrt{2} +1/2\times 1/4\pi i)
\exp(-1/2\times \log\sqrt{2} -1/2\times 1/4\pi i)
\\ = - \frac{1}{2i} 
\exp(-\log\sqrt{2})
= - \frac{1}{2i\sqrt{2}}.$$
Now  using  the dogbone  contour  shown  in  the accepted  answer  and
traversed  counterclockwise we  pick  up $2Q.$  This  is because  for
$x\in(-1,1)$ we get above the cut the value
$$\exp(-1/2\log (1+x))\exp(-1/2\log (1-x) -1/2\times 2\pi i)
= - \frac{1}{\sqrt{1-x^2}}$$
and below the cut
$$\exp(-1/2\log (1+x))\exp(-1/2\log (1-x))
= \frac{1}{\sqrt{1-x^2}}.$$
Therefore
$$ 2Q= -2\pi i
\left(\mathrm{Res}_{z=i} f(z)
+ \mathrm{Res}_{z=-i} f(z)
+ \mathrm{Res}_{z=\infty} f(z)\right).$$
The residue at infinity is zero because $f(z)$ is $O(1/R^3)$ on the circle.

This gives
$$2Q = - 2\pi i
\left(- \frac{1}{2i\sqrt{2}} - \frac{1}{2i\sqrt{2}}\right)
= \pi \frac{2}{\sqrt{2}}
\quad\text{or}\quad 
Q = \frac{\pi}{\sqrt{2}}.$$
In order to be rigorous we also need to show continuity across the two overlapping cuts on $(-\infty, -1)$ as shown in this MSE link.
Remark. It really helps to think of the map from $z$ to $-z$ as a $180$ degree rotation when one tries to visualize what is happening here.
