Mathematical functions

Function summaries

abs       find the absolute value
acos      compute inverse cosine
acosh     compute inverse hyperbolic cosine
asin      compute inverse sine
asinh     compute inverse hyperbolic sine
atan      compute inverse tangent
atanh     compute inverse hyperbolic tangent
ceil      round up to nearest integer
choose    randomly pick one item from given arguments
cos       compute cosine
cosh      compute hyperbolic cosine
diff      compute the difference between given arguments
factorial compute factorial
floor     round down to nearest integer
log       compute logarithm
mean      find the average of given arguments
median    find the median of given arguments
neg       negate number
pow       compute exponent
product   find the product of the given arguments
quotient  find the quotient of the given arguments
rand      generate a random number
randint   generate a random integer
round     round to the nearest integer
shuffle   randomly shuffle an array
sin       compute sine
sinh      compute hyperbolic sine
sqrt      compute square root
sum       find the sum of the given arguments
tan       compute tangent
tanh      compute hyperbolic tangent

abs

Returns the absolute value. That is, if the number is negative, the positive equivalent is returned. If it is positive already, the number provided is returned.

Parameters

0. number (required): the number from which to find the absolute value

Returns

number: the absolute value of the argument

Example

abs[-42]; => 42

acos

Computes and returns the inverse cosine of the given number. The given argument must fall between -1 and 1 (inclusive.) This function (and all the trigonometric functions) operate in radians.

Parameters

0. number (required): the number from which to derive the inverse cosine

Returns

number: the inverse cosine of the given number

Example

acos[0]; => 1.570796
acos[1]; => 0

acosh

Computes and returns the inverse hyperbolic cosine of the given number. The argument must be 1 or greater. This function (and all the trigonometric functions) operate in radians.

Parameters

0. number: the number from which to derive the inverse hyperbolic cosine

Returns

number: the inverse hyperbolic cosine of the given argument

Example

acosh[1]; => 0
acosh[2]; => 1.316958

asin

Computes and returns the inverse sine of the given number. The given argument must fall between -1 and 1 (inclusive.) This function (and all the trigonometric functions) operate in radians.

Parameters

0. number: the number from which to derive the inverse sine

Returns

number: the inverse sine of the given number

Example

asin[0]; => 0
asin[-1]; => -1.570796

asinh

Computes and returns the inverse hyperbolic sine of the given number. This function (and all the trigonometric functions) operate in radians.

Parameters

0. number: the number from which to derive the inverse hyperbolic sine

Returns

number: the inverse hyperbolic sine of the given argument

Example

asinh[1]; => 0.881374

atan

Computes and returns the inverse tangent of the given number. This function (and all the trigonometric functions) operate in radians.

Parameters

0. number: the number from which to derive the inverse tangent

Returns

number: the inverse tangent of the given argument

Example

atan[42]; => 1.546991

atanh

Computes and returns the inverse hyperbolic tangent of the given number. The argument must be between -1 and 1 (exclusive.) This function (and all the trigonometric functions) operate in radians.

Parameters

0. number: the number from which to derive the inverse hyperbolic tangent

Returns

number: the inverse hyperbolic tangent of the given argument

Example

atanh[0.5]; => 0.54930

ceil

Round number up to its nearest integer ceiling. If it's already an integer, the same number provided is returned.

Parameters

0. number (required): the number to round up

Returns

number: the integer ceiling of the argument

Example

ceil[7.3]; => 8

choose

Parameters

Returns

Example


    

cos

Computes and returns the cosine of the given number. This function (and all the trigonometric functions) operate in radians.

Parameters

0. number (required): the number from which to derive the cosine

Returns

number: the cosine of the given number

Example

cos[-3.14179]; => -1

cosh

Computes and returns the hyperbolic cosine of the given number. This function (and all the trigonometric functions) operate in radians.

Parameters

0. number (required): the number from which to derive the hyperbolic cosine

Returns

number: the hyperbolic cosine of the given number

Example

cosh[5]; => 74.209949

diff

Parameters

Returns

Example


    

factorial

Computes the factorial of the argument. This is computed via the gamma function, thus allowing fractional numbers. The largest argument that can be provided is approximately 1754.548. Anything larger than that results in an out-of-range error.

Parameters

0. positive number (required): the number from which to compute the factorial

Returns

number: the computed factorial of the argument

Example

factorial[42]; => 1405006117752879898466906934139018484885707565301760

floor

Removes the fractional part of the provided argument, leaving only an integer.

Parameters

0. number (required): the number to find the floor of

Returns

number: the floor of the given number

Examples

floor[4.01]; => 4
floor[9.99]; => 9

log

With only one argument, computes the natural logarithm of the given number to base e. With two arguments, computes and returns the logarithm of the first argument (x) to the given base, calculated as log[x] / log[base].

Parameters

0. number (required): the number from which to derive the logarithm

1. number (optional): the logarithm base to use in the computation

Returns

number: the computed logarithm

Example

log[5]; => 1.609438
log[5, 10]; => 0.698970

mean

Parameters

Returns

Example


    

median

Parameters

Returns

Example


    

neg

Negates the provided argument. That is, a given negative number returns positive, and a given positive number becomes negative.

Parameters

0. number (required): the number to negate

Returns

number: the negated argument

Examples

neg[42]; => -42
neg[-42]; => 42

pow

Returns the exponent of the given base number raised to the given power. If the power is omitted, the base will be squared (power 2.)

Parameters

0. number (required): the base number to raise to the given power

1. number (optional): the power to which to raise the base number

Returns

number: the exponent of the given base raised to the given power

Examples

pow[5]; => 25
pow[5, 5.5]; => 6987.71243

product

Parameters

Returns

Example


    

quotient

Parameters

Returns

Example


    

rand

Generates and returns a random number, most likely fractional, between the two arguments (exclusive.) It doesn't matter which is the high bound and which is the low bound--the number generated will be between them either way. If both parameters are the same number, that number will be returned.

Parameters

0. number (required): either the upper or lower bound of the number to generate

1. number (required): the other bound of the number to generate

Returns

number: a random number between the two arguments

Example

rand[0, 100]; => 64.583948
rand[100, 0]; => 13.995845

randint

Generates and returns a random integer between the two arguments (inclusive.) It doesn't matter which is the high bound and which is the low bound--the number generated will be between them either way. If both parameters are the same number, that number will be returned.

Parameters

0. number (required): either the upper or lower bound of the integer to generate

1. number (required): the other bound of the integer to generate

Returns

number: a random integer between the two arguments

Example

randint[0, 100]; => 57
randint[100, 0]; => 89

round

Rounds the given number to the nearest integer. If the number is exactly half-way between two integers, this function will round towards infinity if positive, and negative infinty if negative.

Parameters

0. number: the number to round

Returns

The rounded number of the given parameter.

Examples

round[5.4]; => 5
round[5.6]; => 6

shuffle

Parameters

Returns

Example


    

sin

Computes and returns the sine of the given number. This function (and all the trigonometric functions) operate in radians.

Parameters

0. number (required): the number from which to derive the sine

Returns

number: the sine of the given number

Example

sin[2.5]; => 0.598472

sinh

Computes and returns the hyperbolic sine of the given number. This function (and all the trigonometric functions) operate in radians.

Parameters

0. number (required): the number from which to derive the hyperbolic sine

Returns

number: the hyperbolic sine of the given number

Example

sinh[-5]; => -74.203211

sqrt

Returns the square root of the provided number.

Parameters

0. number (required): the number of which to find the square root

Returns

number: the square root of the provided number

Examples

sqrt[16]; => 4
sqrt[5]; => 2.236068

sum

Parameters

Returns

Example


    

tan

Computes and returns the tangent of the given number. This function (and all the trigonometric functions) operate in radians.

Parameters

0. number (required): the number from which to derive the tangent

Returns

number: the tangent of the given number

Example

tan[1]; => 1.557408

tanh

Computes and returns the hyperbolic tangent of the given number. This function (and all the trigonometric functions) operate in radians.

Parameters

0. number (required): the number from which to derive the hyperbolic tangent

Returns

number: the hyperbolic tangent of the given number

Example

tanh[0.5]; => 0.462117