4. Given the polynomial $f(x)=x^{12}-x^{6}+1$ divided by $x^{2}+1$ has a quotient $q(x)$ and a remainder $r(x)=a x+b$, where $a$ and $b$ are real numbers. Then the value of $b$ is ( ).
(A) 0
(B) 1
(C) 2
(D) 3
4. D.

Notice that, $\mathrm{i}^{2}+1=0$.
Let $x=\mathrm{i}$, then
$$
\begin{array}{l}
\mathrm{i}^{12}-\mathrm{i}^{6}+1=a \mathrm{i}+b \\
\Rightarrow a \mathrm{i}+b=3 \Rightarrow a=0, b=3 .
\end{array}
$$