<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] Another standard approach, set $t = x + \sqrt{x^2 +x -2}$, then
\begin{align*}
& (t -x)^2 = x^2 +x -2 \\
& t^2 -2tx = x -2 \\
& x = \frac{t^2 +2}{1 +2t} \\
& dx = 2\frac{t^2 +t -2}{(1 +2t)^2}dt \\
\end{align*}
moreover, express the square root in terms of $t$
\begin{align*}
\sqrt{x^2 +x -2} &= t - x = \\
& = t - \frac{t^2 +2}{1 +2t} = \\
& = \frac{t^2 +t -2}{1 +2t} \\
\end{align*}
Then
\begin{align*}
\int \sqrt{x^2 +x -2} \, dx &= \int \frac{t^2 +t -2}{1 +2t} \cdot 2\frac{t^2 +t -2}{(1 +2t)^2}dt = \\
&= 2\int \frac{(t^2 +t -2)^2}{(1 +2t)^3} dt = \\
&= \int \left(\frac{1}{4}t +\frac{1}{8} +\frac{81}{16}\cdot\frac{2}{(1 +2t)^3} -\frac{9}{8}\cdot\frac{2}{1 +2t} \right)dt = \\
&= \frac{1}{8}t^2 +\frac{1}{8}t -\frac{81}{32}\cdot\frac{1}{(1 +2t)^2} -\frac{9}{8}\log{(1 +2t)}  +C \\
\end{align*}
and this can be simplified, with some efforts, to
$$
\frac{1}{4}(2x+1)\sqrt{x^2+x-2} -\frac{9}{8}\log\left(2x+1+2\sqrt{x^2+x-2}\right) +C
$$
</s>