ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 26 Oct 2013 09:43:37 +0200complex rectangular to polarhttps://ask.sagemath.org/question/10614/complex-rectangular-to-polar/I'm new to Sage. How do I convert a complex number like 2+3i into its polar form symbolically to get it in the form r.e^i.theta?Sat, 26 Oct 2013 07:25:45 +0200https://ask.sagemath.org/question/10614/complex-rectangular-to-polar/Answer by tmonteil for <p>I'm new to Sage. How do I convert a complex number like 2+3i into its polar form symbolically to get it in the form r.e^i.theta?</p>
https://ask.sagemath.org/question/10614/complex-rectangular-to-polar/?answer=15610#post-id-15610You can use `abs()` and `arg()` functions to compute modulus and argument of a symbolic complex number as follows:
sage: a = 2 + 3*I
sage: b = abs(a)*e^(I*(arg(a))) ; b
sqrt(13)*e^(I*arctan(3/2))
sage: bool(a == b)
True
In the other direction, you can use `real_part()` and `imag_part()`
sage: c = real_part(b) + I*imag_part(b) ; c
sqrt(13)*cos(real_part(arctan(3/2)))*e^(-imag_part(arctan(3/2))) + I*sqrt(13)*e^(-imag_part(arctan(3/2)))*sin(real_part(arctan(3/2)))
sage: c.simplify()
3*I + 2
Sat, 26 Oct 2013 09:43:37 +0200https://ask.sagemath.org/question/10614/complex-rectangular-to-polar/?answer=15610#post-id-15610