View all results

Math

Functions for mathematical operations and numeric calculations.

abs

1-parameter signature

abs(number)

Deprecated.

Use math::abs instead.

abs returns the absolute value of a given number.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe absolute value of a given number.

acos

1-parameter signature

acos(number)

Deprecated.

Use math::acos instead.

acos returns the arccosine, in radians, of a given number.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe arccosine, in radians, of a given number.

asin

1-parameter signature

asin(number)

Deprecated.

Use math::asin instead.

asin returns the arcsine, in radians, of a given number.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe arcsine, in radians, of a given number.

atan

1-parameter signature

atan(number)

Deprecated.

Use math::atan instead.

atan returns the arctangent, in radians, of a given number.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe arctangent, in radians, of a given number.

atan2

2-parameter signature

atan2(number1, number2)

Deprecated.

Use math::atan2 instead.

atan2 returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.

Parameters
  • number1Int | FloatInput number.
  • number2Int | FloatInput number.
Returns
FloatThe arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.

average

1-parameter signature

average(array)

Deprecated.

Use math::mean instead.

average returns the arithmetic mean of the numeric elements in a list.

Parameters
  • arrayAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
Returns
FloatThe arithmetic mean, or zero when no numbers remain.
Throws
  • TypeErrorAn argument has an invalid type.

ceil

1-parameter signature

ceil(number)

Deprecated.

Use math::ceil instead.

ceil returns the least integer value greater than or equal to a given value.

Parameters
  • numberInt | FloatInput number.
Returns
IntThe least integer value greater than or equal to a given value.

cos

1-parameter signature

cos(number)

Deprecated.

Use math::cos instead.

cos returns the cosine of a given number.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe cosine of a given number.

degrees

1-parameter signature

degrees(number)

Deprecated.

Use math::degrees instead.

degrees returns the angle converted from radians to degrees.

Parameters
  • numberInt | FloatThe input number.
Returns
FloatThe angle in degrees

exp

1-parameter signature

exp(number)

Deprecated.

Use math::exp instead.

exp returns Euler's constant (2.71828...) raised to the power of value.

Parameters
  • numberInt | FloatInput number.
Returns
FloatEuler's constant raised to the power of value.

exp2

1-parameter signature

exp2(number)

Deprecated.

Use math::exp2 instead.

exp2 returns 2 raised to the power of value.

Parameters
  • numberInt | FloatInput number.
Returns
Float2 raised to the power of value.

floor

1-parameter signature

floor(number)

Deprecated.

Use math::floor instead.

floor returns the greatest integer value less than or equal to a given value.

Parameters
  • numberInt | FloatInput number.
Returns
IntThe greatest integer value less than or equal to a given value.

log

1-parameter signature

log(number)

Deprecated.

Use math::log instead.

log returns the natural logarithm of a given value.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe natural logarithm of a given value.

log10

1-parameter signature

log10(number)

Deprecated.

Use math::log10 instead.

log10 returns the decimal logarithm of a given value.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe decimal logarithm of a given value.

log2

1-parameter signature

log2(number)

Deprecated.

Use math::log2 instead.

log2 returns the binary logarithm of a given value.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe binary logarithm of a given value.

max

1-parameter signature

max(array)

Deprecated.

Use math::max instead.

max returns the largest number among the numeric elements in a list.

Parameters
  • arrayAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
Returns
Float | NoneThe largest number as Float, or None when no numbers remain.
Throws
  • TypeErrorAn argument has an invalid type.

median

1-parameter signature

median(array)

Deprecated.

Use math::median instead.

median returns the middle numeric value, averaging the two middle numbers for even numeric counts.

Parameters
  • arrayAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
Returns
Int | Float | NoneThe selected middle value or their Float mean, or None when no numbers remain.
Throws
  • TypeErrorAn argument has an invalid type.

min

1-parameter signature

min(array)

Deprecated.

Use math::min instead.

min returns the smallest number among the numeric elements in a list.

Parameters
  • arrayAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
Returns
Float | NoneThe smallest number as Float, or None when no numbers remain.
Throws
  • TypeErrorAn argument has an invalid type.

percentile

2-parameter signature

percentile(array, number)

Deprecated.

Use math::percentile instead.

percentile returns the nth percentile of the values in a given array.

Parameters
  • arrayAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
  • numberIntA number which must be between 0 (excluded) and 100 (included).
Returns
Int | FloatThe selected number or interpolated Float, or NaN when no numbers remain.
Throws
  • TypeErrorAn argument has an invalid type.

3-parameter signature

percentile(array, number, method)

Deprecated.

Use math::percentile instead.

percentile returns the nth percentile of the values in a given array.

Parameters
  • arrayAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
  • numberIntA number which must be between 0 (excluded) and 100 (included).
  • methodString"interpolation" uses linear interpolation; all other strings select nearest rank.
Returns
Int | FloatThe selected number or interpolated Float, or NaN when no numbers remain.
Throws
  • TypeErrorAn argument has an invalid type.

pi

0-parameter signature

pi()

Deprecated.

Use math::pi instead.

pi returns Pi value.

Parameters
None
Returns
FloatPi value.

pow

2-parameter signature

pow(base, exp)

Deprecated.

Use math::pow instead.

pow returns the base to the exponent value.

Parameters
  • baseInt | FloatThe base value.
  • expInt | FloatThe exponent value.
Returns
FloatThe exponentiated value.

radians

1-parameter signature

radians(number)

Deprecated.

Use math::radians instead.

radians returns the angle converted from degrees to radians.

Parameters
  • numberInt | FloatThe input number.
Returns
FloatThe angle in radians.

rand

0-parameter signature

rand()

Deprecated.

Use random::float() instead.

rand draws a non-cryptographic pseudo-random Float from the Session source.

Parameters
None
Returns
FloatA number in [0, 1).

1-parameter signature

rand(max)

Deprecated.

Use random::int(min, max) for inclusive integer bounds or random::float(min, max) for continuous bounds. Supply explicit bounds; the legacy one-argument form uses max/2 and max*2.

rand applies the historical rounded random calculation around a supplied value.

Parameters
  • maxInt | FloatConverted to Float; the historical lower bound is max/2 and upper bound is max*2.
Returns
FloatThe historical result floor(u*(max*2-max/2+1))+max/2, where u is in [0, 1).

2-parameter signature

rand(max, min)

Deprecated.

Use random::int(min, max) for inclusive integer bounds or random::float(min, max) for continuous bounds. Reverse the legacy argument order; canonical functions validate bounds and types.

rand applies the historical rounded random calculation with maximum first.

Parameters
  • maxInt | FloatUpper bound, converted to Float without canonical range validation.
  • minInt | FloatLower bound, converted to Float without canonical range validation.
Returns
FloatThe historical result floor(u*(max-min+1))+min, where u is in [0, 1).

round

1-parameter signature

round(number)

Deprecated.

Use math::round instead.

round returns the nearest integer, rounding half away from zero.

Parameters
  • numberInt | FloatInput number.
Returns
IntThe nearest integer, rounding half away from zero.

sin

1-parameter signature

sin(number)

Deprecated.

Use math::sin instead.

sin returns the sine of the radian argument.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe sin, in radians, of a given number.

sqrt

1-parameter signature

sqrt(value)

Deprecated.

Use math::sqrt instead.

sqrt returns the square root of a given number.

Parameters
  • valueInt | FloatA number.
Returns
FloatThe square root.

stddev_population

1-parameter signature

stddev_population(numbers)

Deprecated.

Use math::stddev instead.

stddev_population returns the square root of the population variance.

Parameters
  • numbersAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
Returns
FloatThe population standard deviation, or NaN when no numbers remain.
Throws
  • TypeErrorAn argument has an invalid type.

stddev_sample

1-parameter signature

stddev_sample(numbers)

Deprecated.

Use math::stddev_sample instead.

stddev_sample returns the square root of the sample variance.

Parameters
  • numbersAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
Returns
FloatThe sample standard deviation, or NaN for fewer than two numbers.
Throws
  • TypeErrorAn argument has an invalid type.

sum

1-parameter signature

sum(numbers)

Deprecated.

Use math::sum instead.

sum returns the sum of the numeric elements in a list.

Parameters
  • numbersAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
Returns
Int | FloatThe sum as Float, including zero when all elements are ignored; integer zero for an empty list.
Throws
  • TypeErrorAn argument has an invalid type.

tan

1-parameter signature

tan(number)

Deprecated.

Use math::tan instead.

tan returns the tangent of a given number.

Parameters
  • numberInt | FloatA number.
Returns
FloatThe tangent.

variance_population

1-parameter signature

variance_population(numbers)

Deprecated.

Use math::variance instead.

variance_population returns the population variance, dividing squared deviations from the mean by the numeric count N.

Parameters
  • numbersAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
Returns
FloatThe population variance, or NaN when no numbers remain.
Throws
  • TypeErrorAn argument has an invalid type.

variance_sample

1-parameter signature

variance_sample(numbers)

Deprecated.

Use math::variance_sample instead.

variance_sample returns the sample variance, dividing squared deviations from the mean by the numeric count N minus one.

Parameters
  • numbersAny[]A list whose Int and Float elements are used; other elements are ignored. It is not mutated.
Returns
FloatThe sample variance, or NaN for fewer than two numbers.
Throws
  • TypeErrorAn argument has an invalid type.

math::abs

1-parameter signature

math::abs(number)

abs returns the absolute value of a given number.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe absolute value of a given number.

math::acos

1-parameter signature

math::acos(number)

acos returns the arccosine, in radians, of a given number.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe arccosine, in radians, of a given number.

math::asin

1-parameter signature

math::asin(number)

asin returns the arcsine, in radians, of a given number.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe arcsine, in radians, of a given number.

math::atan

1-parameter signature

math::atan(number)

atan returns the arctangent, in radians, of a given number.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe arctangent, in radians, of a given number.

math::atan2

2-parameter signature

math::atan2(number1, number2)

atan2 returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.

Parameters
  • number1Int | FloatInput number.
  • number2Int | FloatInput number.
Returns
FloatThe arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.

math::cbrt

1-parameter signature

math::cbrt(value)

cbrt returns the real cube root of a number, including negative numbers.

Parameters
  • valueInt | FloatInput number.
Returns
FloatThe cube root, preserving NaN, infinities, and signed zero.
Throws
  • TypeErrorThe argument is not numeric.

math::ceil

1-parameter signature

math::ceil(number)

ceil returns the least integer value greater than or equal to a given value.

Parameters
  • numberInt | FloatInput number.
Returns
IntThe least integer value greater than or equal to a given value.

math::clamp

3-parameter signature

math::clamp(value, min, max)

clamp limits a number to the inclusive interval from min to max.

Parameters
  • valueInt | FloatInput number.
  • minInt | FloatLower bound; must not be NaN or greater than max.
  • maxInt | FloatUpper bound; must not be NaN. Infinite bounds are allowed.
Returns
Int | FloatThe original min if value is below it, max if above it, or value otherwise. Equality and NaN preserve value unchanged.
Throws
  • TypeErrorAn argument is not numeric.
  • InvalidArgumentA bound is NaN or min is greater than max.

math::cos

1-parameter signature

math::cos(number)

cos returns the cosine of a given number.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe cosine of a given number.

math::degrees

1-parameter signature

math::degrees(number)

degrees returns the angle converted from radians to degrees.

Parameters
  • numberInt | FloatThe input number.
Returns
FloatThe angle in degrees

math::e

0-parameter signature

math::e()

e returns Euler's number, the base of the natural logarithm.

Parameters
None
Returns
FloatEuler's number, approximately 2.718281828459045.

math::exp

1-parameter signature

math::exp(number)

exp returns Euler's constant (2.71828...) raised to the power of value.

Parameters
  • numberInt | FloatInput number.
Returns
FloatEuler's constant raised to the power of value.

math::exp2

1-parameter signature

math::exp2(number)

exp2 returns 2 raised to the power of value.

Parameters
  • numberInt | FloatInput number.
Returns
Float2 raised to the power of value.

math::expm1

1-parameter signature

math::expm1(value)

expm1 computes exp(value)-1 with improved numerical accuracy for values near zero.

Parameters
  • valueInt | FloatInput number.
Returns
FloatThe exponential minus one; negative infinity gives -1, while NaN, positive infinity, and signed zero are preserved.
Throws
  • TypeErrorThe argument is not numeric.

math::floor

1-parameter signature

math::floor(number)

floor returns the greatest integer value less than or equal to a given value.

Parameters
  • numberInt | FloatInput number.
Returns
IntThe greatest integer value less than or equal to a given value.

math::hypot

2-parameter signature

math::hypot(x, y)

hypot computes sqrt(x*x + y*y), avoiding unnecessary overflow and underflow.

Parameters
  • xInt | FloatFirst coordinate.
  • yInt | FloatSecond coordinate.
Returns
FloatThe nonnegative distance; infinity takes precedence over NaN.
Throws
  • TypeErrorAn argument is not numeric.

math::log

1-parameter signature

math::log(number)

log returns the natural logarithm of a given value.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe natural logarithm of a given value.

math::log10

1-parameter signature

math::log10(number)

log10 returns the decimal logarithm of a given value.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe decimal logarithm of a given value.

math::log1p

1-parameter signature

math::log1p(value)

log1p computes ln(1+value) with improved numerical accuracy for values near zero.

Parameters
  • valueInt | FloatInput number.
Returns
FloatThe logarithm; -1 gives negative infinity, values below -1 give NaN, and signed zero is preserved.
Throws
  • TypeErrorThe argument is not numeric.

math::log2

1-parameter signature

math::log2(number)

log2 returns the binary logarithm of a given value.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe binary logarithm of a given value.

math::max

1-parameter signature

math::max(values)

max returns the largest number in a numeric list.

Parameters
  • valuesInt[] | Float[]Numeric list; non-numeric elements are rejected. The list is not mutated.
Returns
Float | NoneThe maximum as Float, or None for an empty list.
Throws
  • TypeErrorAn argument or list element has an invalid type.

math::mean

1-parameter signature

math::mean(values)

mean returns the arithmetic mean of a numeric list.

Parameters
  • valuesInt[] | Float[]Numeric list; non-numeric elements are rejected. The list is not mutated.
Returns
FloatThe arithmetic mean, or NaN for an empty list.
Throws
  • TypeErrorAn argument or list element has an invalid type.

math::median

1-parameter signature

math::median(values)

median returns the central number, averaging the middle pair for even counts.

Parameters
  • valuesInt[] | Float[]Numeric list; non-numeric elements are rejected. The list is not mutated.
Returns
Int | FloatThe selected number or Float mean, or NaN for an empty list.
Throws
  • TypeErrorAn argument or list element has an invalid type.

math::min

1-parameter signature

math::min(values)

min returns the smallest number in a numeric list.

Parameters
  • valuesInt[] | Float[]Numeric list; non-numeric elements are rejected. The list is not mutated.
Returns
Float | NoneThe minimum as Float, or None for an empty list.
Throws
  • TypeErrorAn argument or list element has an invalid type.

math::percentile

2-parameter signature

math::percentile(values, p)

percentile returns the percentile using linear interpolation at (p / 100) * (N - 1).

Parameters
  • valuesInt[] | Float[]Numeric list; non-numeric elements are rejected. The list is not mutated.
  • pInt | FloatFinite percentile from zero through 100, inclusive; validated even for an empty list.
Returns
Int | FloatThe selected number or interpolated Float, or NaN for an empty list.
Throws
  • TypeErrorAn argument or list element has an invalid type.
  • InvalidArgumentThe percentile is non-finite or outside zero through 100.

math::pi

0-parameter signature

math::pi()

pi returns Pi value.

Parameters
None
Returns
FloatPi value.

math::pow

2-parameter signature

math::pow(base, exp)

pow returns the base to the exponent value.

Parameters
  • baseInt | FloatThe base value.
  • expInt | FloatThe exponent value.
Returns
FloatThe exponentiated value.

math::radians

1-parameter signature

math::radians(number)

radians returns the angle converted from degrees to radians.

Parameters
  • numberInt | FloatThe input number.
Returns
FloatThe angle in radians.

math::round

1-parameter signature

math::round(number)

round returns the nearest integer, rounding half away from zero.

Parameters
  • numberInt | FloatInput number.
Returns
IntThe nearest integer, rounding half away from zero.

math::sign

1-parameter signature

math::sign(value)

sign returns the sign of a number, including positive and negative infinity.

Parameters
  • valueInt | FloatInput number; must not be NaN.
Returns
IntMinus one for negative values, zero for either signed zero, or one for positive values.
Throws
  • TypeErrorThe argument is not numeric.
  • InvalidArgumentThe argument is NaN and has no ordered sign.

math::sin

1-parameter signature

math::sin(number)

sin returns the sine of the radian argument.

Parameters
  • numberInt | FloatInput number.
Returns
FloatThe sin, in radians, of a given number.

math::sqrt

1-parameter signature

math::sqrt(value)

sqrt returns the square root of a given number.

Parameters
  • valueInt | FloatA number.
Returns
FloatThe square root.

math::stddev

1-parameter signature

math::stddev(values)

stddev returns the population standard deviation.

Parameters
  • valuesInt[] | Float[]Numeric list; non-numeric elements are rejected. The list is not mutated.
Returns
FloatThe statistic, or NaN for an empty list.
Throws
  • TypeErrorAn argument or list element has an invalid type.

math::stddev_sample

1-parameter signature

math::stddev_sample(values)

stddev_sample returns the sample standard deviation.

Parameters
  • valuesInt[] | Float[]Numeric list; non-numeric elements are rejected. The list is not mutated.
Returns
FloatThe statistic, or NaN for fewer than two numbers.
Throws
  • TypeErrorAn argument or list element has an invalid type.

math::sum

1-parameter signature

math::sum(values)

sum returns the sum of a numeric list.

Parameters
  • valuesInt[] | Float[]Numeric list; non-numeric elements are rejected. The list is not mutated.
Returns
Int | FloatThe sum as Float, or integer zero for an empty list.
Throws
  • TypeErrorAn argument or list element has an invalid type.

math::tan

1-parameter signature

math::tan(number)

tan returns the tangent of a given number.

Parameters
  • numberInt | FloatA number.
Returns
FloatThe tangent.

math::trunc

1-parameter signature

math::trunc(value)

trunc removes the fractional part of a number by rounding toward zero.

Parameters
  • valueInt | FloatInput number.
Returns
Int | FloatThe input Int unchanged, or a truncated Float preserving NaN, infinities, and signed zero.
Throws
  • TypeErrorThe argument is not numeric.

math::variance

1-parameter signature

math::variance(values)

variance returns the population variance using N.

Parameters
  • valuesInt[] | Float[]Numeric list; non-numeric elements are rejected. The list is not mutated.
Returns
FloatThe statistic, or NaN for an empty list.
Throws
  • TypeErrorAn argument or list element has an invalid type.

math::variance_sample

1-parameter signature

math::variance_sample(values)

variance_sample returns the sample variance using N - 1.

Parameters
  • valuesInt[] | Float[]Numeric list; non-numeric elements are rejected. The list is not mutated.
Returns
FloatThe statistic, or NaN for fewer than two numbers.
Throws
  • TypeErrorAn argument or list element has an invalid type.