> < ^ Date: Thu, 22 Aug 1996 11:33:07 +0200
> < ^ From: Sebastian Egner <sebastian.egner@philips.com >
> ^ Subject: A little observation (may be important)

Dear GAP-forum,

we just needed a function to test whether a given cyclotomic
field element is a root of unity. Since GAP v3.4 does not
contain such a function our first guess was

IsRootOfUnityCyc := function ( x )
  return IsCyc(x) and x^NofCyc(x) = 1;  # Do not use this!
end;

Trying it on Random(CF(43)) convinced us that there must be
a better way. This is our solution:

IsRootOfUnityCyc := function ( x )
  return IsCyc(x) and x*GaloisCyc(x, -1) = 1; # Use this.
end;

It is obvious why the second function outperforms the first
one by orders of magnitude. However, you need to think of it.
Does anybody know a faster solution?
Sebastian Egner, Markus P"uschel.


> < [top]