computing $\int _{-1}^1\:\frac{\sqrt{1-x^2}}{x^2+1}$ using residue calculus How can I compute the following integral using residue calculus? I can't seem to compute it since the singularity point is on the contour boundary... 
 A: Let $I$ be the integral given by
$$I=\int_{-1}^1 \frac{\sqrt{1-x^2}}{1+x^2}\,dx \tag1$$

To evaluate $(1)$ using complex analysis, we will analyze the integral $J$
$$J=\int_C \frac{\sqrt{1-z^2}}{1+z^2}\,dz \tag2$$
where $C$ is the classical "dog-bone contour."  (See other examples here and here for a primer with details).
We will cut the plane from $-1$ to $1$ such that
$$\sqrt{1-z^2}=-i\sqrt{z-1}\sqrt{z+1}$$
with $-\pi <\arg(z-1)\le \pi$ and $-\pi <\arg(z+1)\le \pi$.
Note that on $\mathbb{C}\setminus [-1,1]$, $f(z)$ is meromorphic  with poles at $z=\pm i$.
Then, using the Residue Theorem and Cauchy's Integral Theorem, we can write $(2)$ as
$$\begin{align}
J&=2\int_{-1}^{1}\frac{\sqrt{1-x^2}}{1+x^2}\,dx\\\\
&=2\pi i\text{Res}\left(\frac{\sqrt{1-z^2}}{1+z^2}, z=\pm i\right) -\int_0^{2\pi}\frac{\sqrt{1-R^2e^{i2\phi}}}{1+R^2e^{i2\phi}}\,iRe^{i\phi}\,d\phi\tag 3
\end{align}$$
where we the contributions from the integrals around the "small" circular contours centered at $\pm1$ vanish as their radii approach $0$.

The residues at $z=i$ and $z=-i$ are equal and given by
$$\text{Res}\left(\frac{\sqrt{1-z^2}}{1+z^2}, z=\pm i\right)=\frac{\sqrt{2}}{2i}$$

The integral over $\phi$ as $R\to \infty$ becomes (note that this is equivalent to $2\pi i$ times the residue at infinity)
$$\lim_{R\to \infty}\int_0^{2\pi}\frac{\sqrt{1-R^2e^{i2\phi}}}{1+R^2e^{i2\phi}}\,iRe^{i\phi}\,d\phi=-i2\pi $$

Putting it all together we see that
$$\begin{align}
2\int_{-1}^{1}\frac{\sqrt{1-x^2}}{1+x^2}\,dx&=2\pi i \frac{2\sqrt 2}{2i}-2\pi\\\\
&=2\pi (\sqrt 2-1)
\end{align}$$
whereupon dividing by $2$ yields the coveted integral

$$I=\pi(\sqrt 2-1)$$

