NumPy - tan() function
The NumPy tan() function is used to calculate trigonometric tangent of given angle in radians.
Syntax
numpy.tan(x, out=None)
Parameters
x |
Required. Specify array (array_like) containing elements as angles in radians of which the trigonometric 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 tangent of each element of x.
Example:
In the example below, numpy tan() function is used to calculate the tangent of each element present in array Arr.
import numpy as np Arr = np.array([0, 30, 60, 90]) #converting the angles in radians Arr = Arr*np.pi/180 print("The tan value of angles:") print(np.tan(Arr))
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]
❮ NumPy - Functions