# Math

### Constants

#### pi

The ratio of a circle's circumference to its diameter, approximately 3.14.

Can also be represented by the Unicode symbol `π`.

#### tau

Equal to 2π (approximately 6.28), representing the ratio of a circle's circumference to its radius.

Can also be represented by the Unicode symbol `τ`.

#### e

The base of natural logarithms, approximately 2.72.

Can also be represented by the Unicode symbol `ℯ`.

#### phi

The golden ratio, approximately 1.618.

Can also be represented by the Unicode symbol `φ`.

### Arithmetic Operators

#### neg n

Changes the sign of `n` if possible. Accepts integer, float, and complex types.

Equivalent to the `(-)` unary operator.

Example:

```ocaml
three = neg -3
three = -(-3)
```

#### add x y

Adds `x` and `y` together if possible. Accepts integer, float, and complex types.

Equivalent to the `(+)` binary operator.

Example:

```ocaml
three = add 1 2
three = (+) 1 2
three = 1 + 2
```

#### sub x y

Subtracts `x` from `y`  if possible. Accepts integer, float, and complex types.

Equivalent to the `(-)` binary operator.

Example:

```ocaml
three = sub 5 2
three = (-) 5 2
three = 5 - 2
```

#### mul x y

Multiplies `x` and `y`  if possible. Accepts integer, float, and complex types.

Equivalent to the `(*)` binary operator.

Example:

```ocaml
six = mul 2 3
six = (*) 2 3
six = 2 * 3
```

#### div x y

Divides `x` by `x`  if possible. Accepts integer, float, and complex types.

Equivalent to the `(/)` binary operator.

Example:

```ocaml
three = div 6 2
three = (/) 6 2
three = 6 / 2
```

#### mod x y

Returns the remainder of `x` divided by `y`  if possible. Accepts integer, float, and complex types.

Equivalent to the `(%)` binary operator.

Example:

```ocaml
one = mod 5 2
one = (%) 5 2
one = 5 % 2
```

#### pow x y

Returns `x` to the power of `y`  if possible. Accepts integer, float, and complex types.

Equivalent to the `(**)` binary operator.

Example:

```ocaml
nine = pow 3 2
nine = (**) 3 2
nine = 3 ** 2
```

### Bitwise Operators

#### bitnot n

Inverts the bits of `n`. Accepts only integers.

Equivalent to the `(~)` unary operator.

Example:

```ocaml
one = bitnot -2
one = (~) -2
one = ~-2
```

#### bitand x y

Performs a bitwise AND operation on `x`  and `y`. Accepts only integers.

Equivalent to the `(&)` binary operator.

Example:

```ocaml
one = bitand 5 3
one = (&) 5 3
one = 5 & 3
```

#### bitor x y

Performs a bitwise OR operation on `x`  and `y`. Accepts only integers.

Equivalent to the `(|)` binary operator.

Example:

```ocaml
seven = bitor 5 3
seven = (|) 5 3
seven = 5 | 3
```

#### bitxor x y

Performs a bitwise XOR operation on `x`  and `y`. Accepts only integers.

Equivalent to the `(^)` binary operator.

Example:

```ocaml
six = bitxor 5 3
six = (^) 5 3
six = 5 ^ 3
```

#### bitleft x y

Shifts the bits of `x`  to the left by `y`  positions. Accepts only integers.

Equivalent to the `(<<)` binary operator.

Example:

```ocaml
ten = bitleft 5 1
ten = (<<) 5 1
ten = 5 << 1
```

#### bitright x y

Shifts the bits of `x`  to the right by `y`  positions. Accepts only integers.

Equivalent to the `(>>)` binary operator.

Example:

```ocaml
two = bitright 5 1
two = (>>) 5 1
two = 5 >> 1
```

### Conversion Functions

#### int n

Converts a float `n` to an integer.

Example:

```ocaml
three = int 3.5
```

#### float n

Converts an integer `n` to a float.

Example:

```ocaml
three_point_zero = float 3
```

#### complex re im

Returns a complex number with a real part `re` and an imaginary part `im`.

Example:

```ocaml
three_plus_five_i = complex 3 5
```

#### real n

Returns a float representing the real part of a complex number `n`.

Example:

```ocaml
three = real 3+5i
```

#### imag n

Returns a float representing the imaginary part of a complex number `n`.

Example:

```ocaml
five = imag 3+5i
```

#### deg\_to\_rad n

Converts `n` from degrees to radians. Accepts integer and float types.

Example:

```ocaml
half_of_pi = deg_to_rad 90
```

#### rad\_to\_deg n

Converts `n` from radians to degrees. Accepts integer and float types.

Example:

```ocaml
ninety = rad_to_deg (pi / 2)
```

### Trigonometric Functions

#### sin n

Computes the sine of `n`  radians. Accepts integer, float, and complex types.

Example:

```ocaml
zero = sin 0
```

#### cos n

Computes the cosine of `n`  radians. Accepts integer, float, and complex types.

Example:

```ocaml
one = cos 0
```

#### tan n

Computes the tangent of `n`  radians. Accepts integer, float, and complex types.

Example:

```ocaml
zero = tan 0
```

#### asin n

Computes the inverse sine of `n` . Accepts integer, float, and complex types.

Example:

```ocaml
zero = asin 0
```

#### acos n

Computes the inverse cosine of `n`. Accepts integer, float, and complex types.

Example:

```ocaml
zero = acos 1
```

#### atan n

Computes the inverse tangent of `n` . Accepts integer, float, and complex types.

Example:

```ocaml
zero = atan 0
```

#### atan2 y x

Computes the inverse tangent of `y` and `x`. Accepts integer and float types.

Example:

```ocaml
zero = atan2 0 1
```

### Hyperbolic Functions

#### sinh n

Computes the hyperbolic sine of `n`  radians. Accepts integer, float, and complex types.

Example:

```ocaml
zero = sinh 0
```

#### cosh n

Computes the hyperbolic cosine of `n`  radians. Accepts integer, float, and complex types.

Example:

```ocaml
one = cosh 0
```

#### tanh n

Computes the hyperbolic tangent of `n`  radians. Accepts integer, float, and complex types.

Example:

```ocaml
zero = tanh 0
```

#### asinh n

Computes the inverse hyperbolic sine of `n`  radians. Accepts integer, float, and complex types.

Example:

```ocaml
zero = asinh 0
```

#### acosh n

Computes the inverse hyperbolic cosine of `n`  radians. Accepts integer, float, and complex types.

Example:

```ocaml
zero = acosh 1
```

#### atanh n

Computes the inverse hyperbolic tangent of `n`  radians. Accepts integer, float, and complex types.

Example:

```ocaml
zero = atanh 0
```

### Advanced Functions

#### ln n

Computes the natural logarithm of `n` . Accepts integer, float, and complex types.

Example:

```ocaml
one = ln e
```

#### log10 n

Computes the logarithm base 10 of `n` . Accepts integer, float, and complex types.

Example:

```ocaml
two = log10 100
```

#### log base n

Computes the logarithm with base `base` of `n` . Accepts integer, float, and complex types for `n` and integer or float types for `base`.

Example:

```ocaml
four = log 3 81
```

#### abs n

Computes the absolute value of `n` . Accepts integer, float, and complex types.

Example:

```ocaml
one = abs -1
```

#### floor n

Returns the largest integer less than or equal to `n`. Accepts integer and float types.

Example:

```ocaml
three = floor 3.7
```

#### ceil n

Returns the smallest integer greater than or equal to `n`. Accepts integer and float types.

Example:

```ocaml
three = ceil 3.3
```

#### sqrt n

Computes the square root of `n` . Accepts integer, float, and complex types.

Example:

```ocaml
two = sqrt 4
```

#### cbrt n

Computes the cube root of `n` . Accepts integer, float, and complex types.

Example:

```ocaml
two = cbrt 8
```

#### fact n

Computes the factorial of `n`. Accepts integer and float types.

Example:

```ocaml
twenty_four = fact 4
```

#### fact2 n

Computes the double factorial of `n`. Accepts integer and float types.

Example:

```ocaml
eight = fact2 4
```

#### min x y

Returns the minimum of `x` and `y`. Accepts integer and float types.

Example:

```ocaml
three = min 3 5
```

#### max x y

Returns the maximum of `x` and `y`. Accepts integer and float types.

Example:

```ocaml
five = max 3 5
```
