Calculating with primitive roots of unity in sage

1,599 views
Skip to first unread message

Andrew Mathas

unread,
Apr 15, 2012, 9:53:41 AM4/15/12
to sage-s...@googlegroups.com
Hi,

I was wondering if some one can tell me the most efficient way of doing calculations with roots of unity inside sage. Specifically, I want to do some calculations with some algebras defined over fields K which contain prescribed roots of unity, where K has arbitrary characteristic.

In characteristic zero one possibility is

sage: e**(2*pi/5)

I am not sure where this implicitly involves some limited precision in e and pi (which would probably be OK). Another option is

sage: K.<xi>=QQ.extension( cyclotomic_polynomial(5)); K
Number Field in xi with defining polynomial x^4 + x^3 + x^2 + x + 1
sage: xi==e**(2*pi/5)
False

Presumably one of these two options is better than the other.

In positive characteristic only the second option appears to be available:

sage: K.<xi>=GF(5).extension( cyclotomic_polynomial(5));K
Univariate Quotient Polynomial Ring in xi over Finite Field of size 5 with modulus xi^4 + xi^3 + xi^2 + xi + 1

All of the arithmetic appears to work fine here, however, sage doesn't seem to know that this is a field which makes me think that there may be a better way to do this. For example,

sage: K.is_field()
False
sage: K.is_finite()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)

/Users/andrew/Sage/<ipython console> in <module>()

/Applications/sage/local/lib/python2.6/site-packages/sage/rings/ring.so in sage.rings.ring.Ring.is_finite (sage/rings/ring.c:6011)()

NotImplementedError:

Cheers,
Andrew

Volker Braun

unread,
Apr 15, 2012, 2:23:10 PM4/15/12
to sage-s...@googlegroups.com
In characteristic zero there is a dedicated CyclotomicField. Presumably this is the most efficient implementation.

John Cremona

unread,
Apr 15, 2012, 3:15:58 PM4/15/12
to sage-s...@googlegroups.com
As Volker said, over Q specifically the right thing to do is use CyclotomicField():
sage: K.<z> = CyclotomicField(5)
sage: z^5
1
sage: CC(z)
0.309016994374947 + 0.951056516295154*I
sage: CC(z) == CC(exp(2*pi*i/5))
True

Note that the latter is True because Sage constructs Cyclotomic fields with a specified embedding into CC (complex field) in which the root of unity generating the fields does indeed map to exp(2*pi*i/n).

Over other fields it's no good just extending by a root of the n'th cyclotomic polynomial, since that need not be irreducible!  The example you gave was particularly unfortunate since over GF(5) the 5th cyclotomic poly has only 1 root with multiplicity 4.  So it's quite right to say that the resulting algebra is not a field.  (The question about Sage not being able to tell that the result is finite is unfortunate, and should be logged as a feature to be implemented., but is not particularly relevant to the current discussion).

I hope this helps,

John Cremona

Andrew Mathas

unread,
Apr 15, 2012, 6:20:55 PM4/15/12
to sage-s...@googlegroups.com
Thanks for the replies!


Over other fields it's no good just extending by a root of the n'th cyclotomic polynomial, since that need not be irreducible!  The example you gave was particularly unfortunate since over GF(5) the 5th cyclotomic poly has only 1 root with multiplicity 4.  So it's quite right to say that the resulting algebra is not a field.  (The question about Sage not being able to tell that the result is finite is unfortunate, and should be logged as a feature to be implemented., but is not particularly relevant to the current discussion).


I clearly shouldn't post these things late at night! In the context that I am working with a "primitive pth root of unity in characteristic p" is an important special case, but this corresponds to xi=1 so I can simply work with  GF(p).

For fields of characteristic p>0, I need to work in GF(p^a) for some a so I guess that my question really is: does anyone know how to construct the smallest extension of GF(p) which contains a primitive eth root of unity when gcd(e,p)=1?

Andrew

Andrew Mathas

unread,
Apr 15, 2012, 7:38:09 PM4/15/12
to sage-s...@googlegroups.com

For fields of characteristic p>0, I need to work in GF(p^a) for some a so I guess that my question really is: does anyone know how to construct the smallest extension of GF(p) which contains a primitive eth root of unity when gcd(e,p)=1?

Oops, when I phrase my question this way the answer becomes obvious.

Thanks,
A.
Reply all
Reply to author
Forward
0 new messages