Ask Your Question

Revision history [back]

Regarding 1:

You can define the field, and simultaneously associate a python name to its generator with:

sage: K.<a> = GF(2^5)
sage: a^31
1
sage: a.parent()
Finite Field in a of size 2^5
sage: a.minpoly()
x^5 + x^2 + 1

So, you can construct any element as the sum of powers of a:

sage: x
a^4 + a^3 + 1
sage: x.parent()
Finite Field in a of size 2^5

Conversely, given an element x in K, you can turn it into a polynomial in a and then extract its coefficients:

sage: x = K.random_element() ; x
a^3 + a^2 + 1
sage: x.parent()
Finite Field in a of size 2^5
sage: x.polynomial()
a^3 + a^2 + 1
sage: x.polynomial().parent()
Univariate Polynomial Ring in a over Finite Field of size 2 (using GF2X)
sage: D = x.polynomial().dict() ; D
{0: 1, 2: 1, 3: 1}

And get back x from it:

sage: [D[d]*a^d for d in D]
[1, a^2, a^3]
sage: sum(D[d]*a^d for d in D)
a^3 + a^2 + 1
sage: sum(D[d]*a^d for d in D) == x
True

Regarding 2: i am not sure to understand you query, the function is not linear, so i do not see how do you want to represent it, could you please provide an example of what do you expect ?