math/cos
===============================================================================
%% Cosine of argument in radians
1. Usage
-------------------------------------------------------------------------------
```mech:disabled
Y := math/cos(X)
```
2. Description
-------------------------------------------------------------------------------
Computes the cosine 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, cos returns complex results. |
4. Output
-------------------------------------------------------------------------------
| Argument | Kind | Description |
|----------|--------------------------|---------------------------------------|
| `Y` | matches input | Cosine 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 cosine of a number
```mech:ex1
y := math/cos(3.14)
```
(b) Find the cosine for a vector of numbers
```mech:ex2
x := [0, 1.57, 3.14]
y := math/cos(x)
```
(c) Find the cosine for a matrix of numbers
```mech:ex3
x := [0, 1; 3 4]
y := math/cos(x)
```
(d) Find the cosine for a matrix of degrees
```mech:ex4
x := [0, 90; 180, 270]
y := math/cos(x * 3.14 / 180)
```
6. Details
-------------------------------------------------------------------------------
The cosine function is a key idea in trigonometry, which studies the relationships between angles and sides of triangles.
In a right triangle, the cosine of an angle x is defined as the ratio of the length of the adjacent side to the hypotenuse:
$$ cos(x) = \frac{\text{adjacent}}{\text{hypotenuse}}
In the unit circle, which is a circle with a radius of 1 centered at the origin, the cosine of an angle corresponds to the x-coordinate of a point on the circle at that angle.
For complex numbers, the cosine function is defined using exponentials:
$$ cos(x) = \frac{e^{ix} - e^{-ix}}{2i}
This definition extends the cosine function to work beyond real numbers, allowing it to handle complex inputs.