Finding $\frac{2a^5 - 5a^4 + 2a^3 - 8a^2}{a^2 + 1}$ Suppose $a$ is a root of $x^2 + 3x - 1.$ Find $\frac{2a^5 - 5a^4 + 2a^3 - 8a^2}{a^2 + 1}.$

I was thinking of factoring the fraction a bit first, than letting $a^2 = 1 - 3a.$ However, that leads nowhere.

A complete solution. Let $a$ be a root of $x^2+3x-1$. Then
$a^2=1-3a$
$a^3=a-3a^2=a-3(1-3a)=10a-3$
$a^4=10a^2-3a=10(1-3a)-3a=10-33a$
$a^5=10a-33a^2=10a-33(1-3a)=-33+109a$
Therefore the numerator:$$2a^5 - 5a^4 + 2a^3 - 8a^2=
-66+218a-5(10-33a)+2(10a-3)-8(1-3a)=-130+427a$$
and the denominator: $a^2+1=2-3a$.
Let $a'$ be another root of $x^2+3x-1=0$. Then $aa'=-1. a+a'=-3$. Multiply the numerator and the denominator by $2-3a'$. The denominator becomes $$(2-3a)(2-3a')=4+9-6(-3)=13-18=-5.$$ The numerator becomes $$(427a-130)(2-3a')=
854a-260+1281+390a'=1021-1170+464a=464a-149.$$
So the fraction is equal to $$\frac{464a-149}{-5}$$ where $$a=\frac{-3\pm \sqrt{13}}{2}.$$
