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: 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}.$$
A: Another way.
For $a^2+3a-1=0$ and $a=\frac{-3+\sqrt{13}}{2}$ we obtain:
$$(a^2-1)^2=9a^2$$ or
$$(a^2+1)^2=13a^2$$ or
$$a^2+1=\sqrt{13}a,$$ which gives: $$\frac{2a^5-5a^4+2a^3-8a^2}{a^2+1}=$$
$$=\tfrac{2a^5+6a^4-2a^3-11a^4-33a^3+11a^2+37a^3+111a^2-37a-130a^2+37a}{\sqrt{13}a}=$$
$$=\tfrac{37-130a}{\sqrt{13}}=\tfrac{37-65(-3+\sqrt{13})}{\sqrt{13}}=\tfrac{232-65\sqrt{13}}{\sqrt{13}}.$$
For $a=\frac{-3-\sqrt{13}}{2}$ we obtain: $$a^2+1=-\sqrt{13}a,$$ which gives
$$\frac{2a^5-5a^4+2a^3-8a^2}{a^2+1}=\tfrac{-232-65\sqrt{13}}{\sqrt{13}}.$$
