As the degree of the numerator is > degree of the denominator, we have to perform a long division
color(white)(aaaa)x^3color(white)(aaaa)-7x-3color(white)(aaaa)|x^2-x-2
color(white)(aaaa)x^3-x^2-2xcolor(white)(aaaaaaaa)|x+1
color(white)(aaaaa)0+x^2-5x-3
color(white)(aaaaaa)#+x^2-x-2#
color(white)(aaaaaaa)#+0-4x-1#
Also,
x^2-x-2=(x-2)(x+1)
Therefore,
(x^3-7x-3)/(x^2-x-2)=(x+1)+(-4x-1)/((x-2)(x+1))
We can perform the decomposition into partial fractions
(-4x-1)/((x-2)(x+1))=A/(x-2)+B/(x+1)
=(A(x+1)+B(x-2))/((x-2)(x+1))
We compare the numerators
-4x-1=A(x+1)+B(x-2)
Let x=2, =>, -9=3A, =>, A=-3
Let x=-1, =>, 3=-3B, =>, B=-1
So,
(4x+1)/((x-2)(x+1))=-3/(x-2)-1/(x+1)
Therefore,
(x^3-7x-3)/(x^2-x-2)=(x+1)-3/(x-2)-1/(x+1)
int((x^3-7x-3)dx)/(x^2-x-2)=intxdx+int1dx-3intdx/(x-2)-intdx/(x+1)
=x^2/2+x-3ln(|x-2|)-ln(|x+1|)+C