0

I'm trying to use the Finite Fields package to show that $x$ is not a primitive element of $\mathbb{Z}_3[x]/\langle x^3 + 2x + 2 \rangle \cong GF(3^3)$. The idea is to take the following piece of code:

i = 1;
While[ReduceElement[GF[3, {2, 2, 0, 1}][{0, 1, 0}]^i] != 
      ReduceElement[GF[3, {2, 2, 0, 1}][{1}]], Print[i]; i++]

which should compute all the powers of $x$ and terminate when it reaches the identity. However, it does not produce any output; I even inserted the Print statement to make sure it would at least do something, but I still get nada. What is going on here? How can I make this piece of code work the way it's supposed to?

george2079
  • 38,913
  • 1
  • 43
  • 110
silvascientist
  • 389
  • 1
  • 13

1 Answers1

2

The problem is that the condition you wrote does not evaluate to True. For e.g. with i=12 it gives

ReduceElement[GF[3, {2, 2, 0, 1}][{0, 1, 0}]^12] != ReduceElement[GF[3, {2, 2, 0, 1}][{1}]]
  (*Subscript[{2, 0, 1}, 3] != Subscript[{1, 0, 0}, 3]*)

But it does evaluate to False for i=13

ReduceElement[GF[3, {2, 2, 0, 1}][{0, 1, 0}]^13] != ReduceElement[GF[3, {2, 2, 0, 1}][{1}]]
 (*False*)

So the solution is to write the condition such that it evaluates to True and False. The code below works and it prints till the False condition is found.

 i = 1;
 While[Not[
 ReduceElement[GF[3, {2, 2, 0, 1}][{0, 1, 0}]^i] === 
 ReduceElement[GF[3, {2, 2, 0, 1}][{1}]]], Print[i]; i++]
Hubble07
  • 3,614
  • 13
  • 23
  • you could use =!= as well.. – george2079 May 14 '16 at 15:13
  • Thanks. Can you explain what the difference is between the two conditions such that one evaluates to true but the other does not? – silvascientist May 14 '16 at 16:22
  • 1
    see documentation for Unequal. Returns True if elements are guaranteed unequal, and otherwise stays unevaluated. – Hubble07 May 16 '16 at 09:15
  • This deserves a little more explanation, the object Subscript[{2, 0, 1}, 3] is effectively a symbol that can be assigned a value. Since yours presumably do not have values, they may or may not be equal. (Same as x==y will return unevaluated if x and y do not have values) – george2079 May 16 '16 at 15:03