Python Tutorial Python Advanced Python References Python Libraries

Python cmath - phase() Function



The Python cmath.phase() function returns the phase of a complex number x as a float. It is also known as the argument of x and equivalent to math.atan2(x.imag, x.real). The returned value lies in the range [-𝜋, 𝜋].

Syntax

cmath.phase(x)

Parameters

x Required. Specify the complex number in rectangular co-ordinates.

Return Value

Returns the phase of a given complex number.

Example:

In the example below, phase() function is used to find out the phase of a given complex number.

import cmath

x = 3 + 4j
y = 3
z = 2j

print(cmath.phase(x))
print(cmath.phase(y))
print(cmath.phase(z))

The output of the above code will be:

0.9272952180016122
0.0
1.5707963267948966

❮ Python cMath Module