Ask Your Question
1

give the code to seperate out two terms

asked 8 years ago

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?
Preview: (hide)

Comments

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 ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
3

answered 8 years ago

tmonteil gravatar image

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]
Preview: (hide)
link

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

Stats

Asked: 8 years ago

Seen: 806 times

Last updated: Apr 14 '16