Factorizing certain polynomial like $x^{10}-1$ efficiently I want to know:

Is there an efficient way to factorize polynomials like
$$x^{10}-1~~~,\text{or}~~~x^{16}-x$$ over small finite fields like $F_2$ and $F_3$ for example?

How would you do that? I want to see some techniques which I can apply to other polynomials of this type. Thanks:)
 A: In general the factorization of a polynomial of the form $x^n-1$ over $\Bbb{F}_p$ is roughly equivalent to producing lists of irreducible polynomials over $\Bbb{F}_p$. This is because all irreducible polynomials $p(x)$ over $\Bbb{F}_p$, with the exception of $p(x)=x$ occur as factors (see the comments below).
Anyway, the following things are easy to see:


*

*If $n=p^km$ with $p\nmid m$, then $$x^n-1=(x^m-1)^{p^k}.$$ Therefore it suffices to study the case $p\nmid n$.

*The characteristic zero factorization in to cyclotomic polynomials still holds over $\Bbb{F}_p$: $$x^n-1=\prod_{d\min n}\Phi_d(x).$$ The difference is that the polynomials $\Phi_d(x)$ are no longer irreducible in general modulo $p$.

*Using Galois theory of the extensions of finite fields it is easy to see that when $p\nmid n$, the factors of $\Phi_n(x)$ modulo $p$ all have the same degree $f$, where $f$ is the smallest positive integer with the property $n\mid p^f-1$. In other words $f$ is the order of the coset of $p$ in the multiplicative group $\Bbb{Z}_n^*$. This has been explained many times on our site (ask if you cannot locate such a thread).


However, finding the individual irreducible factors of cyclotomic polynomials $\Phi_n(x)$ over $\Bbb{F}_p$ is not straightforward. There are tricks, and if those fail there is Berlekamp's algorithm. Too long to fit here.
A: For $F_2$:
\begin{gather*}
x^{10}-1=x^{10}+1=(x^5+1)^2=((x+1)(x^4+x^3+x^2+x+1))^2=(x+1)^2(x^4+x^3+x^2+x+1)^2.
\end{gather*}
A: The remaining cases over $\mathbb{F}_3$ are given by
$$
x^{10}-1=(x^4 + 2x^3 + x^2 + 2x + 1)(x^4 + x^3 + x^2 + x + 1)(x + 2)(x + 1),
$$
and 
$$
x^{16}-1=(x^4 + 2x^2 + 2)(x^4 + x^2 + 2)(x^2 + 2x + 2)(x^2 + x + 2)(x^2 + 1)(x + 2)(x + 1).
$$
The linear factors are easy to find, but for the other factors one has to do more. The result shows that we need some general methods, and there are many of them (in particular Berlekamps's algorithm), see here.
A: Over $F_2$ we have $x^{16}-1=x^{16}+1=(x^8+1)^2=(x^4+1)^4=(x^2+1)^8=(x+1)^{16}.$ Over $F_{p^n}$ when $p$ is prime, two polynomials are equal if their corresponding co-efficients are congruent modulo $p$.
A: An interesting fact that covers the $x^{16}-x$ over $\mathbb{F}_2$ case is the following:

Over $\mathbb{F}_{q}$, the polynomial $x^{q^n}-x$ is the product of all monic irreducible polynomials over $\mathbb{F}_q$ whose degree divides $n$.

So over $\mathbb{F}_2$, $x^{16}-x$ is the product of all monic irreducible polynomials over $\mathbb{F}_2$ of degree $1,2, \text{ and } 4$.
