What algorithm can be used find an irreducible polynomial of degree $n$ over the field $GF(p)$ for prime $p$. The reason I ask is I want to make a program for finite field arithmetic, but creating a field $GF(p^k)$ requires finding a irreducible polynomial. (I'm mostly interested in $GF(2^k)$.)
-
1Maybe you can try to look at Cantor-Zassenhaus algorithm, for factorising polynomials over finite fields. There also is Berlekamp's algorithm. – Watson Feb 14 '16 at 15:36
2 Answers
As others indicated, you can find irreducible polynomials of degree $n$ by factoring $x^{p^n}-x$ modulo $p$, and throwing away factors that have too small a degree. The algorithms by Cantor-Zassenhaus and Berlekamp are useful to that end. Do note that the characteristic zero factor in Hagen's answer is very far from being irreducible modulo $2$.
But, observe that factoring $x^{p^m}-x$ is not an option, when $p^m$ is too big. If that is a concern for you then the easiest to comprehend test I can imagine would be to generate random monic polynomials $p(x)$ of degree $m$. The probability for such a polynomial to be irreducible is roughly $1/m$ (the exact number is given by a Möbius formula). You can then either
A) Proceed with Berlekamp or Cantor-Zassenhaus and try to factor your candidate. If none are found you know the polynomial is irreducible. Or,
B) For each positive integer $d\le m/2$ calculate the greatest common divisor $$\gcd(p(x),x^{p^d}-x).$$ If no common divisors are found, then you know $p(x)$ has no factors of degree $d$, so if no factors are found with $d$ up to $m/2$, you know that $p(x)$ must be irreducible. Observe that calculating gcd's like this is quite fast. Only in the first step of Euclid's algorithm will you have high degree polynomials. That high degree polynomial is a binomial, so calculating its remainder modulo $p(x)$ is fast with the aid of square-and-multiply.
For small $k$ there are tables. I use this table when $p=2$, because it gives primitive polynomials, i.e. minimal polynomials of a generator of the multiplicative group of $GF(2^k)$. For other small $p$ and small $k$ Lidl & Niederreiter have more extensive tables. The book is a bit pricy (and also recommended for hardcore enthusiasts on finite fields only), so go to a university library near you rather than order one from Amazon. Also, they put more effort into listing all the irreducible polynomials rather than giving sample irreducibles of several degrees. Depending on what you want to do a given table may not be useful to you.

- 133,153
The multiplicative group of $\Bbb F_{p^k}$ is cyclic of order $m=p^k-1$. If $\alpha$ is a generator, then it is a root of the polynomial $X^m-1$. We can use the Möbius principle to get rid of roots of lower degree and find that the minimal polynomial of $\alpha$ over $\Bbb F_p$ is $$ \prod_{d\mid m}(X^{m/d}-1)^{\mu(m/d)}$$ For example with $\Bbb F_{64}$ and $m=63=3^2\cdot 7$ we arrive at $$ \frac{(X^{63}-1)(X^3-1)}{(X^{21}-1)(X^{9}-1)}= X^{36} - X^{33} + X^{27} - X^{24} + X^{18} - X^{12} + X^9 - X^3 + 1$$ (Actually, the signs $\pm$ do not matter over $\Bbb F_2$)

- 374,180
-
Do you have a proof or link to a proof of the mobius principle? – Christopher King Feb 14 '16 at 16:22
-
2This polynomial is not irreducible over $\mathbb{F}2$! If $\alpha$ is a generator of $\mathbb{F}{64}$, then the only irreducible polynomial of which $\alpha$ is the minimal polynomial of $\alpha$, which has degree 6. Therefore, your polynomial splits in 6 irreducible factors of degree 6 over $\mathbb{F}_2$. (See also Wolfram Alpha for the explicit factorization.) – Marc Feb 14 '16 at 17:44