megengine.functional.tan¶
- tan(x)[source]¶
Element-wise \(\tan(x)\) function.
Calculates an approximation to the tangent for each element \(x_i\) of the input tensor \(x\). Each element \(x_i\) is assumed to be expressed in radians.
This function has domain
(-infinity, +infinity)
and codomain(-infinity, +infinity)
.- Parameters
x – input tensor whose elements are each expressed in radians. Should have a floating-point data type.
- Returns
a tensor containing the tangent of each element in \(x\). The returned tensor must have a floating-point data type determined by Type promotion rules.
Special cases
For floating-point operands,
If \(x_i\) is
NaN
, the result isNaN
.If \(x_i\) is
+0
, the result is+0
.If \(x_i\) is
-0
, the result is-0
.If \(x_i\) is either
+infinity
or-infinity
, the result isNaN
.
Examples
>>> F.tan(0) Tensor(0.0, device=xpux:0)
Element-wise tangent:
>>> import math >>> x = Tensor([0, math.pi/4, math.pi]) >>> F.tan(x) Tensor([0. 1. 0.], device=xpux:0)