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.

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}}.$$
