megengine.functional.sin#

sin(x)[source]#

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

Parameters:

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

Returns:

a tensor containing the sine of each element in \(x\). The returned tensor must have a floating-point data type determined by Type promotion rules.

Examples

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