Showing that $\displaystyle\int_{-a}^{a} \frac{\sqrt{a^2-x^2}}{1+x^2}dx = \pi\left (\sqrt{a^2+1}-1\right)$.
How can I show that $\displaystyle\int_{-a}^{a} \frac{\sqrt{a^2-x^2}}{1+x^2}dx = \pi\left(\sqrt{a^2+1}-1\right)$?
Putting $x=a\sin\theta,dx=a\cos\theta d\theta$ and $x=\pm a,\theta=\pm\frac\pi2 $
$$\int_{-a}^{a} \frac{\sqrt{a^2-x^2}}{1+x^2}dx =\int _{-\frac\pi2}^{\frac\pi2}\frac{a^2\cos^2\theta}{1+a^2\sin^2\theta}d\theta$$ $$=\int _{-\frac\pi2}^{\frac\pi2}\frac{a^2\sec^2\theta}{(1+\tan^2\theta)(1+(a^2+1)\tan^2\theta)}d\theta$$ (Diving the numerator & the denominator by $\sec^4\theta$)
$$=\int _{-\infty}^{\infty}\frac{a^2}{(1+t^2)(1+(a^2+1)t^2)}dt$$ (Putting $\tan\theta = t$ as $\tan\theta=\pm\infty, t=\pm\frac\pi2$)
$$=\frac{a^2}{(a^2+1)}\int _{-\infty}^{\infty}\frac{1}{(1+t^2)(\frac1{(a^2+1)}+t^2)}dt$$
$$=\frac{\frac{a^2}{(a^2+1)}}{\left(1-\frac1{1+a^2}\right)}\left(\int _{-\infty}^{\infty}\frac1{(\frac1{(a^2+1)}+t^2)}dt-\int _{-\infty}^{\infty}\frac{1}{(1+t^2)}dt\right)$$ as $\frac1{(c+y)(b+y)}=\frac1{c-b}\frac{(c+y)-(b+y)}{(c+y)(b+y)}=\frac1{c-b}\left(\frac1{y+b}-\frac1{y+c}\right)$
$$=\left(\sqrt{1+a^2}\arctan (t\sqrt{1+a^2} )-\arctan t\right)_{-\infty}^{\infty}$$
So,$$\int_{-a}^{a} \frac{\sqrt{a^2-x^2}}{1+x^2}dx=(\sqrt{1+a^2}-1)\frac\pi2-\left\{-(\sqrt{1+a^2}-1)\frac\pi2\right\}=(\sqrt{1+a^2}-1)\pi$$
Observe that we have put $x=a\sin\theta$ and $\tan\theta = t\implies \left(\frac ax\right)^2- \left(\frac 1t\right)^2=\csc^2\theta-\cot^2\theta=1$
$\implies t^2=\frac{x^2}{a^2-x^2}\iff x^2=\frac{a^2t^2}{1+t^2}, a^2-x^2=\frac{a^2}{1+t^2}$
So, if we straight away take $t=\frac x{\sqrt{a^2-x^2}}$ (assuming $a>0$)
$$\frac{dt}{dx}=\frac1{\sqrt{a^2-x^2}}+x\left(\frac{-1}2\right)\frac1{(a^2-x^2)^{\frac32}}(-2x)=\frac{a^2}{(a^2-x^2)^{\frac32}}$$
$$\sqrt{a^2-x^2} dx=\frac{(a^2-x^2)^2dt}{a^2}=\frac{a^2dt}{(1+t^2)^2}$$
and if $x=\pm a,t=\frac{\pm a}0=\pm\infty$
So, $$\int_{-a}^{a} \frac{\sqrt{a^2-x^2}}{1+x^2}dx$$ becomes $$\int _{-\infty}^{\infty}\frac{a^2}{(1+t^2)(1+(a^2+1)t^2)}dt$$
$\newcommand{\Res}{\operatorname{Res}}$ Since the question was tagged complex-analysis, and nobody has given a solutions with purely complex methods, here goes.
Let $$ f(z) = \frac{(a^2-z^2)^{1/2}}{1+z^2}, $$ where $(a^2-z^2)^{1/2}$ denotes branch that is holomorphic on $\mathbb{C} \setminus [-a,a]$. (See this question for details.)
Next, let $\Gamma$ be a "dog bone" contour together with a large circle:
and integrate $f$ along $\Gamma$. On the "top" part of $[-a,a]$ we get the integral that we want. On the "bottom" part, the square root will pick up a minus sign from the branch cut and another minus sign from the orientation. It's straight forward to check that the integrals over the small circles tend to $0$ as their radii tend to $0$, and the integral over the large circle is basically the residue of $f$ at $\infty$. More precisely, by the residue theorem
\begin{align} 2\int_{-a}^a \frac{\sqrt{a^2-x^2}}{x^2+1}\,dx &= 2\pi i( \Res(f;i) + \Res(f;-i) - \Res(f;\infty)) \\ &= 2\pi i \bigg( \frac{\sqrt{a^2+1}}{2i} + \frac{-\sqrt{a^2+1}}{-2i} + i\bigg) \end{align}
which simplifies to the stated equality. (Note that $\Res(f;\infty) = \Res(-\dfrac1{z^2}f(\dfrac1z);0)$.)
A slight variant of lab bhattacharjee's method provides a simpler solution:
Let
$$ I(a) = \int_{-a}^{a} \frac{\sqrt{a^2-x^2}}{1+x^2} \, dx = 2\int_{0}^{a} \frac{\sqrt{a^2-x^2}}{1+x^2} \, dx. $$
Then by a simple application of multivariable calculus,
\begin{align*} I'(a) &= 2 \left. \frac{\sqrt{a^2-x^2}}{1+x^2} \right|_{x=a} + 2 \int_{0}^{a} \frac{d}{da} \frac{\sqrt{a^2-x^2}}{1+x^2} \, dx \\ &= 2 \int_{0}^{a} \frac{a}{(1+x^2)\sqrt{a^2-x^2}} \, dx. \end{align*}
Then with the change of variable $x = a \sin\theta$, we have
\begin{align*} I'(a) &= 2 \int_{0}^{\frac{\pi}{2}} \frac{a}{1+a^2\sin^2\theta} \, d\theta \\ &= 2 \int_{0}^{\frac{\pi}{2}} \frac{a \sec^2\theta}{1+(a^2+1)\tan^2\theta} \, d\theta \\ &= 2 \int_{0}^{\infty} \frac{a}{1+(a^2+1)t^2} \, dt \qquad (t = \tan\theta) \\ &= \frac{\pi a}{\sqrt{a^2+1}}. \end{align*}
Thus by integrating, we must have
$$ I(a) = \pi\sqrt{a^2+1} + C $$
for some constant $C$. But
$$ I(0+) = \lim_{a\to0} \int_{-a}^{a} \frac{\sqrt{a^2-x^2}}{1+x^2} \, dx = \lim_{a\to0} \int_{-1}^{1} \frac{\sqrt{1-x^2}}{(1/a)^2+x^2} \, dx = 0 $$
and we must have $C = -\pi$. This proves the identity.