mygrad.sin#
- class mygrad.sin(x: ArrayLike, out: Tensor | ndarray | None = None, *, where: Mask = True, dtype: DTypeLikeReals = None, constant: bool | None = None)#
Trigonometric sine, element-wise.
This docstring was adapted from that of numpy.sin [1]
- Parameters:
- xArrayLike
Angle, in radians (\(2 \pi\) rad equals 360 degrees).
- outOptional[Union[Tensor, ndarray]]
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated tensor is returned.
- constantOptional[bool]
If
True
, this tensor is treated as a constant, and thus does not facilitate back propagation (i.e.constant.grad
will always returnNone
).Defaults to
False
for float-type data. Defaults toTrue
for integer-type data.Integer-type tensors must be constant.
- whereMask
This condition is broadcast over the input. At locations where the condition is True, the
out
tensor will be set to the ufunc result. Elsewhere, theout
tensor will retain its original value. Note that if an uninitialized out tensor is created via the defaultout=None
, locations within it where the condition is False will remain uninitialized.- dtypeOptional[DTypeLikeReals]
The dtype of the resulting tensor.
- Returns:
- yTensor
The sine of each element of x.
Notes
The sine is one of the fundamental functions of trigonometry (the mathematical study of triangles). Consider a circle of radius 1 centered on the origin. A ray comes in from the \(+x\) axis, makes an angle at the origin (measured counter-clockwise from that axis), and departs from the origin. The \(y\) coordinate of the outgoing ray’s intersection with the unit circle is the sine of that angle. It ranges from -1 for \(x=3\pi / 2\) to +1 for \(\pi / 2.\) The function has zeroes where the angle is a multiple of \(\pi\). Sines of angles between \(\pi\) and \(2\pi\) are negative. The numerous properties of the sine and related functions are included in any standard trigonometry text.
References
[1]Retrieved from https://numpy.org/doc/stable/reference/generated/numpy.sin.html
Examples
>>> import mygrad as mg >>> mg.sin(mg.pi/2.) Tensor(1.0)
Print sines of an array of angles given in degrees:
>>> mg.sin(mg.tensor((0., 30., 45., 60., 90.)) * mg.pi / 180. ) Tensor([ 0. , 0.5 , 0.70710678, 0.8660254 , 1. ])
- Attributes:
- identity
- signature
Methods
accumulate
([axis, dtype, out, constant])Not implemented
at
(indices[, b, constant])Not implemented
outer
(b, *[, dtype, out])Not Implemented
reduce
([axis, dtype, out, keepdims, ...])Not Implemented
reduceat
(indices[, axis, dtype, out])Not Implemented
resolve_dtypes
(dtypes, *[, signature, ...])Find the dtypes NumPy will use for the operation.
- __init__(*args, **kwargs)#
Methods
__init__
(*args, **kwargs)accumulate
([axis, dtype, out, constant])Not implemented
at
(indices[, b, constant])Not implemented
outer
(b, *[, dtype, out])Not Implemented
reduce
([axis, dtype, out, keepdims, ...])Not Implemented
reduceat
(indices[, axis, dtype, out])Not Implemented
resolve_dtypes
(dtypes, *[, signature, ...])Find the dtypes NumPy will use for the operation.
Attributes
identity
nargs
nin
nout
ntypes
signature
types