numpy.angle() in Python (original) (raw)
Last Updated : 28 Nov, 2018
numpy.angle()
function is used when we want to compute the angle of the complex argument. A complex number is represented by “ x + yi ” where x and y are real number and i= (-1)^1/2
. The angle is calculated by the formula tan-1(x/y).
Syntax : numpy.angle(z, deg=0)
Parameters :
z : [array_like] A complex number or sequence of complex numbers.
deg : [bool, optional] Return angle in degrees if True, radians if False (default).Return :
angle : The counterclockwise angle from the positive real axis on the complex plane, with dtype as numpy.float64.
Code #1 : Working
import
numpy as geek
in_list
=
[
2.0
,
1.0j
,
1
+
1j
]
print
(
"Input list : "
, in_list)
out_angle
=
geek.angle(in_list)
print
(
"output angle in radians : "
, out_angle)
Output :
Input list : [2.0, 1j, (1+1j)] output angle in radians : [ 0. 1.57079633 0.78539816]
Code #2 : Working
import
numpy as geek
in_list
=
[
2.0
,
1.0j
,
1
+
1j
]
print
(
"Input list : "
, in_list)
out_angle
=
geek.angle(in_list, deg
=
True
)
print
(
"output angle in degrees : "
, out_angle)
Output :
Input list : [2.0, 1j, (1+1j)] output angle in degrees : [ 0. 90. 45.]
Similar Reads
- numpy.eye() in Python numpy.eye() is a function in the NumPy library that creates a 2D array with ones on the diagonal and zeros elsewhere. This function is often used to generate identity matrices with ones along the diagonal and zeros in all other positions. Let's understand with the help of an example: [GFGTABS] Pytho 2 min read
- numpy.arctan() in Python numpy.arctan(x[, out]) = ufunc 'arctan') : This mathematical function helps user to calculate inverse tangent for all x(being the array elements). Parameters : array : [array_like]elements are in radians. out : [array_like]array of same shape as x. Note : 2pi Radians = 360 degrees The convention is 2 min read
- numpy.arcsin() in Python numpy.arcsin(x[, out]) = ufunc 'arcsin') : This mathematical function helps user to calculate inverse sine for all x(being the array elements). Parameters : array : [array_like]elements are in radians. out : [array_like]array of same shape as x. Return : An array with inverse sine of x for all x i.e 2 min read
- numpy.absolute() in Python numpy.absolute(arr, out = None, ufunc 'absolute') : This mathematical function helps user to calculate absolute value of each element. For complex input, a + ib, the absolute value is [TEX] \sqrt { a^2 + b^2 }[/TEX]. Parameters : arr : [array_like] Input array or object whose elements, we need to te 2 min read
- numpy.arctan2() in Python The numpy.arctan2() method computes element-wise arc tangent of arr1/arr2 choosing the quadrant correctly. The quadrant is chosen so that arctan2(x1, x2) is the signed angle in radians between the ray ending at the origin and passing through the point (1, 0), and the ray ending at the origin and pas 2 min read
- numpy.arcsinh() in Python numpy.arcsinh() : This mathematical function helps user to calculate inverse hyperbolic sine, element-wise for all arr. Syntax : numpy.arcsinh(arr, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, ufunc 'arcsinh') Parameters : arr : array_like Input array. out : [ndarray, opti 2 min read
- numpy.arctanh in Python() numpy.arctanh() : This mathematical function helps user to calculate inverse hyperbolic tangent, element-wise for all arr. Syntax : numpy.arctanh(arr, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, ufunc 'arctanh') Parameters : arr : array_like Input array. out : [ndarray, o 2 min read
- NumPy Array in Python NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C 2 min read
- numpy.cos() in Python numpy.cos(x[, out]) = ufunc 'cos') : This mathematical function helps user to calculate trigonometric cosine for all x(being the array elements). Parameters : array : [array_like]elements are in radians. 2pi Radians = 360 degrees Return : An array with trigonometric cosine of x for all x i.e. array 2 min read
- numpy.arccos() in Python numpy.arccos(x[, out]) = ufunc 'arccos') : This mathematical function helps user to calculate inverse cos for all x(being the array elements). Parameters : array : [array_like]elements are in radians. out : [array_like]array of same shape as x. Note : 2pi Radians = 360 degrees The convention is to r 2 min read