Ask Your Question

Revision history [back]

You 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
sage: bool(a == b)

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