# Help me with this mock-long-division $\frac{-x+2}{x^{2}+x-2}=\frac{-4}{3(x+2)}+\frac{1}{3(x-1)}$

$$\frac{-x+2}{x^{2}+x-2}=\frac{-4}{3(x+2)}+\frac{1}{3(x-1)}$$

Wolphram Alpha states that one can do this with long division, I cannot immediately realize it. Could someone show the trick to simplify the LHD to RHD?

Context: Trying to compute $$\int \frac{x^2}{x^2+x-2}\,dx$$

-
This is called "partial fraction decomposition", not "mock-long-division". You can verify it by performing the operation on the right hand side; the "trick" to do the decomposition is to factor $x^2+x-2=(x-1)(x+2)$ and solve the equation $$\frac{-x+2}{x^2+x-2} = \frac{A}{x+1}+\frac{B}{x-2}.$$Look around here for "partial fraction decomposition". And what is "WA"? – Arturo Magidin Feb 3 '12 at 4:52
@ArturoMagidin I was about to ask what is "WA" too. I believe it is Wolfram Alpha. – user38268 Feb 3 '12 at 4:55
@ArturoMagidin: WA (=wolframalpha) stated me that one needs to use long-division to deduce this, I was flaggergasted, hence "mock-long-division". – hhh Feb 3 '12 at 4:56
Where did Wolfram alpha state this? When doing integrals of rational functions, the first step is often to do long division, and then a partial fraction decomposition using the remainder. What's the context? – Arturo Magidin Feb 3 '12 at 5:05
@ArturoMagidin: here when you press "show steps". This problem is a slight variation but I think it is misleading instructed as "long-division". – hhh Feb 3 '12 at 5:16

The trick is to realise that the denominator can be factored as

$x^2 + x - 2 = (x+2)(x-1)$.

Then you make an ansatz (educated guess) that the right hand side can be written as

$$\frac{A}{x+2} + \frac{B}{x-1}$$

and solve for $A$ and $B$. In fact if you do this, you get after making denominators common the equation

$2 - x = A(x-1) + B(x+2)$.

From which substituting in $x = 1$ gives $3B = 1$, or $B = 1/3$. Similarly substituting in $x = -2$ gives $4 = -3A$, so that $A = -4/3$.

-