Conversion from finite field to integer polynomial

64 views
Skip to first unread message

G. M.-S.

unread,
Nov 26, 2024, 5:47:40 PM11/26/24
to sage-s...@googlegroups.com

Already asked on

I am looking for a function myf doing the following:

    sage: var('x')
    x
    sage: P=x^3-2*x^2-x-2
    sage: F125.<a>=GF(5^3,name='a',modulus=P)
    sage: b=a^37;b
    4*a^2 + 3*a + 1
    sage: c=myf(b,y)
    1 + 3*y + 4*y^2
    sage: c.parent()
    Power Series Ring in y over Integer Ring

or better still (symmetric representation):

    sage: c=myf(b,y)
    1 - 2*y - y^2
    sage: c.parent()
    Power Series Ring in y over Integer Ring

I can manage with str, replace, preparse, eval but there is surely a natural way.

TIA,

Guillermo

Dima Pasechnik

unread,
Nov 27, 2024, 1:51:57 AM11/27/24
to sage-s...@googlegroups.com
A natural way would be to construct the quotient ring of GF(5)[x]  modulo (P), then b will be a polynomial in x, and you will have direct access to its coefficients.

John Cremona

unread,
Nov 27, 2024, 3:48:05 AM11/27/24
to sage-support
Use list() to get the coefficients:

sage: P=x^3-2*x^2-x-2
sage: F125.<a>=GF(5^3,name='a',modulus=P)
sage: b=a^37;b
4*a^2 + 3*a + 1
sage: Zy.<y> = ZZ[]
sage: Zy(list(b))
4*y^2 + 3*y + 1

Dima Pasechnik

unread,
Nov 27, 2024, 4:58:13 AM11/27/24
to sage-s...@googlegroups.com
I would have never guessed that list(b) works. Should there be b.list() or b.coefs() ?

John Cremona

unread,
Nov 27, 2024, 6:26:11 AM11/27/24
to sage-support
Yes, b.list() works instead of list(b).

There is also b.polynomial() which gives it as a polynomial over the prime field, so I could have done either Zy(b.list()) or Zy(b.polynomial()) as you can check.

I agree that b.coeffs() would make sense to have.  Also, the parent field F125 = GF(5^3) has a dual_basis() method but no basis() method, which is strange.  I think that finite fields should have a basis() method, giving their basis as a vector space over the prime field (or over its base field).

G. M.-S.

unread,
Nov 27, 2024, 3:49:57 PM11/27/24
to sage-s...@googlegroups.com

Thank you very much, Dima and John.

As they say in Spanish:  "No te acostarás sin saber una cosa más."

Guillermo
Reply all
Reply to author
Forward
0 new messages