Polynomial rings over finite fields have a dedicated method polynomials
.
It can generate polynomials of_degree
something or of given max_degree
.
For monic degree 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
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 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: