<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] First, reduce to a simpler square root
\begin{align*}
\int \sqrt{x^2+x-2} dx &= \int \sqrt{\left(x+\frac{1}{2}\right)^2-\frac{9}{4}} \,dx = \\
&= \frac{3}{2}\int \sqrt{\frac{4}{9}\left(x+\frac{1}{2}\right)^2-1} \,dx = \\
&= \frac{3}{2}\int \sqrt{\left(\frac{2}{3}x+\frac{1}{3}\right)^2-1} \,dx = \\
&= \frac{9}{4}\int \sqrt{t^2-1} \,dt
\end{align*}
Then use this know result
\begin{align*}
I = \int \sqrt{t^2-1} \,dt &= t\sqrt{t^2-1} -\int t\frac{2t}{2\sqrt{t^2-1}} \,dt = \\
&= t\sqrt{t^2-1} -\int \frac{t^2-1+1}{\sqrt{t^2-1}} \,dt = \\
&= t\sqrt{t^2-1} -\int \sqrt{t^2-1} \,dt -\int \frac{1}{\sqrt{t^2-1}} \,dt= \\
&= t\sqrt{t^2-1} -\int \sqrt{t^2-1} \,dt -\operatorname{arccosh} t = \\
&= t\sqrt{t^2-1} -I -\operatorname{arccosh} t
\end{align*}
from which
\begin{align*}
I = \int \sqrt{t^2-1} \,dt &= \frac{1}{2}t\sqrt{t^2-1} -\frac{1}{2}\operatorname{arccosh} t +C = \\
&= \frac{1}{2}t\sqrt{t^2-1} -\frac{1}{2}\log\left(t+\sqrt{t^2-1}\right) +C
\end{align*}
Then come back to the original integral
\begin{align*}
& \int \sqrt{x^2+x-2} dx = \frac{9}{4}\int \sqrt{t^2-1} \,dt = \\
& \qquad = \frac{9}{8}t\sqrt{t^2-1} -\frac{9}{8}\log\left(t+\sqrt{t^2-1}\right) +C = \\
& \qquad = \frac{9}{8}\left(\frac{2}{3}x+\frac{1}{3}\right)\sqrt{\left(\frac{2}{3}x+\frac{1}{3}\right)^2-1} -\frac{9}{8}\log\left(\left(\frac{2}{3}x+\frac{1}{3}\right)+\sqrt{\left(\frac{2}{3}x+\frac{1}{3}\right)^2-1}\right) +C = \\
& \qquad = \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 \\
\end{align*}
</s>