How to integrate $\int_{-1}^1 \tan^{-1}\left(\frac{1}{\sqrt{1-x^2}}\right )\,dx$?

$$\begin{eqnarray*}\int_{-1}^{1}\arctan\left(\frac{1}{\sqrt{1-x^2}}\right)\,dx &=& \pi-2\int_{0}^{1}\arctan(\sqrt{1-x^2})\\&=&\pi-2\int_{0}^{\pi/2}\cos(\theta)\arctan(\cos\theta)\,d\theta\\&=&\pi-2\int_{0}^{\pi/2}\frac{\sin(\theta)^2}{1+\cos^2\theta}\,d\theta\\&=&\pi-2\int_{0}^{+\infty}\frac{t^2\,dt}{(1+t^2)(2+t^2)}\\&=&\pi-2\int_{0}^{+\infty}\left(\frac{2}{t^2+2}-\frac{1}{t^2+1}\right)\,dt\\&=&\color{red}{(2-\sqrt{2})\pi}.\end{eqnarray*}$$ Steps involved:

  • $\arctan\frac{1}{t}=\frac{\pi}{2}-\arctan t$
  • substitution $x=\sin\theta$
  • integration by parts
  • substitution $\theta=\arctan t$
  • partial fraction decomposition
  • profit.

First, integrate by parts to reduce the problem to calculating $$\int \frac{x^2}{\sqrt{1-x^2}(2-x^2)}\,dx.$$ now split into two more manageable terms $$\int \frac{2}{\sqrt{1-x^2}(2-x^2)}\,dx + \int \frac{x^2-2}{\sqrt{1-x^2}(2-x^2)}\,dx.$$ The left term is the only tricky one. Substitute $x= \sin u$ to get rid of the square root $$\int \frac{2}{2-\sin^2 u}\,du = \int \frac{2}{2\cos^2 u+\sin^2 u}\,du = \int \frac{2\sec^2 u}{2+\tan^2 u}\,du$$ and finally substitute $v = \frac{\tan u}{\sqrt{2}}$.