How to find the co-efficients of a function within Zp[x]?
One thing you can always do in situations like this is &quot;defer the reductions to the end&quot;.
By this, I mean do all of your calculations in $\mathbb{Z}[x]$, and then at the end &quot;perform reductions until you no longer can&quot;, where the two kinds of reductions you do in $\mathbb{Z}/p\mathbb{Z}[x]$ are:

Modular reductions (of coefficients): $a\mapsto a\bmod p$
Reductions (of variables) according to Fermat's little theorem (if working mod $n$ for a composite number, instead use Euler's theorem): $x^k\mapsto x^{k\bmod \varphi(p)}\bmod p = x^{k\bmod (p-1)}$

As kelalaka points out, you can first expand $f(x)$ as a degree 6 polynomial. As $p$ is large compared to the degree (unless by &quot;large&quot; you mean something like 5), you will need no reductions of the second type, so can solely reduce the coefficients of $f(x)$ mod $p$.
If you have to do these computations on the fly this is not the most efficient thing to do (as the initial computation of $f(x)$ can potentially have a very large representation compared to the reduced version, and you may have to do arithmetic with very large numbers in computing this), but it can be useful both conceptually, and fine when you need to pre-process a polynomial (as you do now).
Essentially, arithmetic with polynomials $\bmod n$ can be split into (familiar) integer polynomial arithmetic, followed by applications of the above two reduction rules.