Ask Your Question

Revision history [back]

With:

sage: m=f.list()[0]
sage: m
2*a + 4

you get an element of the field of size 25:

sage: m.parent()
Finite Field in a of size 5^2

To separate 2*a and 4, you need to see it as a polynomial on the field on 5 elements (with indeterminate a):

sage: m.polynomial()
2*a + 4
sage: m.polynomial().parent()
Univariate Polynomial Ring in a over Finite Field of size 5

So, you can get the coefficients as follows:

sage: p = m.polynomial()
sage: p.dict()
{0: 4, 1: 2}
sage: p.dict().items()
[(0, 4), (1, 2)]

So you can get the list you want as follows:

sage: [a^i*j for i,j in p.dict().items()]
[4, 2*a]