Ask Your Question

Revision history [back]

Polynomial rings over finite fields have a dedicated method.

That method, polynomials, takes of_degree or max_degree.

Add x^n to max_degree one less for monic degree n polynomials.

sage: F.<a> = GF(2^2)
sage: F
Finite Field in a of size 2^2

sage: R.<x> = PolynomialRing(F)
sage: R
Univariate Polynomial Ring in x over Finite Field in a of size 2^2

sage: R1 = R.polynomials(max_degree=1)
sage: R1
<generator object PolynomialRing_general._polys_max at 0x...>

sage: R2m = list(x^2 + p for p in R1)
sage: R2m
[x^2,
 x^2 + a,
 x^2 + a + 1,
 x^2 + 1,
 x^2 + a*x,
 x^2 + a*x + a,
 x^2 + a*x + a + 1,
 x^2 + a*x + 1,
 x^2 + (a + 1)*x,
 x^2 + (a + 1)*x + a,
 x^2 + (a + 1)*x + a + 1,
 x^2 + (a + 1)*x + 1,
 x^2 + x,
 x^2 + x + a,
 x^2 + x + a + 1,
 x^2 + x + 1]

Polynomial rings over finite fields have a dedicated method.

That method, method polynomials, takes .

It can generate polynomials of_degree something or of given max_degree.

Add x^n to max_degree one less for For monic degree n polynomials.d polynomials, add x^d to polynomials of "max degree one less".

To illustrate, we use the field with four elements so the list stays short enough.

The field and the polynomial ring:

sage: F.<a> = GF(2^2)
sage: F
Finite Field in a of size 2^2

sage: R.<x> = PolynomialRing(F)
sage: R
Univariate Polynomial Ring in x over Finite Field in a of size 2^2

sage: R1 = R.polynomials(max_degree=1)
sage: R1
<generator object PolynomialRing_general._polys_max at 0x...>

sage: R2m = 

All polynomials of degree up to one:

sage: list(R.polynomials(max_degree=1))
[0
 a,
 a + 1,
 1,
 a*x,
 a*x + a,
 a*x + a + 1,
 a*x + 1,
 (a + 1)*x,
 (a + 1)*x + a,
 (a + 1)*x + a + 1,
 (a + 1)*x + 1,
 x,
 x + a,
 x + a + 1,
 x + 1]

All monic polynomials of degree two:

sage: list(x^2 + p for p in R1)
sage: R2m
R.polynomials(max_degree=1))
[x^2,
 x^2 + a,
 x^2 + a + 1,
 x^2 + 1,
 x^2 + a*x,
 x^2 + a*x + a,
 x^2 + a*x + a + 1,
 x^2 + a*x + 1,
 x^2 + (a + 1)*x,
 x^2 + (a + 1)*x + a,
 x^2 + (a + 1)*x + a + 1,
 x^2 + (a + 1)*x + 1,
 x^2 + x,
 x^2 + x + a,
 x^2 + x + a + 1,
 x^2 + x + 1]

Aall monic polynomials up to degree 2:

sage: list(x^d + p for d in (0 .. 2) for p in R.polynomials(max_degree=d-1))
[1,
 x,
 x + a,
 x + a + 1,
 x + 1,
 x^2,
 x^2 + a,
 x^2 + a + 1,
 x^2 + 1,
 x^2 + a*x,
 x^2 + a*x + a,
 x^2 + a*x + a + 1,
 x^2 + a*x + 1,
 x^2 + (a + 1)*x,
 x^2 + (a + 1)*x + a,
 x^2 + (a + 1)*x + a + 1,
 x^2 + (a + 1)*x + 1,
 x^2 + x,
 x^2 + x + a,
 x^2 + x + a + 1,
 x^2 + x + 1]

Providing a keyword argument for generating only monic polynomials is tracked at: