The numpy.tan() method in Python returns the tangent of a list of numbers. This is equal to numpy.sin(x) / numpy.cos(x).
The visual representation of the tangent () is as follows.
numpy.tan(x, out=None)
x: This method takes an array of numbers as the input.out=None: This is an optional parameter in numpy.tan() function. This could be ndarray, None, or tuple of the ndarray. This parameter identifies a location where the solution is stored.This method returns a ndarray containing the tangent values of radian numbers from the input. The output may be scalar if the input is scalar.
import numpy as np# Creating an arrayarray = np.array([0, np.pi/2, np.pi])#Calculating the tangent of the valuesresult = np.tan(array)#Using the out parameternew_result = np.array([0, np.pi/2, np.pi])np.tan(array, out = new_result)print("Tengant of values : ", result)print("New Result array : ", new_result)
np.array method.array.new_result array using the out parameter.Note: Providing the
outparameter innumpy.tan()function stores the result in theoutparameter and returns a reference to it.
Free Resources