ID EN
Complex Math

phase

Python 3.11

Return the phase of x (also known as the argument of x), as a float. phase(x) is equivalent to math.atan2(x.imag, x.real). The result lies in the range [-π, π], and the branch cut for this operation lies along the negative real axis. The sign of the result is the same as the sign of x.imag, even when x.imag is zero:

Syntax

PYTHON
cmath.phase(x)

Examples

Example 1
PYTHON
>>> phase(complex(-1.0, 0.0))
3.141592653589793
>>> phase(complex(-1.0, -0.0))
-3.141592653589793