galois.primitive_element(method: Literal[min] | Literal[max] | Literal[random] = 'min') Poly

Finds a primitive element $$g$$ of the Galois field $$\mathrm{GF}(q^m)$$ with degree-$$m$$ irreducible polynomial $$f(x)$$ over $$\mathrm{GF}(q)$$.

Parameters:
irreducible_poly: Poly

The degree-$$m$$ irreducible polynomial $$f(x)$$ over $$\mathrm{GF}(q)$$ that defines the extension field $$\mathrm{GF}(q^m)$$.

method: Literal[min] | Literal[max] | Literal[random] = 'min'

The search method for finding the primitive element.

Returns:

A primitive element $$g$$ of $$\mathrm{GF}(q^m)$$ with irreducible polynomial $$f(x)$$. The primitive element $$g$$ is a polynomial over $$\mathrm{GF}(q)$$ with degree less than $$m$$.

Examples

Construct the extension field $$\mathrm{GF}(7^5)$$.

In : f = galois.irreducible_poly(7, 5, method="max"); f
Out: Poly(x^5 + 6x^4 + 6x^3 + 6x^2 + 6x + 6, GF(7))

In : GF = galois.GF(7**5, irreducible_poly=f, repr="poly")

In : print(GF.properties)
Galois Field:
name: GF(7^5)
characteristic: 7
degree: 5
order: 16807
irreducible_poly: x^5 + 6x^4 + 6x^3 + 6x^2 + 6x + 6
is_primitive_poly: False
primitive_element: x + 3


Find the smallest primitive element for the degree-5 extension of $$\mathrm{GF}(7)$$ with irreducible polynomial $$f(x)$$.

In : g = galois.primitive_element(f); g
Out: Poly(x + 3, GF(7))

# Convert the polynomial over GF(7) into an element of GF(7^5)
In : g = GF(int(g)); g
Out: GF(x + 3, order=7^5)

In : g.multiplicative_order() == GF.order - 1
Out: True


Find the largest primitive element for the degree-5 extension of $$\mathrm{GF}(7)$$ with irreducible polynomial $$f(x)$$.

In : g = galois.primitive_element(f, method="max"); g
Out: Poly(6x^4 + 6x^3 + 6x^2 + 6x + 3, GF(7))

# Convert the polynomial over GF(7) into an element of GF(7^5)
In : g = GF(int(g)); g
Out: GF(6x^4 + 6x^3 + 6x^2 + 6x + 3, order=7^5)

In : g.multiplicative_order() == GF.order - 1
Out: True


Find a random primitive element for the degree-5 extension of $$\mathrm{GF}(7)$$ with irreducible polynomial $$f(x)$$.

In : g = galois.primitive_element(f, method="random"); g
Out: Poly(4x^4 + 2x^3 + 5x^2 + 2x + 2, GF(7))

# Convert the polynomial over GF(7) into an element of GF(7^5)
In : g = GF(int(g)); g
Out: GF(4x^4 + 2x^3 + 5x^2 + 2x + 2, order=7^5)

In : g.multiplicative_order() == GF.order - 1
Out: True