I want to integrate $$\int \frac{dx}{x^2 + 1 + x\sqrt{x^2+2}}$$ and I get that I need to do a variable substitution. But how do I know what to substitute and for what? I can guess that I should substitute $\sqrt{x^2+2}$ but for what? Usually I would go for $t$ but in this case it looks like $t-x$ or something like that are more correct.
Substituting to $t-x$ gives $\int \frac{t^2+2}{t^4+6t^2+4}$ which I believe is wrong because the answer does not consist of any logaritms.
=Edit= And in any case, what's wrong with the solution (t-x) I tried. It gives me a perfectly solvable integral, but it's still wrong, why?
=Edit 2= Still haven't managed to solve this.
$\int \frac{1}{x^2+x+x\sqrt{x^2+2}} = \left[\sqrt{x^2+2} = t - x, x = \frac{t^2-2}{2t}, \frac{dx}{dt} = \frac{t^2+2}{2t^2}, \sqrt{x^2+2} = \frac{t^2-2}{2t} \right] = \int \frac{1}{\left(\frac{t^2-2}{2t} \right)^2+1+\left(\frac{t^2-2}{2t} \right)^2}\times \frac{t^2+2}{2t^2} dt = \int \frac{t^2+2}{t^4-2t^2+4} dt$
This is going in the wrong direction since I know that the answer should be $\frac{1}{2}\left(x - \sqrt{x^2+2} - \frac{1}{6}\left(\sqrt{x^2+2}-x\right)^3\right)$ or $-\frac{1}{x+\sqrt{x^2+2}} - \frac{2}{3(x + \sqrt{x^2+2}^3}$
Note that $$\int\frac{dx}{x^2+1+x\sqrt{x^2+2}}=\int\frac{2dx}{(x+\sqrt{x^2+2})^2}$$
Use the substitution $$y=x+\sqrt{x^2+2}$$
So $$(y-x)^2=x^2-2\Rightarrow x=\frac{y^2-2}{2y}$$
and $$\frac{dy}{dx}=1+\frac{x}{\sqrt{x^2+2}}=\frac{x+\sqrt{x^2+2}}{\sqrt{x^2+2}}=\frac{y}{\sqrt{\left(\frac{y^2-2}{2y}\right)^2+2}}=\frac{2y^2}{y^2+2}$$ Thus we have $$\frac{dx}{dy}=\frac{y^2+2}{2y^2}$$
This leads to the integral being $$\int\frac{2dx}{(x+\sqrt{x^2+2})^2}=\int\frac{2(y^2+2)dy}{2y^2(y^2)}=\int\frac{dy}{y^2}+2\int\frac{dy}{y^4}\\=-\frac{1}{y}-\frac{2}{3y^3}$$
Subtituting $x$ back in, we end up with $$\int\frac{dx}{x^2+1+x\sqrt{x^2+2}}=\int\frac{2dx}{(x+\sqrt{x^2+2})^2}=-\frac{1}{x+\sqrt{x^2+2}}-\frac{2}{3(x+\sqrt{x^2+2})^3}$$