How do I integrate this fraction:
$$\int\frac{x^3+2x^2+x-7}{x^2+x-2} dx$$
I did try the partial fraction decomposition:
$$\frac{x^3+2x^2+x-7}{x^2+x-2} = \frac{x^3+2x^2+x-7}{(x-1)(x+2)}$$
And:
$$\frac{A}{(x-1)}+\frac{B}{(x+2)}=\frac{A(x+2)}{(x-1)(x+2)}+\frac{B(x-1)}{(x-1)(x+2)}$$
Then:
$$\ A(x+2) + B(x-1)= x^3+2x^2+x-7$$
When I do this I gets a wrong answer, so I figured out that this may only work when the degree of the denominator is greater than the degree of the numerator...
So how do I integrate such a fraction?
You need to use polynomial long division, first, so the degree in the numerator is less than that of the denominator to get
$$I = \int \left(x+1 + \dfrac{2x-5}{x^2 + x-2}\right)\,dx$$
THEN you can use partial fraction decomposition given the factors you found for the denominator.
$$I = \frac {x^2}{2} + x + \left( I_2 = \int \frac{(2x-5)\,dx}{(x+2)(x-1)}\right)$$
$$I_2 = \int \left(\dfrac A{x+2} + \frac B{x-1}\right) \,dx$$
So we want to solve for the coefficients $A, B$, given the fact that
$$A(x-1) + B(x+2) = 2x - 5$$
At $x = 1,\quad A(0) + B(3) = 2-5=-3 \implies B = -1$
At $x = -2, \quad -3A = -9 \implies A = 3$.
Can you take it from here?