D A
D A

Reputation: 3438

Python Sympy angle of a complex number?

What is the sympy function to obtain the angle of a complex number?

In numpy, I can do:

numpy.angle(complexnumber)

In sympy, I want to just be able to take the angle of an expression:

sympy.givemeangle(sympyexpression_whichevaluatestoacomplexnumber)

I suppose I could implement my own logic to check which quadrant the number is in, and then deal with inverse tan function depending on the coord... but I would really like to just not know what quadrant an expression ends up being in, and be able to think of the expression's angle.

What should I do here?

Upvotes: 2

Views: 2901

Answers (1)

D A
D A

Reputation: 3438

I got it!

n = sympyexpression_whichevaluatestoacomplexnumber
expressionangle = sympy.arg( n )

Also a slight modification of Tom's suggestion works:

expressionangle2 = sympy.log( n ).as_real_imag()[1]

Thanks for help!

Upvotes: 1

Related Questions