NumPy Tutorial NumPy Statistics NumPy References

NumPy - arctan() function



The NumPy arctan() function is used to calculate arc tangent (inverse tangent) of given value. The returned value will be in the range -𝜋/2 through 𝜋/2.

Syntax

numpy.arctan(x, out=None)

Parameters

x Required. Specify array (array_like) containing elements, of which the arc tangent is calculated.
out Optional. Specify a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.

Return Value

Returns the inverse tangent of each element in x.

Example:

In the example below, numpy arctan() function is used to calculate the inverse tangent of each element present in array tanArr.

import numpy as np

Arr = np.array([0, 30, 60, 90])
#converting the angles in radians
Arr = Arr*np.pi/180

tanArr = np.tan(Arr)
inv_tanArr = np.arctan(tanArr)
print("The tan value of angles:")
print(tanArr)
print("The inverse of the tan value (in radians):")
print(inv_tanArr)
print("The inverse of the tan value (in degrees):")
print(np.degrees(inv_tanArr))

The output of the above code will be:

The tan value of angles:
[  0.00000000e+00   5.77350269e-01   1.73205081e+00   1.63312394e+16]
The inverse of the tan value (in radians):
[ 0.          0.52359878  1.04719755  1.57079633]
The inverse of the tan value (in degrees):
[  0.  30.  60.  90.]

❮ NumPy - Functions