<s>[INST] Help Solve $\int \sqrt{x^{2}+x-2}\,dx$ I have this integral $\int \sqrt{x^{2}+x-2}\,dx=\int |x-1|\sqrt{\frac{x+2}{x-1}}\,dx$.
My textbook advices to use the substitution $t^{2}=\frac{x+2}{x-1}$.
Observation: This integral should be solvable without using integral of modules as it is placed before moduled function integrals chapter.
I did the substitution and i obtaind $-18\int \frac{{t^{2}}}{|(t^{2}-1)^{3}|}\,dt$ . At this point i thought that since the substitution has to be an invertible function, i may consider a restrinction to cancel the absolute value.
I checked on wolfram alpha both integrals but it gives different results. Wolfram solution:
$$\int \sqrt{(x^2 + x - 2)}\,dx = \frac14 (2 x + 1) \sqrt{(x^2 + x - 2)} - \frac98 \log\left(2 \sqrt{(x^2 + x - 2)} + 2 x + 1\right) + c$$
Any help?
The purpose of the exercise is to trasform the irrational function into a rational one and use the Hermite's equation to solve it
 [/INST] $$
\begin{aligned}
I &= \int{\sqrt{x^2 + x - 2}dx} = \int{\underbrace{\sqrt{x^2 + x - 2}}_{u}\underbrace{dx}_{dv}} = |\text{ integrating by parts }| = \\
&= x\sqrt{x^2+x-2}-\int{xd\sqrt{x^2+ x-2}} = \\
&= x\sqrt{x^2+x-2}-\int{x\frac{2x+1}{2\sqrt{x^2+x-2}}dx} = \\
&= x\sqrt{x^2+x-2}-\int{\frac{2\left(x^2+x-2\right)-\left(x-4\right)}{2\sqrt{x^2+x-2}}dx} = \\
&= x\sqrt{x^2+x-2}-\underbrace{\int{\sqrt{x^2+x-2}dx}}_{I} + \int{\frac{x-4}{2\sqrt{x^2+ x-2}}dx} \Leftrightarrow \\
2I &= x\sqrt{x^2+x-2} + \frac{1}{2}\underbrace{\int{\frac{2x+1}{2\sqrt{x^2+ x - 2}}dx}}_{\int{d\sqrt{x^2+ x-2}}=\sqrt{x^2+x-2}}-\frac{9}{4}\int{\frac{dx}{\sqrt{x^2+x-2}}} = \\
&= \left(x+\frac{1}{2}\right)\sqrt{x^2+x-2}-\frac{9}{4}\int{\frac{dx}{\sqrt{\left(x+\frac{1}{2}\right)^2-\frac{9}{4}}}} = \left|\text{ note that }dx = d\left(x+\frac{1}{2}\right)\right|=\\
&= \left(x+\frac{1}{2}\right)\sqrt{x^2+x-2}-\frac{9}{4}\int{\frac{d\left(x+\frac{1}{2}\right)}{\sqrt{\left(x+\frac{1}{2}\right)^2-\left(\frac{3}{2}\right)^2}}} = \left|\int{\frac{du}{\sqrt{u^2-a^2}}} = \ln\left|u+\sqrt{u^2-a^2}\right|\right|=\\
&= \left(x+\frac{1}{2}\right)\sqrt{x^2+x-2}-\frac{9}{4}\ln\left|\left(x+\frac{1}{2}\right)+\sqrt{\left(x+\frac{1}{2}\right)^2-\left(\frac{3}{2}\right)^2}\right| + C \Leftrightarrow \\
I &=\frac{1}{2}\left(x+\frac{1}{2}\right)\sqrt{x^2+x-2}-\frac{9}{8}\ln\left|\left(x+\frac{1}{2}\right)+\sqrt{x^2+x-2}\right| + C
\end{aligned}
$$
</s>