Notice that x-2 and x+1 are factors of x^2-x-2.
x+7x2−x−2=ax−2+bx+1x+7x2−x−2=a(x+1)x2−x−2+b(x−2)x2−x−2x−7=a(x+1)+b(x−2)x−7=ax+a+bx−2b
ax+bx must add up to the x term on the left side, which is x. a-2b must subtract to the constant on the left side, -7. We then have a system of equations.
a+b=1
a-2b=-7
We find that a= -5/3 and b=8/3.