Search
ctrl/
Ask AI
Light
Dark
System

Mathematical Functions

math::abs()

Returns the absolute value of the input.

math::ceil()

Rounds up a given value to the nearest integer.

math::floor()

Rounds down a given value to the nearest integer.

math::ln()

Returns the natural logarithm of a given value.

math::lg()

Returns the base 10 logarithm of a given value.

math::log()

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

math::mean()

Returns the arithmetic mean of the input set.

math::stddev()

Returns the sample standard deviation of the input set.

math::stddev_pop()

Returns the population standard deviation of the input set.

math::var()

Returns the sample variance of the input set.

math::var_pop()

Returns the population variance of the input set.

math::pi()

Returns the value of pi.

math::acos()

Returns the arc cosine of the input.

math::asin()

Returns the arc sine of the input.

math::atan()

Returns the arc tangent of the input.

math::atan2()

Returns the arc tangent of y / x.

math::cos()

Returns the cosine of the input.

math::cot()

Returns the cotangent of the input.

math::sin()

Returns the sinine of the input.

math::tan()

Returns the tanangent of the input.

function

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

Returns the absolute value of the input.

Copy
db> 
select math::abs(1);
{1}
Copy
db> 
select math::abs(-1);
{1}

function

math::ceil()
math::ceil(x: int64) -> float64math::ceil(x: float64) -> float64math::ceil(x: bigint) -> bigintmath::ceil(x: decimal) -> decimal

Rounds up a given value to the nearest integer.

Copy
db> 
select math::ceil(1.1);
{2}
Copy
db> 
select math::ceil(-1.1);
{-1}

function

math::floor()
math::floor(x: int64) -> float64math::floor(x: float64) -> float64math::floor(x: bigint) -> bigintmath::floor(x: decimal) -> decimal

Rounds down a given value to the nearest integer.

Copy
db> 
select math::floor(1.1);
{1}
Copy
db> 
select math::floor(-1.1);
{-2}

function

math::ln()
math::ln(x: int64) -> float64math::ln(x: float64) -> float64math::ln(x: decimal) -> decimal

Returns the natural logarithm of a given value.

Copy
db> 
select 2.718281829 ^ math::ln(100);
{100.00000009164575}

function

math::lg()
math::lg(x: int64) -> float64math::lg(x: float64) -> float64math::lg(x: decimal) -> decimal

Returns the base 10 logarithm of a given value.

Copy
db> 
select 10 ^ math::lg(42);
{42.00000000000001}

function

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

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

Copy
db> 
select 3 ^ math::log(15n, base := 3n);
{15.0000000000000005n}

function

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

Returns the arithmetic mean of the input set.

Copy
db> 
select math::mean({1, 3, 5});
{3}

function

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

Returns the sample standard deviation of the input set.

Copy
db> 
select math::stddev({1, 3, 5});
{2}

function

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

Returns the population standard deviation of the input set.

Copy
db> 
select math::stddev_pop({1, 3, 5});
{1.63299316185545}

function

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

Returns the sample variance of the input set.

Copy
db> 
select math::var({1, 3, 5});
{4}

function

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

Returns the population variance of the input set.

Copy
db> 
select math::var_pop({1, 3, 5});
{2.66666666666667}

function

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

Returns the value of pi.

Copy
db> 
select math::pi();
{3.141592653589793}

function

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

Returns the arc cosine of the input.

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

function

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

Returns the arc sine of the input.

Copy
db> 
select math::asin(-1);
{-1.5707963267948966}
Copy
db> 
select math::asin(0);
{0}
Copy
db> 
select math::asin(1);
{1.5707963267948966}

function

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

Returns the arc tangent of the input.

Copy
db> 
select math::atan(-1);
{-0.7853981633974483}
Copy
db> 
select math::atan(0);
{0}
Copy
db> 
select math::atan(1);
{0.7853981633974483}

function

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

Returns the arc tangent of y / x.

Uses the signs of the arguments determine the correct quadrant.

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

function

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

Returns the cosine of the input.

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

function

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

Returns the cotangent of the input.

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

function

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

Returns the sinine of the input.

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

function

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

Returns the tanangent of the input.

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