> ## Documentation Index
> Fetch the complete documentation index at: https://numpyts.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Trigonometric

> Element-wise trigonometric functions and angle conversions.

All trigonometric functions operate element-wise. Angles are in radians unless otherwise noted.

### sin

Compute the sine, element-wise.

```typescript theme={null}
function sin(x: NDArray): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | - | Angle in radians. |

**Returns:** `NDArray` -- Sine of each element.

```typescript Full Library theme={null}
import * as np from 'numpy-ts';

const a = np.sin(np.array([0, Math.PI / 2, Math.PI]));
// array([0, 1, ~0])
```

```typescript Core theme={null}
import { sin, array } from 'numpy-ts/core';

const a = sin(array([0, Math.PI / 2, Math.PI]));
```

***

### cos

Compute the cosine, element-wise.

```typescript theme={null}
function cos(x: NDArray): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | - | Angle in radians. |

**Returns:** `NDArray` -- Cosine of each element.

```typescript Full Library theme={null}
import * as np from 'numpy-ts';

const a = np.cos(np.array([0, Math.PI / 2, Math.PI]));
// array([1, ~0, -1])
```

```typescript Core theme={null}
import { cos, array } from 'numpy-ts/core';

const a = cos(array([0, Math.PI / 2, Math.PI]));
```

***

### tan

Compute the tangent, element-wise.

```typescript theme={null}
function tan(x: NDArray): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | - | Angle in radians. |

**Returns:** `NDArray` -- Tangent of each element.

```typescript Full Library theme={null}
import * as np from 'numpy-ts';

const a = np.tan(np.array([0, Math.PI / 4]));
// array([0, 1])
```

```typescript Core theme={null}
import { tan, array } from 'numpy-ts/core';

const a = tan(array([0, Math.PI / 4]));
```

***

### arcsin

Compute the inverse sine, element-wise. Also available as the alias `asin`.

```typescript theme={null}
function arcsin(x: NDArray): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | - | Values in the range `[-1, 1]`. |

**Returns:** `NDArray` -- Angle in radians, in the range `[-pi/2, pi/2]`.

```typescript Full Library theme={null}
import * as np from 'numpy-ts';

const a = np.arcsin(np.array([0, 0.5, 1]));
// array([0, 0.5236..., 1.5708...])  -- 0, pi/6, pi/2

// Alias
const b = np.asin(np.array([0, 1]));
```

```typescript Core theme={null}
import { arcsin, array } from 'numpy-ts/core';
// or: import { asin } from 'numpy-ts/core';

const a = arcsin(array([0, 0.5, 1]));
```

***

### arccos

Compute the inverse cosine, element-wise. Also available as the alias `acos`.

```typescript theme={null}
function arccos(x: NDArray): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | - | Values in the range `[-1, 1]`. |

**Returns:** `NDArray` -- Angle in radians, in the range `[0, pi]`.

```typescript Full Library theme={null}
import * as np from 'numpy-ts';

const a = np.arccos(np.array([1, 0, -1]));
// array([0, 1.5708..., 3.1416...])  -- 0, pi/2, pi

// Alias
const b = np.acos(np.array([1, 0]));
```

```typescript Core theme={null}
import { arccos, array } from 'numpy-ts/core';

const a = arccos(array([1, 0, -1]));
```

***

### arctan

Compute the inverse tangent, element-wise. Also available as the alias `atan`.

```typescript theme={null}
function arctan(x: NDArray): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | - | Input values. |

**Returns:** `NDArray` -- Angle in radians, in the range `[-pi/2, pi/2]`.

```typescript Full Library theme={null}
import * as np from 'numpy-ts';

const a = np.arctan(np.array([0, 1, -1]));
// array([0, 0.7854..., -0.7854...])  -- 0, pi/4, -pi/4

// Alias
const b = np.atan(np.array([0, 1]));
```

```typescript Core theme={null}
import { arctan, array } from 'numpy-ts/core';

const a = arctan(array([0, 1, -1]));
```

***

### arctan2

Compute the two-argument inverse tangent, element-wise. Returns the angle of the point `(x2, x1)` with the positive x-axis. Also available as the alias `atan2`.

```typescript theme={null}
function arctan2(x1: NDArray, x2: NDArray | number): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x1` | `NDArray` | - | y-coordinates. |
| `x2` | `NDArray \| number` | - | x-coordinates. |

**Returns:** `NDArray` -- Angle in radians, in the range `[-pi, pi]`.

```typescript Full Library theme={null}
import * as np from 'numpy-ts';

// Angle of (1, 1) is pi/4
const a = np.arctan2(np.array([1, 0, -1]), np.array([1, 1, 0]));
// array([0.7854..., 0, -1.5708...])

// Alias
const b = np.atan2(np.array([1]), np.array([1]));
```

```typescript Core theme={null}
import { arctan2, array } from 'numpy-ts/core';

const a = arctan2(array([1, 0, -1]), array([1, 1, 0]));
```

***

### hypot

Compute the hypotenuse `sqrt(x1**2 + x2**2)`, element-wise. Avoids overflow for large values.

```typescript theme={null}
function hypot(x1: NDArray, x2: NDArray | number): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x1` | `NDArray` | - | First leg of the triangle. |
| `x2` | `NDArray \| number` | - | Second leg of the triangle. |

**Returns:** `NDArray` -- Element-wise hypotenuse.

```typescript Full Library theme={null}
import * as np from 'numpy-ts';

const a = np.hypot(np.array([3, 5, 0]), np.array([4, 12, 1]));
// array([5, 13, 1])
```

```typescript Core theme={null}
import { hypot, array } from 'numpy-ts/core';

const a = hypot(array([3, 5]), array([4, 12]));
```

***

### degrees

Convert angles from radians to degrees. Equivalent to `rad2deg`.

```typescript theme={null}
function degrees(x: NDArray): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | - | Angles in radians. |

**Returns:** `NDArray` -- Angles in degrees.

```typescript Full Library theme={null}
import * as np from 'numpy-ts';

const a = np.degrees(np.array([0, Math.PI / 2, Math.PI]));
// array([0, 90, 180])
```

```typescript Core theme={null}
import { degrees, array } from 'numpy-ts/core';

const a = degrees(array([0, Math.PI / 2, Math.PI]));
```

***

### radians

Convert angles from degrees to radians. Equivalent to `deg2rad`.

```typescript theme={null}
function radians(x: NDArray): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | - | Angles in degrees. |

**Returns:** `NDArray` -- Angles in radians.

```typescript Full Library theme={null}
import * as np from 'numpy-ts';

const a = np.radians(np.array([0, 90, 180, 360]));
// array([0, 1.5708..., 3.1416..., 6.2832...])
```

```typescript Core theme={null}
import { radians, array } from 'numpy-ts/core';

const a = radians(array([0, 90, 180, 360]));
```

***

### deg2rad

Convert angles from degrees to radians. Equivalent to `radians`.

```typescript theme={null}
function deg2rad(x: NDArray): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | - | Angles in degrees. |

**Returns:** `NDArray` -- Angles in radians.

***

### rad2deg

Convert angles from radians to degrees. Equivalent to `degrees`.

```typescript theme={null}
function rad2deg(x: NDArray): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | - | Angles in radians. |

**Returns:** `NDArray` -- Angles in degrees.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.