# give the code to seperate out two terms

p=5 K.=GF(p^2);K.modulus() R.<z>=PolynomialRing(K); f=(z+2*a+4).truncate(1)

m=f.list() m the above code after execution give the result (2a+4) . i want to seperate out terms (2a) and 4. How to seperate?
edit retag close merge delete

To display blocks of code, either indent them with 4 spaces, or select the corresponding lines and click the "code" button (the icon with '101 010'). Can you edit your question to do that?

To display inline code, surround it within "backticks" or "backquotes" .

( 2016-04-15 07:30:58 -0600 )edit

Sort by ยป oldest newest most voted

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]
`
more