As the numerator has the same degree of the denominator we start by separating the rational function in a way that allows a simplification:
#x^2/((x-1)(x+2)) = (x^2-1)/((x-1)(x+2)) +1/((x-1)(x+2)) #
#x^2/((x-1)(x+2)) = ((x-1)(x+1))/((x-1)(x+2)) +1/((x-1)(x+2)) #
#x^2/((x-1)(x+2)) = color(blue)((x+1)/(x+2)) + 1/((x-1)(x+2)) #
The first addendum can be separated again to simplify:
#x^2/((x-1)(x+2)) = color(blue)((x+2-1)/(x+2)) + 1/((x-1)(x+2)) #
#x^2/((x-1)(x+2)) = color(blue)(1-1/(x+2)) + color(red)(1/((x-1)(x+2)) )#
Now we write the second term (in red) as a sum of partial fractions with parametric numerators:
#1/((x-1)(x+2)) = A/(x-1)+B/(x+2)#
compute the sum in the second member:
#1/((x-1)(x+2)) = (A(x+2)+B(x-1))/((x-1)(x+2))#
#1/((x-1)(x+2)) = ((A+B)x+(2A-B))/((x-1)(x+2))#
As the denominators are equal, the equation is satisfied when the numerators are equal:
#(A+B)x+(2A-B) = 1#
which implies:
#{(A+B=0),(2A-B=1):}#
#{(A=-B),(3A=1):}#
#{(A=1/3),(B=-1/3):}#
Substituting in the expressions above:
#x^2/((x-1)(x+2)) = 1-1/(x+2) + 1/3(1/(x-1))-1/3(1/(x+2))#
#x^2/((x-1)(x+2)) = 1 -4/3 (1/(x+2)) + 1/3 (1/(x-1))#
We are now ready to integrate:
#int x^2/((x-1)(x+2))dx = int dx -4/3 int (dx)/(x+2) + 1/3 int(dx)/(x-1)#
#int x^2/((x-1)(x+2))dx =x -4/3lnabs(x+2) +1/3 ln abs(x-1)+C#