Solve the following integral: $ \int \frac{x^2}{x^2+x-2} dx $ Solve the integral: $ \int \frac{x^2}{x^2+x-2} dx $
I was hoping that writing it in the form $ \int 1 - \frac{x-2}{x^2+x-2} dx $ would help but I'm still not getting anywhere.
In the example it was re-written as $ \int 1 - \frac{4}{3x+6} - \frac{1}{3x-3} dx $
but I am not sure how this was accomplished. Any ideas? I am more interested in the method than the answer.
 A: Since $x^2+x-2 = (x-1)(x+2)$, we can use partial fraction decomposition:
$$\frac{x-2}{x^2+x-2} = \frac{A}{x-1} + \frac{B}{x+2}.$$
Then $x-2 = A(x+2) + B(x-1)$.
Equating the coefficients of each power of $x$, we have that $1=A+B$, and $-2=2A-B$.
Solving for $A$ and $B$ decomposes our original rational expression into two simple fractions.
A: Hint: you can divide the numerator with the denominator and rewrite the integral in this way: $$\int q(x)+\int D(x)/R(x)$$
A: when you get the $\int 1 - \frac{x-2}{x^2+x-2} dx$, you can use  $x^2+x-2 = (x-1)(x+2)$.
then it become
$$
\int 1 - \frac{x+2-4}{(x+2)(x-1)}dx
$$
which equal to 
$$
\int 1 - \frac{1}{x-1}-\frac{4}{(x+2)(x-1)}dx
$$
$$
\int 1 - \frac{1}{x-1}-4/3(\frac{1}{(x-1)}+\frac{1}{(x+2)})dx
$$
A: While partial fraction expansion is certainly the natural choice, here is a slightly different approach that continues from the OP's attempt.
$$\begin{align}
\frac{x^2}{x^2+x-2}&=1-\frac{x-2}{x^2+x-2}\\\\
&=1-\frac12 \frac{2x-4}{x^2+x-2}\\\\
&=1-\frac12 \frac{2x+1-5}{x^2+x-2}\\\\
&1-\frac12 \frac{2x+1}{x^2+x-2}+ \frac{5/2}{x^2+x-2}\\\\
&=1-\frac12 \frac{2x+1}{x^2+x-2}+ \frac{5/2}{(x+1/2)^2-(3/2)^2}
\end{align}$$
Now, the first term is trivial to integrate.  The second term is a perfect differential since the numerator is the derivative of the denominator.  And the last term is set up for a hyperbolic trigonometric substitution.
