<s>[INST] How do we factor out $x^2 - x -2$ in this expression? Suppose we're given that
$$x^4 - 2x^3 +x-2$$
How do we factor out $x^2 - x -2$ in this expression?

$$(x^4 -x^3- 2x^2)-(x^3-x^2-2x)+(x^2-x-2) = x^2(x^2 -x-2)-x(x^2-x-2)+(x^2-x-2) = (x^2-x-2)(x^2-x+1)$$

This satisfies with what we want to get. However, I do not seem to have understood what is done there. Could I get your assistance in order to understand it? Perhaps there's better way of factoring. 
Regards
 [/INST] An easier way is to note that $x^4-2x^3+x-2$ has the simple roots $x=-1$ and $x=2$, which are obvious candidates by the rational root theorem, so your polynomial is divisible by
$$(x+1)(x-2)=x^2-x-2.$$
</s>