
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Return the angle of the complex argument in radians 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. The 1st parameter z, A complex number or sequence of complex numbers. The 2nd parameter, deg, return angle in degrees if True, radians if False (default).
Steps
At first, import the required libraries −
import numpy as np
Create an array using the array() method −
arr = np.array([1.0, 1.0j, 1+1j])
Display the array −
print("Array...\n", arr)
Get the type of the array −
print("\nOur Array type...\n", arr.dtype)
Get the dimensions of the Array −
print("\nOur Array Dimension...\n",arr.ndim)
Get the shape of the Array −
print("\nOur Array Shape...\n",arr.shape)
To return the angle of the complex argument, use the numpy.angle() method in Python Numpy. 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 −
print("\nResult (radians)...\n", np.angle(arr))
Example
import numpy as np # Create an array using the array() method arr = np.array([1.0, 1.0j, 1+1j]) # Display the array print("Array...\n", arr) # Get the type of the array print("\nOur Array type...\n", arr.dtype) # Get the dimensions of the Array print("\nOur Array Dimension...\n",arr.ndim) # Get the shape of the Array print("\nOur Array Shape...\n",arr.shape) # To return the angle of the complex argument, use the numpy.angle() method in Python Numpy # 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. print("\nResult (radians)...\n", np.angle(arr))
Output
Array... [1.+0.j 0.+1.j 1.+1.j] Our Array type... complex128 Our Array Dimension... 1 Our Array Shape... (3,) Result (radians)... [0. 1.57079633 0.78539816]
- Related Articles
- Return the angle of the complex argument in Python
- Return the angle of the complex argument in degrees in Python
- Return the imaginary part of the complex argument in Python
- Return the real part of the complex argument in Python
- Change the real part of the complex argument in Python
- Change the imaginary part of the complex argument in Python
- Return the square of the complex-value input in Python
- Return the reciprocal of the argument element-wise in Numpy
- Return the base 2 logarithm for complex value input in Python
- degrees() and radians() in Python
- Return the default fill value for the argument object in Numpy
- How to set the Y-axis in radians in a Python plot?
- Return an element-wise indication of the sign of complex types in Numpy
- Get the angle whose sine is float value argument in C#
- Return the element-wise square-root of a complex type array in Numpy
