primitive k-th root of unity

1,259 views
Skip to first unread message

mac8090

unread,
Jul 14, 2009, 6:37:47 AM7/14/09
to sage-support

For a given k, is it possible to instantly get an k-th root of unity
in sage without making extra fields, or by using e^(2*pi*I/k)?

On a similar note, anybody know why I can't get sage to equate e^
(theta*I) == cos(theta) + I*sin(theta) ?

davidloeffler

unread,
Jul 14, 2009, 9:02:06 AM7/14/09
to sage-support
On Jul 14, 11:37 am, mac8090 <bonzerpot...@hotmail.com> wrote:
> For a given k, is it possible to instantly get an k-th root of unity
> in sage without making extra fields, or by using e^(2*pi*I/k)?

I'm curious why you are so opposed to creating a number field.
Basically, there are three one-liners you can use:

CyclotomicField(k).gen() -- creates a number field element.
CC.zeta(k) -- creates an inexact, fixed-precision approximation.
QQbar.zeta(k) -- a clever hybrid, which behaves like an element of CC
but also remembers that it's algebraic and can calculate itself to
arbitrary precision if you ask it to.

David

David Joyner

unread,
Jul 14, 2009, 9:41:13 AM7/14/09
to sage-s...@googlegroups.com
On Tue, Jul 14, 2009 at 6:37 AM, mac8090<bonzer...@hotmail.com> wrote:
>
>
> For a given k, is it possible to instantly get an k-th root of unity
> in sage without making extra fields, or by using e^(2*pi*I/k)?


I'm a bit confused by your question. If you mean k-th roots of unity in
the complex field CC then

sage: z = e^(2*pi*I/7)
sage: z^7
1

works for me. If youmean the kth roots of unity in some other field
(after all, every field contains 0 and 1) then you should specify the
field to determine where you want the roots of x^k-1=0 to lie.



>
> On a similar note, anybody know why I can't get sage to equate e^
> (theta*I) == cos(theta) + I*sin(theta) ?


I don't know. Sage uses Maxima. Does maxima know Euler's formula?


> >
>

Laurent

unread,
Jul 19, 2009, 12:14:27 PM7/19/09
to sage-s...@googlegroups.com

>> On a similar note, anybody know why I can't get sage to equate e^
>> (theta*I) == cos(theta) + I*sin(theta) ?
>>
>
>
> I don't know. Sage uses Maxima. Does maxima know Euler's formula?
>
>
I suppose that Sage knows Euler's formula because

sage: var('x')
x
sage: real_part(e^(I*x))
e^(-imag_part(x))*cos(real_part(x))


but :

sage: var('x')
x
sage: assume(imag_part(x)==0)
sage: real_part(e^(I*x))
e^(-imag_part(x))*cos(real_part(x))

seems strange to me.
Does someone know how to make Sage understand that x is real and that
e^(i*x) = cos(x)+I*sin(x) ??

Good afternoon
Laurent


Reply all
Reply to author
Forward
0 new messages