exp(I*pi*n).simplify_exp() doesn't work well

33 views
Skip to first unread message

Dan Drake

unread,
Sep 7, 2011, 11:23:32 PM9/7/11
to sage-support
This isn't quite what I hoped for:

sage: n = var('n')
sage: assume(n, 'integer')
sage: exp(I*n*pi).simplify_exp()
e^(I*pi*n)

Is there a way to get Sage/Maxima to turn that into cos(n*x)? It seems
like the integer assumption isn't filtering through.

Dan

--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------

signature.asc

Laurent

unread,
Sep 8, 2011, 1:37:19 AM9/8/11
to sage-s...@googlegroups.com
Le 08/09/2011 05:23, Dan Drake a �crit :

> This isn't quite what I hoped for:
>
>

sage: n = var('n')
> sage: assume(n, 'integer')
> sage: exp(I*n*pi).simplify_exp()
> e^(I*pi*n)

This workaround works :

sage: n = var('n')
sage: assume(n, 'integer')

sage: A=exp(I*n*pi)
sage: Abis=A.real_part()+I*A.imag_part() <--- this is the stupid part !!
sage: Abis.simplify_trig()
(-1)^n

Have a nice day
Laurent

achrzesz

unread,
Sep 8, 2011, 2:41:08 AM9/8/11
to sage-support
Also:

sage: n=var('n')
sage: assume(n,'integer')
sage: maxima('rectform(exp(%i*n*%pi))').sage().simplify_full()
(-1)^n

Andrzej Chrzeszczyk

Dan Drake

unread,
Sep 8, 2011, 3:22:52 AM9/8/11
to sage-s...@googlegroups.com
On Wed, 07 Sep 2011 at 11:41PM -0700, achrzesz wrote:
> Also:
>
> sage: n=var('n')
> sage: assume(n,'integer')
> sage: maxima('rectform(exp(%i*n*%pi))').sage().simplify_full()
> (-1)^n

That's a nice tip. I found a way to access rectform() "directly":

sage: A = exp(I*pi*n)
sage: A.maxima_methods().rectform()
(-1)^n

That's good enough for what I need. Thanks!

signature.asc

kcrisman

unread,
Sep 8, 2011, 9:16:42 AM9/8/11
to sage-support


On Sep 8, 3:22 am, Dan Drake <dr...@kaist.edu> wrote:
> On Wed, 07 Sep 2011 at 11:41PM -0700, achrzesz wrote:
> > Also:
>
> > sage: n=var('n')
> > sage: assume(n,'integer')
> > sage: maxima('rectform(exp(%i*n*%pi))').sage().simplify_full()
> > (-1)^n
>
> That's a nice tip. I found a way to access rectform() "directly":
>
> sage: A = exp(I*pi*n)
> sage: A.maxima_methods().rectform()
> (-1)^n
>

I dimly recall this as well. Dan or Andrzej, can you open a ticket
adding this example to our documentation somewhere? We may even want
to wrap rectform, though probably under a different name...

Thanks,
- kcrisman

Dan Drake

unread,
Sep 8, 2011, 8:11:33 PM9/8/11
to sage-s...@googlegroups.com
signature.asc
Reply all
Reply to author
Forward
0 new messages