5. Given $x+\frac{1}{x}=3$, then $x^{4}+3 x^{3}-16 x^{2}+3 x-1$ ? The value equals $\qquad$ .
5. From $x^{2}+1=3 x$, we get $x^{4}=7 x^{2}-1, x^{3}=3 x^{2}-x$. Therefore, the original expression $=7 x^{2}-1+9 x^{2}-3 x-16 x^{2}+3 x-17$ $=-18$.
Another solution: From the given $x^{2}+1=3 x, x^{2}-3 x=-1$, so,
$$
\begin{array}{l}
x^{4}+3 x^{3}-16 x^{2}+3 x-17=\left(x^{4}+2 x^{2}+1\right)+3 x^{3}+3 x \\
-18 x^{2}-18=\left(x^{2}+1\right)^{2}+3 x\left(x^{2}+1\right)-18\left(x^{2}+1\right) \\
=(3 x)^{2}+(3 x)^{2}-18 \times 3 x=18\left(x^{2}-3 x\right)=-18 .
\end{array}
$$