<s>[INST] 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?
 [/INST] $$\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$$
</s>