0
$\begingroup$

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?

$\endgroup$

1 Answer 1

2
$\begingroup$

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++]
$\endgroup$
4
  • $\begingroup$ you could use =!= as well.. $\endgroup$
    – george2079
    Commented May 14, 2016 at 15:13
  • $\begingroup$ Thanks. Can you explain what the difference is between the two conditions such that one evaluates to true but the other does not? $\endgroup$ Commented May 14, 2016 at 16:22
  • 1
    $\begingroup$ see documentation for Unequal. Returns True if elements are guaranteed unequal, and otherwise stays unevaluated. $\endgroup$
    – Hubble07
    Commented May 16, 2016 at 9:15
  • $\begingroup$ 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) $\endgroup$
    – george2079
    Commented May 16, 2016 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.