# megengine.functional.atan¶

atan(x)[源代码]

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)$$.

x – input tensor. Should have a floating-point data type.

a tensor containing the inverse tangent of each element in $$x$$. The returned tensor must have a floating-point data type determined by 类型提升规则.

Special cases

For floating-point operands,

• If $$x_i$$ is NaN, the result is NaN.

• 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.

>>> 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)