Solving indefinite integral $\int \frac{1+\sqrt{1+x^2}}{x^2+\sqrt{1+x^2}}dx$ How can we solve this integration?
$$\int \frac{1+\sqrt{1+x^2}}{x^2+\sqrt{1+x^2}}dx$$
I tried to make the following substitution
$$1+x^2=w^2$$
but this substitution complicated the integral.
 A: Let $x=\tan u$ 
$$\int \frac{\sec^2u+\sec^3u}{\tan^2u+\sec u}$$
$$\int \frac{\sec^2u+\sec u \tan^2 u +\sec u}{\tan^2u+\sec u}$$
First two terms cancel with the denominator the third term and the denominator think about it 
A: Like the answer of @AmerYR, taking $1+x^2=u^2$
$$I=\int \frac{1+\sqrt{1+x^2}}{x^2+\sqrt{1+x^2}} dx= \int \sec u ~du + \int \frac{sec u}{\tan^2 u+ sec u} du$$ $$ \implies I =\log (\tan u+ sec~ u)+J(u)$$
Next, using $\sin u=\frac{2 \tan(u/2)}{1+\tan^(u/2)},~~ \cos u= \frac{1-\tan^(u/2)}{1+\tan^2(u/2)}$ and $t=\tan(u/2), dt= sec^2 (u/2) du/2$, we get
$$J=\int \frac{\cos u ~du} {\sin^2 u + \cos u}= \frac{(1-t^2)/(1+t^2)}{4t^2/(1+t^2)^2+(1-t^2)/(1+t^2)} \frac{2dt}{(1+t^2)}$$
$$\implies J= 2 \int \frac{t^2-1}{t^4-4t^2-1} dt= 2 \int \frac{t^2-1}{(t^2+a^2)(t^2-b^2)}  dt = 2 \int \left(\frac{A}{t^2-a^2} + \frac{B}{t^2+b^2} \right) dt$$
$$\implies 2 \left(\frac{A}{2a} \log \frac{t-a}{t+a} + \frac{B}{b} \tan^{-1} \frac{t}{b} \right) +C$$
Here $a=\sqrt{2+\sqrt{5}}, b=\sqrt{\sqrt{5}-2}$, $A=\frac{\sqrt{5}+1}{2\sqrt{5}}$, $B=\frac{\sqrt{5}-1}{2\sqrt{5}}.$
A: Substitute $x=\sinh u$,
$$I=\int \frac{1+\sqrt{1+x^2}}{x^2+\sqrt{1+x^2}}dx=
\int \frac{\cosh u+\cosh^2 u}{\cosh^2 u+\cosh u - 1}du = u+I_1$$
where,
$$I_1=\int \frac{du}{\cosh^2 u+\cosh u-1}$$
Next, use the substitution $\cosh u = \frac{1+t^2}{1-t^2}$, along with $d u = \frac{2dt}{1-t^2}$,
$$I_1=2\int \frac{t^2-1}{t^4-4t^2-1}dt$$
$$=\frac{1}{\sqrt5}\int\left( \frac{\sqrt5+1}{t^2+\sqrt5-2}+\frac{\sqrt5-1}{t^2-\sqrt5-2}\right)dt$$
$$=\sqrt{\frac25}\sqrt{\sqrt5+1}\tan^{-1}\left(\sqrt{\sqrt5+2}\>t\right)
- \sqrt{\frac25}\sqrt{\sqrt5-1}\tanh^{-1}\left(\sqrt{\sqrt5-2}\>t\right)$$
Thus, the solution is,
$$I= \sinh^{-1}x +
\sqrt{\frac25(\sqrt5+1)}\tan^{-1}\left(\sqrt{\sqrt5+2}\>t\right)
-\sqrt{\frac25(\sqrt5-1)}\tanh^{-1}\left(\sqrt{\sqrt5-2}\>t\right)$$
where,
$$t= \left(\frac{\cosh u-1}{\cosh u+1}\right)^{\frac12} 
= \left(\frac{\sqrt{1+x^2}-1}{\sqrt{1+x^2}+1}\right)^{\frac12}$$
