Ask Your Question

give the code to seperate out two terms

asked 2016-04-14 10:37:59 -0500

santoshi gravatar image

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 flag offensive 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" `.

slelievre gravatar imageslelievre ( 2016-04-15 07:30:58 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-04-14 11:17:27 -0500

tmonteil gravatar image


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]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-04-14 10:37:59 -0500

Seen: 60 times

Last updated: Apr 14 '16