# Mathematical Functions

|                                                                                                      |                                                               |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| [`math::abs()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::abs)               | Returns the absolute value of the input.                      |
| [`math::ceil()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::ceil)             | Rounds up a given value to the nearest integer.               |
| [`math::floor()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::floor)           | Rounds down a given value to the nearest integer.             |
| [`math::exp()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::exp)               | Returns the natural logarithm of a given value.               |
| [`math::ln()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::ln)                 | Returns the natural logarithm of a given value.               |
| [`math::lg()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::lg)                 | Returns the base 10 logarithm of a given value.               |
| [`math::log()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::log)               | Returns the logarithm of a given value in the specified base. |
| [`math::mean()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::mean)             | Returns the arithmetic mean of the input set.                 |
| [`math::stddev()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::stddev)         | Returns the sample standard deviation of the input set.       |
| [`math::stddev_pop()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::stddev_pop) | Returns the population standard deviation of the input set.   |
| [`math::var()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::var)               | Returns the sample variance of the input set.                 |
| [`math::var_pop()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::var_pop)       | Returns the population variance of the input set.             |
| [`math::pi()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::pi)                 | Returns the value of pi.                                      |
| [`math::e()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::e)                   | Returns the value of e (euler's number).                      |
| [`math::acos()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::acos)             | Returns the arc cosine of the input.                          |
| [`math::asin()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::asin)             | Returns the arc sine of the input.                            |
| [`math::atan()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::atan)             | Returns the arc tangent of the input.                         |
| [`math::atan2()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::atan2)           | Returns the arc tangent of y / x.                             |
| [`math::cos()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::cos)               | Returns the cosine of the input.                              |
| [`math::cot()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::cot)               | Returns the cotangent of the input.                           |
| [`math::sin()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::sin)               | Returns the sinine of the input.                              |
| [`math::tan()`](https://docs.geldata.com/reference/stdlib/math.md#function::math::tan)               | Returns the tanangent of the input.                           |

## Function: math::abs()

```eql
math::abs(x: anyreal) -> anyreal
```

Returns the absolute value of the input.

```edgeql-repl
db> select math::abs(1);
{1}
db> select math::abs(-1);
{1}
```


## Function: math::ceil()

```eql
math::ceil(x: int64) -> float64
math::ceil(x: float64) -> float64
math::ceil(x: bigint) -> bigint
math::ceil(x: decimal) -> decimal
```

Rounds up a given value to the nearest integer.

```edgeql-repl
db> select math::ceil(1.1);
{2}
db> select math::ceil(-1.1);
{-1}
```


## Function: math::floor()

```eql
math::floor(x: int64) -> float64
math::floor(x: float64) -> float64
math::floor(x: bigint) -> bigint
math::floor(x: decimal) -> decimal
```

Rounds down a given value to the nearest integer.

```edgeql-repl
db> select math::floor(1.1);
{1}
db> select math::floor(-1.1);
{-2}
```


## Function: math::exp()

```eql
math::exp(x: int64) -> float64
math::exp(x: float64) -> float64
math::exp(x: decimal) -> decimal
```

Returns the natural logarithm of a given value.

```edgeql-repl
db> select math::exp(1);
{2.718281829}
```


## Function: math::ln()

```eql
math::ln(x: int64) -> float64
math::ln(x: float64) -> float64
math::ln(x: decimal) -> decimal
```

Returns the natural logarithm of a given value.

```edgeql-repl
db> select math::exp(math::ln(100));
{100.00000009164575}
```


## Function: math::lg()

```eql
math::lg(x: int64) -> float64
math::lg(x: float64) -> float64
math::lg(x: decimal) -> decimal
```

Returns the base 10 logarithm of a given value.

```edgeql-repl
db> select 10 ^ math::lg(42);
{42.00000000000001}
```


## Function: math::log()

```eql
math::log(x: decimal, named only base: decimal) -> decimal
```

Returns the logarithm of a given value in the specified base.

```edgeql-repl
db> select 3 ^ math::log(15n, base := 3n);
{15.0000000000000005n}
```


## Function: math::mean()

```eql
math::mean(vals: set of int64) -> float64
math::mean(vals: set of float64) -> float64
math::mean(vals: set of decimal) -> decimal
```

Returns the arithmetic mean of the input set.

```edgeql-repl
db> select math::mean({1, 3, 5});
{3}
```


## Function: math::stddev()

```eql
math::stddev(vals: set of int64) -> float64
math::stddev(vals: set of float64) -> float64
math::stddev(vals: set of decimal) -> decimal
```

Returns the sample standard deviation of the input set.

```edgeql-repl
db> select math::stddev({1, 3, 5});
{2}
```


## Function: math::stddev_pop()

```eql
math::stddev_pop(vals: set of int64) -> float64
math::stddev_pop(vals: set of float64) -> float64
math::stddev_pop(vals: set of decimal) -> decimal
```

Returns the population standard deviation of the input set.

```edgeql-repl
db> select math::stddev_pop({1, 3, 5});
{1.63299316185545}
```


## Function: math::var()

```eql
math::var(vals: set of int64) -> float64
math::var(vals: set of float64) -> float64
math::var(vals: set of decimal) -> decimal
```

Returns the sample variance of the input set.

```edgeql-repl
db> select math::var({1, 3, 5});
{4}
```


## Function: math::var_pop()

```eql
math::var_pop(vals: set of int64) -> float64
math::var_pop(vals: set of float64) -> float64
math::var_pop(vals: set of decimal) -> decimal
```

Returns the population variance of the input set.

```edgeql-repl
db> select math::var_pop({1, 3, 5});
{2.66666666666667}
```


## Function: math::pi()

```eql
math::pi() -> float64
```

Returns the value of pi.

```edgeql-repl
db> select math::pi();
{3.141592653589793}
```


## Function: math::e()

```eql
math::e() -> float64
```

Returns the value of e (euler's number).

```edgeql-repl
db> select math::e();
{2.718281828459045}
```


## Function: math::acos()

```eql
math::acos(x: float64) -> float64
```

Returns the arc cosine of the input.

```edgeql-repl
db> select math::acos(-1);
{3.141592653589793}
db> select math::acos(0);
{1.5707963267948966}
db> select math::acos(1);
{0}
```


## Function: math::asin()

```eql
math::asin(x: float64) -> float64
```

Returns the arc sine of the input.

```edgeql-repl
db> select math::asin(-1);
{-1.5707963267948966}
db> select math::asin(0);
{0}
db> select math::asin(1);
{1.5707963267948966}
```


## Function: math::atan()

```eql
math::atan(x: float64) -> float64
```

Returns the arc tangent of the input.

```edgeql-repl
db> select math::atan(-1);
{-0.7853981633974483}
db> select math::atan(0);
{0}
db> select math::atan(1);
{0.7853981633974483}
```


## Function: math::atan2()

```eql
math::atan2(y: float64, x: float64) -> float64
```

Returns the arc tangent of `y / x`.

Uses the signs of the arguments determine the correct quadrant.

```edgeql-repl
db> select math::atan2(1, 1);
{0.7853981633974483}
db> select math::atan2(1, -1);
{2.356194490192345}
db> select math::atan2(-1, -1);
{-2.356194490192345}
db> select math::atan2(-1, 1);
{-0.7853981633974483}
```


## Function: math::cos()

```eql
math::cos(x: float64) -> float64
```

Returns the cosine of the input.

```edgeql-repl
db> select math::cos(0);
{1}
db> select math::cos(math::pi() / 2);
{0.000000000}
db> select math::cos(math::pi());
{-1}
db> select math::cos(math::pi() * 3 / 2);
{-0.000000000}
```


## Function: math::cot()

```eql
math::cot(x: float64) -> float64
```

Returns the cotangent of the input.

```edgeql-repl
db> select math::cot(math::pi() / 4);
{1.000000000}
db> select math::cot(math::pi() / 2);
{0.000000000}
db> select math::cot(math::pi() * 3 / 4);
{-0.999999999}
```


## Function: math::sin()

```eql
math::sin(x: float64) -> float64
```

Returns the sinine of the input.

```edgeql-repl
db> select math::sin(0);
{0}
db> select math::sin(math::pi() / 2);
{1}
db> select math::sin(math::pi());
{0.000000000}
db> select math::sin(math::pi() * 3 / 2);
{-1}
```


## Function: math::tan()

```eql
math::tan(x: float64) -> float64
```

Returns the tanangent of the input.

```edgeql-repl
db> select math::tan(-math::pi() / 4);
{-0.999999999}
db> select math::tan(0);
{0}
db> select math::tan(math::pi() / 4);
{0.999999999}
```


