3
$\begingroup$

I am trying to do basic 101 manipulation with SageMath

F = GF(3); F

Finite Field of size 3

R.<x> = F[] ; R

Univariate Polynomial Ring in x over Finite Field of size 3

F2 = F.extension(x^2+1,'u');F2

Finite Field in u of size 3^2

for i,x in enumerate(F2):  print("{} {}".format(i, x))

0 0 
1 u + 2 
2 u 
3 2*u + 2 
4 2 
5 2*u + 1 
6 2*u 
7 u + 1 
8 1

Now i would just like to do simple arithmetic and check for example that $u^2+1 = 0$ But i get an error. I cannot find the right syntax.

u^2+1

--------------------------------------------------------------------------- NameError Traceback (most recent call last) in () ----> 1 u**Integer(2)+Integer(1)

NameError: name 'u' is not defined

$\endgroup$

1 Answer 1

4
$\begingroup$

Try naming the variable $u$ by using .<u> in your definition of F2, like this.

F2.<u> = F.extension(x^2+1)

If you don't care what the minimal polynomial of your primitive element of $\mathbb F_9$ is, you could also do this.

F2.<u> = GF(3^2)
$\endgroup$
2
  • $\begingroup$ thanks it does the job $\endgroup$ Jun 19, 2020 at 23:02
  • 1
    $\begingroup$ I am getting error message for this line. F=GF(3); F2.<u>=F.extension(x^2+1) ; F2 Error::UnboundLocalError: local variable 'E' referenced before assignment; how to over come this error? $\endgroup$ May 30, 2023 at 6:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .