Factoring $x^4-2x^3+2x^2+x+4$

If we can write $$p(x)= q(x)r(x)$$ say in $\mathbb{Z}$ then we can do that also in $\mathbb{Z}_m$ where $m$ is an arbitrary integer $>1$. So there exists $q_1,r_1$ such that

$$p(x)\equiv_m q_1(x)r_1(x)$$ and $$r(x) \equiv_m r_1(x) \;\;\;\wedge\;\;\; q(x) \equiv_m q_1(x) $$

and we might hope that $r(x) = r_1(x)$ or $q(x) =q_1(x)$.


If we try this in your case for mod $2$ we get $$p(x) \equiv_2 x^4+x \equiv_2 x(x+1)(x^2+x+1)$$

and we see that $x^2+x+1$ actually divide $p(x)$.


$$x^4-2x^3+2x^2+x+4$$ $$=(x^2+1)^2-2x^3+x+3$$ $$=(x^2+1)^2-2x(x^2+1)+3x+3$$ $$=(x^2+1)^2+x(x^2+1)-3x^3+3$$ $$=(x^2+1)^2+x(x^2+1)-3(x-1)(x^2+x+1)$$ $$=(x^2+x+1)(x^2+1-3x+3)$$ and you are done.


Actually, if you just try to solve this like a general quartic equation you get a break: let $x=t+1/2$. Then $$\begin{align}x^4-2x^4+2x^2+x+4&=\left(t+\frac12\right)^4-2\left(t+\frac12\right)^3+2\left(t+\frac12\right)^2+\left(t+\frac12\right)+4\\ &=t^4+\frac12t^2+2t+\frac{77}{16}\\ &=\left(t^2+at+b\right)\left(t^2-at+c\right)\\ &=t^4+\left(b-a^2+c\right)t^2-a(b-c)t+bc\end{align}$$ So we have $$\begin{align}b+c&=\frac12+a^2\\ b-c&=-\frac2a\end{align}$$ With solutions $$\begin{align}2b&=a^2+\frac12-\frac2a\\ 2c&=a^2+\frac12+\frac2a\end{align}$$ Then $$4bc=a^4+a^2+\frac14-\frac4{a^2}=\frac{77}4$$ Which simplifies to $$a^6+a^4-19a^2-4=0$$ And here is our break: the resolvent cubic has a rational root: $a^2=4$. If we pick $a=2$, then $b=7/4$, $c=11/4$ and $$\begin{align}x^4-2x^4+2x^2+x+4&=\left(t^2+2t+\frac74\right)\left(t^2-2t+\frac{11}4\right)\\ &=\left(\left(x-\frac12\right)^2+2\left(x-\frac12\right)+\frac74\right)\left(\left(x-\frac12\right)^2-2\left(x-\frac12\right)+\frac{11}4\right)\\ &=\left(x^2+x+1\right)\left(x^2-3x+4\right)\end{align}$$