4. The function $f(x)$ that satisfies the equation
$$
f(x)+(x-2) f(1)+3 f(0)=x^{3}+2 \quad (x \in \mathbf{R})
$$

is $f(x)=$ . $\qquad$
4. $x^{3}-x+1$.

Substitute $x=1$ and $x=0$ into the equation, we get
$$
\begin{array}{l}
f(0)=1, f(1)=1 \text {. } \\
\text { Therefore, } f(x)=x^{3}+2-(x-2) f(1)-3 f(0) \\
=x^{3}-x+1 \text {. }
\end{array}
$$