Ask Your Question
1

Finite field extension

asked 2013-01-15 15:13:00 +0100

bonjour gravatar image

updated 2021-04-04 19:43:50 +0100

slelievre gravatar image

How can one recover the coefficients of the polynomial representation of a number field element when the number field is not prime?

In the following example,

F = GF(p)
R.<x> = F[]
K.<t>  = GF(p^2, modulus=x^2 + 1)
a = K.random_element()

say the value of a obtained is 364*t + 214.

How can I read from Sage the integer values (364, 214), I need them for manipulation, I do not want the t there.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-01-15 15:53:54 +0100

achrzesz gravatar image
sage: P=127
sage: F = GF(P) 
sage: R.<x> = F[]
sage: K.<t> = GF(P^2, modulus = x^2 + 1) 
sage: a = K.random_element()
sage: a.polynomial().coeffs()
[5, 42]
edit flag offensive delete link more
0

answered 2021-04-04 19:39:21 +0100

slelievre gravatar image

updated 2021-04-04 20:11:34 +0100

This updates the answer by @achrzesz, as coeffs is no longer available.

The polynomial method of a number field element gives the associated polynomial. The list method of that polynomial gives its coefficients.

Beware that polynomials also have a coefficients method but by default it only gives the nonzero coefficients, so one should prefer list.

Define the number field:

sage: p = 127
sage: x = polygen(GF(p))
sage: K.<t> = GF(p^2, modulus=x^2 + 1)

Find the coefficients of some elements expressed as polynomials in the number field generator:

sage: a = 364*t + 214
sage: a
110*t + 87
sage: a.polynomial()
110*t + 87
sage: a.polynomial().list()
[87, 110]

sage: b = 16*t
sage: b
16*t
sage: b.polynomial()
16*t
sage: b.polynomial().list()
[0, 16]

sage: c = K(16)
sage: c
sage: c.polynomial()
16
sage: c.polynomial().list()
[16]

The coefficients method is error-prone:

sage: a.polynomial().coefficients()  # also works here
[87, 110]
sage: b.polynomial().coefficients()
[16]
sage: c.polynomial().coefficients()
[16]

unless one is specific about including zeros:

sage: b.polynomial().coefficients(sparse=False)
[0, 16]
sage: c.polynomial().coefficients(sparse=False)
[16]

Another option is to go through the integer representation:

sage: ZZ(a.integer_representation()).digits(base=p)
[87, 110]
sage: ZZ(b.integer_representation()).digits(base=p)
[0, 16]
sage: ZZ(c.integer_representation()).digits(base=p)
[16]

There, one can also pad with zeros so that the number of "p-adic digits" matches the degree:

sage: ZZ(c.integer_representation()).digits(base=p, padto=2)
[16, 0]

I answered the question with p = 127 as @achrzesz did, but the value of p the original poster had in mind was likely greater than 364.

When trying the above with p = 367, the integer_representation method is not available. Making it available independent of the finite field implementation is now tracked at

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

Stats

Asked: 2013-01-15 15:13:00 +0100

Seen: 1,434 times

Last updated: Apr 04 '21