megengine.functional.atan¶
- atan(x)[source]¶
Element-wise \(\arctan(x)\) function.
Calculates an approximation to the inverse tangent for each element \(x_i\) of the input tensor \(x\). Each element-wise result is expressed in radians.
This function has domain
(-infinity, +infinity)and codomain[-pi/2, pi/2].The inverse of \(\tan\) so that, if \(y = \tan(x)\), then \(x = \arctan(y)\).
- Parameters
x – input tensor. Should have a floating-point data type.
- Returns
a tensor containing the inverse 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
+infinity, the result is an approximation to+π/2.If \(x_i\) is
-infinity, the result is an approximation to-π/2.
Examples
>>> F.atan(0) Tensor(0.0, device=xpux:0)
Element-wise inverse tangent:
>>> x = Tensor([0, 1, -1]) >>> F.atan(x) Tensor([ 0. 0.7854 -0.7854], device=xpux:0)