Ask Your Question
2

Complex argument of a symbolic expression

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

Juanlu001 gravatar image

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

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

1 Answer

Sort by ยป oldest newest most voted
1

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

parzan gravatar image

You can do this:

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

Comments

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 +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!!

GaryMak gravatar imageGaryMak ( 2013-04-23 15:16:58 +0100 )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

Stats

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

Seen: 1,837 times

Last updated: Nov 15 '11