# megengine.functional.sin¶

sin(x)[源代码]

Element-wise $$\sin(x)$$ function.

Calculates an approximation to the sine 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 [-1, +1].

x – input tensor whose elements are each expressed in radians. Should have a floating-point data type.

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

>>> F.sin(0)
Tensor(0.0, device=xpux:0)


Element-wise sine:

>>> import math
>>> x = Tensor([0, math.pi/2, math.pi])
>>> F.sin(x)
Tensor([ 0.  1. -0.], device=xpux:0)