In NumPy, a library of the high-level programming language Python, the tan
function can be used to calculate the tan
of a given angle.
The NumPy
library must be imported to use the tan
function.
import numpy as np
np.tan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'tan'>
A universal function (ufunc) is a function that operates on ndarrays in an element-by-element fashion. The
tan
method is a universal function.
The tan
function only accepts the following arguments.
x
: array-like structure on the contents of which the tan
function will be applied.out
(optional): the function’s output is stored at this location.where
(optional): if set True
, a universal function is calculated at this position.casting
(optional): enables the user to decide how the data will be cast. If set as same_kind
, safe casting will take place.order
(optional): determines the memory layout of the output. For example, if set as K, the function reads data in the order they are written in memory.dtype
(optional): the data type of the array.subok
(optional): to pass subclasses, subok
must be set as True
.Returns an ndarray that contains the tan
of the value(s) passed as arguments.
If
x
is scalar, the return value is also scalar.
The following example demonstrates how the tan
function may be implemented on an array of angle values.
import numpy as nparr = np.tan([360, 270, 180, 90, 0])print(arr)
Free Resources