Compute difficult integral $\int \frac{dx}{2 + x + \sqrt{1 - x^2}}$ To solve the integral
$$I = \int \frac{dx}{2 + x + \sqrt{1 - x^2}}$$
I have tried several things, such as $t = \arcsin x$, because $\cos(\arcsin x) = \sqrt{1 - x^2}$. If I am not wrong, we can conclude with this variable change
$$
I = \int \frac{\cos t\,dt}{2 + \sin t + \cos t}
$$
but if it were correct, how could I go on?
 A: $$\int\frac{dx}{2+x+\sqrt{1-x^2}}$$
Substitute $x= \sin 2u;\;dx=2\cos 2u$
$$\int \frac{2\cos (2 u)}{2+\sin (2 u)+\cos (2 u)} \, du$$
$$\int \frac{2\cos ^2 u-2\sin ^2 u}{2-\sin ^2 u+\cos ^2 u+2 \sin u \cos u}\,du$$
$$\int \frac{2\cos ^2 u-2\sin ^2 u}{\sin ^2 u+3 \cos ^2 u+2 \sin u \cos u}\,du$$
divide numerator and denominator by $\cos^2 u$
$$\int \frac{2-2\tan ^2 u}{\tan ^2 u +2 \tan u +3}\,du$$
substitute $\tan u = t\to dt=\frac{du}{1+u^2}$
$$\int \frac{2-2t^2}{\left(t^2+1\right) \left(t^2+2 t+3\right)}\,dt$$
using partial fraction
$$\int \left(\frac{1-t}{t^2+1}+\frac{t-1}{t^2+2 t+3}\right)\,dt$$
$$\frac{1}{2} \left(-\log \left(t^2+1\right)+\log \left(t^2+2 t+3\right)+2 \arctan t-2 \sqrt{2} \arctan\left(\frac{t+1}{\sqrt{2}}\right)\right)+C$$
$t=\tan u$ and $x=\sin 2u$ we have $t=\frac{1-\sqrt{1-x^2}}{x}$
$$\frac{1}{2} \log \left(\sqrt{1-x^2}+x+2\right)+\arctan\left(\frac{1-\sqrt{1-x^2}}{x}\right)-\sqrt{2} \arctan\left(\frac{-\sqrt{1-x^2}+x+1}{\sqrt{2} x}\right)+C$$
A: Bioche's rules say you should set  $\;u=\tan \frac t2,\enspace \mathrm du=\frac12(1+u^2)\,\mathrm dt$, whence the integral of a rational function
$$\int\frac{2(1-u^2)\,\mathrm du}{(1+u^2)(u^2+2u+3)},$$
which is easily calculated using partial fractions decomposition.
Some more details: using the half angle formulæ, we get
\begin{align}
\frac{\cos t}{2 + \sin t + \cos t}\,\mathrm dt&=\frac{\cfrac{1-u^2}{1+u^2}}{2+\cfrac{2u}{1+u^2}+\cfrac{1-u^2}{1+u^2}}\,\frac{2\,\mathrm du}{1+u^2} \\
&=\frac{2(1-u^2)}{(1+u^2)\bigl(2(1+u^2)+2u+1-u^2\bigr)} \\
&=\frac{2(1-u^2)}{(1+u^2)\bigl(u^2+2u+3\bigr)}. \\
\end{align}
A: Continue with $x=\sin t$
\begin{align}
&\int \frac{1}{2 + x + \sqrt{1 - x^2}} dx=\int \frac{\cos t}{2 + \sin t + \cos t}dt\\
= &\ \frac12\int \left(1+ \frac{\cos t-\sin t}{2 + \sin t + \cos t}-
\frac{2}{2 + \sin t + \cos t} \right)dt\\
=& \ \frac12t +\frac12 \ln(2 + \sin t + \cos t) -\sqrt2\tan^{-1} \frac{\tan\frac t2+1}{\sqrt2}\\
=&\ \frac12\sin^{-1}x+\frac12 \ln\left(2 + x+ \sqrt{1-x^2}\right) -\sqrt2\tan^{-1} \frac{1+x-\sqrt{1-x^2}}{x \sqrt2}
\end{align}
A: Use Euler substitution
$$tx-1=\sqrt{1-x^2}$$
$$t=\frac{1+\sqrt{1-x^2}}{x}$$
$$x=\frac{2t}{t^2+1}$$
$$dx=\frac{2(1-t^2)}{(t^2+1)^2}dt$$
$$\int \frac{dx}{2+x+\sqrt{1-x^2}}=\int\frac{1}{2+(t+1)\frac{2t}{t^2+1}-1}\frac{2(1-t^2)}{(t^2+1)^2}dt=\int\frac{2(1-t^2)dt}{(3t^2+2t+1)(t^2+1)}$$$$=-\int\frac{t+1}{t^2+1}dt+\frac{1}{2}\int\frac{6t+2}{3t^2+2t+1}dt+\frac{2}{3}\int\frac{dt}{(t+\frac{1}{3})^2+\frac{2}{9}}$$$$=-\frac{1}{2}\ln(t^2+1)-\arctan(t)+\frac{1}{2}\ln(3t^2+2t+1)+\frac{2}{3}\frac{1}{\frac{2}{9}}\arctan\left(\frac{t+\frac{1}{3}}{\frac{2}{9}}\right)+C$$
$$=\frac{1}{2}\ln\left(\frac{3t^2+2t+1}{t^2+1}\right)-\arctan(t)+3\arctan\left(\frac{9t+3}{2}\right)+C$$
where $t=\frac{1+\sqrt{1-x^2}}{x}$
A: Using @Bernard solution
$$y=\frac{2(1-u^2)}{(1+u^2)\bigl(u^2+2u+3\bigr)}$$ using partial fractions
$$y=-\frac{1+i}{2(u-i)}-\frac{1-i}{2 (u+ i)}+\frac{\sqrt{2}+2 i}{2 \left(\sqrt{2} u+\sqrt{2}-2 i\right)}+\frac{\sqrt{2}-2 i}{2 \left(\sqrt{2} u+\sqrt{2}+2 i\right)}$$
$$\int y\,du=\left(-\frac{1}{2}-\frac{i}{2}\right) \log (-2 u+2 i)\left(-\frac{1}{2}+\frac{i}{2}\right) \log (2 u+2 i)+$$
$$\frac{\left(\sqrt{2}+2 i\right) \log \left(\sqrt{2} u+\sqrt{2}-2 i\right)}{2
   \sqrt{2}}+\frac{\left(\sqrt{2}-2 i\right) \log \left(\sqrt{2} u+\sqrt{2}+2 i\right)}{2
   \sqrt{2}}$$
Now, recombining everything
$$\int y\,du=\tan ^{-1}(u)-\sqrt{2} \tan ^{-1}\left(\frac{u+1}{\sqrt{2}}\right)+\frac 12 \log \left(\frac{u^2+2 u+3}{u^2+1}\right)$$
