# How to do arithmetic operation of elements in finite field? Anonymous

Let us consider an example:

Var('x')
F.<x> = GF(13^2)


We consider two elements 2*x + 11, 3*x + 2 corresponding to the integers 37 and 41 respectively. Now we can operate them as

a=F.fetch_int(37)+F.fetch_int(41)
m=F.fetch_int(37)*F.fetch_int(41)


We have a=4*x + 10 , m= 4*x + 10

In reverse way we can get the corresponding integers as :

ai=a.integer_representation()
mi=m.integer_representation()


That is, ai=65, mi=62

How can I do the same for the field GF(251) using the same function?

edit retag close merge delete

Sort by » oldest newest most voted

Because 251 is prime, Sage choose a different implementation for GF(13^2) and GF(251), see:

sage: 251 in Primes()
True

sage: type(GF(13^2))
<class 'sage.rings.finite_rings.finite_field_givaro.FiniteField_givaro_with_category'>

sage: type(GF(251))
<class 'sage.rings.finite_rings.finite_field_prime_modn.FiniteField_prime_modn_with_category'>


As you can see, the field GF(13^2) is handled by givaro. If you look to the documentation of the GF constructor:

sage: GF?


you can see that you can chose the implementation yourself instead of relying to Sage best guess. Hence you can construct the field GF(251) using the givaro backend, which provides the fetch_int method:

sage: F.<x> = GF(251^2, impl='givaro')
sage: a=F.fetch_int(37)+F.fetch_int(41)
sage: m=F.fetch_int(37)*F.fetch_int(41)
sage: ai=a.integer_representation()
sage: mi=m.integer_representation()
sage: ai,mi
(78, 11)


By the way, Var('x') is if no use here, since F.<x> = defines both F and x (and the var function name is lowercase).

more