Ask Your Question

Complex argument of a symbolic expression

asked 2011-11-15 13:06:02 +0200

Juanlu001 gravatar image

updated 2011-11-15 13:09:17 +0200

I was wondering how could I get the argument of an expression involving complex numbers. For example, this simple case fails at first:

sage: z = i + 1.0
sage: z.argument() 

Traceback (most recent call last):
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'argument'


sage: i = CC.0
sage: z = i + 1.0
sage: z.argument() * 180 / pi.n()

As you can see in this worksheet.

Of course, if the expression involves symbolic variables and such the same problem appears. Is there any direct way I can calculate the complex argument of a symbolic expression?

I mean, apart from

atan(z.imag() / z.real())

of course.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-11-15 13:54:02 +0200

parzan gravatar image

You can do this:

sage: z = i + 1.0
sage: arg(z)
edit flag offensive delete link more


Hm, works in this case, but it seems I still have problems with plot(), for example. Thank you anyway!

Juanlu001 gravatar imageJuanlu001 ( 2011-12-05 17:25:00 +0200 )edit

Is there any way of doing the original thing Juanlu asked - eg if I write z=exp(2*pi*i/17) then I would like to get z.arg() = 2*pi/17, not some horrid numerical approximation!!

GaryMak gravatar imageGaryMak ( 2013-04-23 15:16:58 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-11-15 13:06:02 +0200

Seen: 1,712 times

Last updated: Nov 15 '11