📅  最后修改于: 2023-12-03 15:04:06.791000             🧑  作者: Mango
numpy.tan()
The numpy.tan()
function is used to compute the tangent of an input array or scalar angle in radians. It is part of the NumPy library, which is a fundamental package for scientific computing in Python.
numpy.tan(x, out=None)
x
: The input angle in radians, which can be an array or a scalar.out
(optional): An alternative output array in which to place the result. It must have the same shape as the input.The numpy.tan()
function returns an array with elements representing the tangent of each corresponding element in the input array.
To use numpy.tan()
, you need to import the NumPy library:
import numpy as np
angle = np.pi/3
result = np.tan(angle)
print(result)
Output:
1.7320508075688767
angles = np.array([0, np.pi/4, np.pi/2])
result = np.tan(angles)
print(result)
Output:
[ 0.00000000e+00 1.00000000e+00 1.63312394e+16]
numpy.tan()
function returns an array with dtype float64
. To specify a different dtype, use the dtype
argument.numpy.radians()
function.For more information and options, refer to the official NumPy documentation.
Remember to consult the NumPy documentation and experiment with the function to explore its full capabilities.