# Complex argument of a symbolic expression

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'


But:

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


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 close merge delete

Sort by ยป oldest newest most voted

You can do this:

sage: z = i + 1.0
sage: arg(z)
0.785398163397

more

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

( 2011-12-05 17:25:00 +0100 )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!!

( 2013-04-23 15:16:58 +0100 )edit