math/sin
===============================================================================
%% Sine of argument in radians
1. Usage
-------------------------------------------------------------------------------
```mech:disabled
Y := math/sin(X)
```
2. Description
-------------------------------------------------------------------------------
Computes the sine of each element of `X`. The input `X` is interpreted in radians, not degrees. The result `Y` has the same shape as the input `X`.
3. Input
-------------------------------------------------------------------------------
| Argument | Kind | Description |
|----------|--------------------------|---------------------------------------|
| `X` | `float`, `[float]` | Input angle(s) specified in radians. Can be real or complex. If `X` is complex, sin returns complex results. |
4. Output
-------------------------------------------------------------------------------
| Argument | Kind | Description |
|----------|--------------------------|---------------------------------------|
| `Y` | matches input | Sine of the input values. If `X` is real, `Y` is real in the range `[-1,1]`. If `X` is complex, `Y` may have both real and imaginary parts. The shape of `Y` matches the shape of `X`. |
5. Examples
-------------------------------------------------------------------------------
(a) Find the sine of a number
```mech:ex1
y := math/sin(3.14)
```
(b) Find the sine for a vector of numbers
```mech:ex2
x := [0, 1.57, 3.14]
y := math/sin(x)
```
(c) Find the sine for a matrix of numbers
```mech:ex3
x := [0, 1; 3 4]
y := math/sin(x)
```
(d) Find the sine for a matrix of degrees
```mech:ex4
x := [0, 90; 180, 270]
y := math/sin(x * 3.14 / 180)
```
6. Details
-------------------------------------------------------------------------------
The sine function is a key idea in trigonometry, which studies the relationships between angles and sides of triangles.
In a right triangle, the sine of an angle $$x$$ is defined as the ratio of the length of the opposite side to the hypotenuse:
$$ sin(x) = \frac{\text{opposite}}{\text{hypotenuse}}
In the unit circle, which is a circle with a radius of 1 centered at the origin, the sine of an angle corresponds to the y-coordinate of a point on the circle at that angle.
For complex numbers, the sine function is defined using exponentials:
$$ sin(x) = \frac{e^{ix} - e^{-ix}}{2i}
This definition extends the sine function to work beyond real numbers, allowing it to handle complex inputs.