How to deduce this factorization of $x^5+x+1$ by looking at $\int\frac{3x^4+2x^3-2x+1}{x^5+x+1}dx$?

Just it's better to see that any polynomial $x^{3k-1}+x^{3n-2}+1$ has a factor $x^2+x+1$ for any naturals $k$ and $n$.

For example, your reasoning with $\omega\neq1$ and $\omega^3=1$ helps to understand it.

In our case we can get this factoring so: $$x^5+x+1=x^5-x^2+x^2+x+1=(x^2+x+1)(x^3-x^2+1).$$


Hmm. I'd look at it and say "There's no rational root" because $x = \pm 1$ doesn't work. So there's some irrational root, $\alpha$, and two complex-conjugate pairs. So there's no nice obvious linear factor I can write down.

Then I'd say "Maybe there's a quadratic factor." I can assume it's monic, so I'm looking to write $$ x^5 + x + 1 = (x^2 + ax + b) (x^3 + px^2 + qx + r). $$ from which I can expand to get $$ x^5 + x + 1 = x^5+(p + a)x^4 + (q + ap + b) x^3 + (ra + bq)x + br $$ if I've done the algebra right. Equating coefficients I see that \begin{align} 0 &= a + p\\ 0 &= q + ap + b\\ 1 &= ra + bq\\ 1 &= br \end{align} so $ p = -a$, and $r = \frac1b$,and these equations become \begin{align} 0 &= a + -a\\ 0 &= q - a^2 + b\\ 1 &= \frac1b a + bq\\ 1 &= b(1/b) \end{align} which simplify down to \begin{align} q &= a^2 - b\\ b &= a + b^2q\\ \end{align} or \begin{align} q &= a^2 - b\\ 0 &= b^2 q - b + a \end{align}

That last equation is a quadratic in $b$ or $q = 0$. The first choice yields $$ b = \frac{1 \pm \sqrt{1-4aq }}{2q} $$ The second choice yields $b = a, q = 0$, from which we find that $r = 1, p = -1$, which is a nice solution, so we can stop looking at the first case. (Yay!)