Skip to main content
Version: 2.x(alpha)

Math functions

These functions can be used when analysing numeric data and numeric collections.

FunctionDescription
math::abs()Returns the absolute value of a number
math::acos()Computes the arccosine (inverse cosine) of a value
math::acot()Computes the cotangent of an angle given in radians
math::asin()Computes the arcsine (inverse sine) of a value
math::atan()Computes the arctangent (inverse tangent) of a value
math::bottom()Returns the bottom X set of numbers in a set of numbers
math::ceil()Rounds a number up to the next largest integer
math::clamp()Clamps a value between a specified minimum and maximum
math::cos()Computes the cosine of an angle given in radians
math::cot()Computes the cotangent of an angle given in radians
math::deg2rad()Converts an angle from degrees to radians
math::eRepresents the base of the natural logarithm
math::fixed()Returns a number with the specified number of decimal places
math::floor()Rounds a number down to the nearest integer
math::infRepresents positive infinity
math::interquartile()Returns the interquartile of an array of numbers
math::lerp()Linearly interpolates between two values based on a factor
math::lerpangle()Linearly interpolates between two angles in degrees
math::ln()Computes the natural logarithm (base e) of a value
math::log()Computes the logarithm of a value with the specified base
math::log10()Computes the base-10 logarithm of a value
math::log2()Computes the base-2 logarithm of a value
math::max()Returns the maximum number in a set of numbers
math::mean()Returns the mean of a set of numbers
math::median()Returns the median of a set of numbers
math::midhinge()Returns the midhinge of a set of numbers
math::min()Returns the minimum number in a set of numbers
math::mode()Returns the value that occurs most often in a set of numbers
math::nearestrank()Returns the nearest rank of an array of numbers
math::neg_infRepresents negative infinity
math::percentile()Returns the value below which a percentage of data falls
math::piRepresents the mathematical constant π.
math::product()Returns the product of a set of numbers
math::rad2deg()Converts an angle from radians to degrees
math::round()Rounds a number up or down to the nearest integer
math::sign()Returns the sign of a value (-1, 0, or 1)
math::sin()Computes the sine of an angle given in radians
math::spread()Returns the spread of an array of numbers
math::sqrt()Returns the square root of a number
math::stddev()Calculates how far a set of numbers are away from the mean
math::sum()Returns the total sum of a set of numbers
math::tauRepresents the mathematical constant τ.
math::top()Returns the top X set of numbers in a set of numbers
math::trimean()The weighted average of the median and the two quartiles
math::variance()Calculates how far a set of numbers are spread out from the mean

math::abs

The math::abs function returns the absolute value of a number.

API DEFINITION
math::abs(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::abs(-13.746189);

13.746189

math::acos

The math::acos function returns the arccosine (inverse cosine) of a number, which must be in the range -1 to 1. The result is expressed in radians.

API DEFINITION
math::acos(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::acos(0.5);

1.0471975511965979

math::acot

The math::acot function returns the arccotangent (inverse cotangent) of a number. The result is expressed in radians.

API DEFINITION
math::acot(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::acot(1);

0.7853981633974483

math::asin

The math::asin function returns the arcsine (inverse sine) of a number, which must be in the range -1 to 1. The result is expressed in radians.

API DEFINITION
math::asin(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::asin(0.5);

0.5235987755982989

math::atan

The math::atan function returns the arctangent (inverse tangent) of a number. The result is expressed in radians.

API DEFINITION
math::atan(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::atan(1);

0.7853981633974483

math::bottom

The math::bottom function returns the bottom X set of numbers in a set of numbers.

API DEFINITION
math::bottom(array<number>, number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::bottom([1, 2, 3], 2);

[ 2, 1 ]

math::ceil

The math::ceil function rounds a number up to the next largest integer.

API DEFINITION
math::ceil(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::ceil(13.146572);

14

math::clamp

The math::clamp function constrains a number within the specified range, defined by a minimum and a maximum value. If the number is less than the minimum, it returns the minimum. If it is greater than the maximum, it returns the maximum.

API DEFINITION
math::clamp(number, min, max) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::clamp(1, 5, 10);

5

math::cos

The math::cos function returns the cosine of a number, which is assumed to be in radians. The result is a value between -1 and 1.

API DEFINITION
math::cos(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::cos(1);

0.5403023058681398

math::cot

The math::cot function returns the cotangent of a number, which is assumed to be in radians. The cotangent is the reciprocal of the tangent function.

API DEFINITION
math::cot(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::cot(1);

0.6420926159343306

math::deg2rad

The math::deg2rad function converts an angle from degrees to radians.

API DEFINITION
math::deg2rad(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::deg2rad(180);

3.141592653589793

math::e

The math::e constant represents the base of the natural logarithm.

API DEFINITION
math::e -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::e;

2.718281828459045f

math::fixed

The math::fixed function returns a number with the specified number of decimal places.

API DEFINITION
math::fixed(number, number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::fixed(13.146572, 2);

13.15

math::floor

The math::floor function rounds a number down to the nearest integer.

API DEFINITION
math::floor(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::floor(13.746189);

13

math::inf

The math::inf constant represents positive infinity.

API DEFINITION
math::inf -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::inf;

inf

math::interquartile

The math::interquartile function returns the interquartile of an array of numbers.

API DEFINITION
math::interquartile(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::interquartile([ 1, 40, 60, 10, 2, 901 ]);

51

math::lerp

The math::lerp function performs a linear interpolation between two numbers (a and b) based on a given fraction (t). The fraction t should be between 0 and 1, where 0 returns a and 1 returns b.

API DEFINITION
math::lerp(a, b, t) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::lerp(0, 10, 0.5);

5

math::lerpangle

The math::lerpangle function interpolates between two angles (a and b) by the given fraction (t). This is useful for smoothly transitioning between angles.

API DEFINITION
math::lerpangle(a, b, t) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::lerpangle(0, 180, 0.5);

90

math::ln

The math::ln function returns the natural logarithm (base e) of a number.

API DEFINITION
math::ln(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::ln(10);

2.302585092994046

math::log

The math::log function returns the logarithm of a number with a specified base.

API DEFINITION
math::log(number, base) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::log(100, 10);

2

math::log10

The math::log10 function returns the base-10 logarithm of a number.

API DEFINITION
math::log10(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::log10(1000);

3

math::log2

The math::log2 function returns the base-2 logarithm of a number.

API DEFINITION
math::log2(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::log2(8);

3

math::max

The math::max function returns the maximum number in a set of numbers.

API DEFINITION
math::max(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::max([ 26.164, 13.746189, 23, 16.4, 41.42 ]);

41.42

math::mean

The math::mean function returns the mean of a set of numbers.

API DEFINITION
math::mean(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::mean([ 26.164, 13.746189, 23, 16.4, 41.42 ]);

24.1460378

math::median

The math::median function returns the median of a set of numbers.

API DEFINITION
math::median(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::median([ 26.164, 13.746189, 23, 16.4, 41.42 ]);

23

math::midhinge

The math::midhinge function returns the midhinge of an array of numbers.

API DEFINITION
math::midhinge(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::midhinge([ 1, 40, 60, 10, 2, 901 ]);

29.5

math::min

The math::min function returns the minimum number in a set of numbers.

API DEFINITION
math::min(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::min([ 26.164, 13.746189, 23, 16.4, 41.42 ]);

13.746189

math::mode

The math::mode function returns the value that occurs most often in a set of numbers. In case of a tie, the highest one is returned.

API DEFINITION
math::mode(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::mode([ 1, 40, 60, 10, 2, 901 ]);

901

math::nearestrank

The math::nearestrank function returns the nearestrank of an array of numbers.

API DEFINITION
math::nearestrank(array<number>, number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::nearestrank([1, 40, 60, 10, 2, 901], 50);

40

math::neg_inf

The math::neg_inf constant represents negative infinity.

API DEFINITION
math::neg_inf -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::neg_inf;

-inf

math::percentile

The math::percentile function returns the value below which a percentage of data falls.

API DEFINITION
math::percentile(array<number>, number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::percentile([1, 40, 60, 10, 2, 901], 50);

25

math::pi

The math::pi constant represents the mathematical constant π.

API DEFINITION
math::pi -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::pi;

3.141592653589793f

math::product

The math::product function returns the product of a set of numbers.

API DEFINITION
math::product(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::product([ 26.164, 13.746189, 23, 16.4, 41.42 ]);

5619119.004884841504

math::rad2deg

The math::rad2deg function converts an angle from radians to degrees.

API DEFINITION
math::rad2deg(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::rad2deg(3.141592653589793);

180

math::round

The math::round function rounds a number up or down to the nearest integer.

API DEFINITION
math::round(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::round(13.53124);

14

math::sign

The math::sign function returns the sign of a number, indicating whether the number is positive, negative, or zero. It returns 1 for positive numbers, -1 for negative numbers, and 0 for zero.

API DEFINITION
math::sign(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::sign(-42);

-1

math::sin

The math::sin function returns the sine of a number, which is assumed to be in radians.

API DEFINITION
math::sin(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::sin(1);

0.8414709848078965

math::tan

The math::tan function returns the tangent of a number, which is assumed to be in radians.

API DEFINITION
math::tan(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::tan(1);

1.5574077246549023

math::tau

The math::tau constant represents the mathematical constant τ, which is equal to 2π.

API DEFINITION
math::tau -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::tau;

6.283185307179586f

math::spread

The math::spread function returns the spread of an array of numbers.

API DEFINITION
math::spread(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::spread([ 1, 40, 60, 10, 2, 901 ]);

900

math::sqrt

The math::sqrt function returns the square root of a number.

API DEFINITION
math::sqrt(number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::sqrt(15);

3.872983346207417

math::stddev

The math::stddev function calculates how far a set of numbers are away from the mean.

API DEFINITION
math::stddev(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::stddev([ 1, 40, 60, 10, 2, 901 ]);

359.37167389765153

math::sum

The math::sum function returns the total sum of a set of numbers.

API DEFINITION
math::sum(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::sum([ 26.164, 13.746189, 23, 16.4, 41.42 ]);

120.730189

math::top

The math::top function returns the top of an array of numbers.

API DEFINITION
math::top(array<number>, number) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::top([1, 40, 60, 10, 2, 901], 3);

[ 40, 901, 60 ]

math::trimean

The math::trimean function returns the trimean of an array of numbers.

API DEFINITION
math::trimean(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::trimean([ 1, 40, 60, 10, 2, 901 ]);

27.25

math::variance

The math::variance function returns the variance of an array of numbers.

API DEFINITION
math::variance(array<number>) -> number

The following example shows this function, and its output, when used in a RETURN statement:

RETURN math::variance([ 1, 40, 60, 10, 2, 901 ]);

129148