Return the angle of the complex argument in Python

To return the angle of the complex argument, use the numpy.angle() method in Python. The method returns the counterclockwise angle from the positive real axis on the complex plane in the range (-pi, pi], with dtype as numpy.float64.

Syntax

numpy.angle(z, deg=False)

Parameters

  • z ? A complex number or sequence of complex numbers
  • deg ? Return angle in degrees if True, radians if False (default)

Basic Example

Let's create an array of complex numbers and find their angles ?

import numpy as np

# Create an array of complex numbers
arr = np.array([1.0, 1.0j, 1+1j])

print("Array...")
print(arr)

print("\nAngles in radians:")
print(np.angle(arr))
Array...
[1.+0.j 0.+1.j 1.+1.j]

Angles in radians:
[0.         1.57079633 0.78539816]

Angles in Degrees

Set the deg parameter to True to get angles in degrees ?

import numpy as np

# Complex numbers
complex_nums = np.array([1+0j, 0+1j, 1+1j, -1+0j, 0-1j])

print("Complex numbers:")
print(complex_nums)

print("\nAngles in degrees:")
print(np.angle(complex_nums, deg=True))

print("\nAngles in radians:")
print(np.angle(complex_nums, deg=False))
Complex numbers:
[ 1.+0.j  0.+1.j  1.+1.j -1.+0.j  0.-1.j]

Angles in degrees:
[  0.  90.  45. 180. -90.]

Angles in radians:
[ 0.          1.57079633  0.78539816  3.14159265 -1.57079633]

Understanding the Results

The angles correspond to the position of each complex number on the complex plane ?

  • 1+0j lies on positive real axis ? 0°
  • 0+1j lies on positive imaginary axis ? 90°
  • 1+1j lies in first quadrant ? 45°
  • -1+0j lies on negative real axis ? 180°
  • 0-1j lies on negative imaginary axis ? -90°

Working with Individual Complex Numbers

You can also find the angle of a single complex number ?

import numpy as np

# Single complex number
z = 3 + 4j

print(f"Complex number: {z}")
print(f"Angle in radians: {np.angle(z)}")
print(f"Angle in degrees: {np.angle(z, deg=True)}")
Complex number: (3+4j)
Angle in radians: 0.9272952180016122
Angle in degrees: 53.13010235415598

Conclusion

The numpy.angle() method efficiently calculates the phase angle of complex numbers. Use deg=True for degrees or deg=False (default) for radians. The angles range from -? to ? radians (-180° to 180°).

Updated on: 2026-03-26T19:33:33+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements