Mathematical Functions

Functions for performing mathematical operations.

Abs

Abs( value ) -> returns: Number

Returns the absolute value of a number. If the input is null, then it returns 0.

Name Type Description
value Number A number on which to perform the operation.
Returns: Number
Example

prints 3

Abs(-3)

Acos

Acos( value ) -> returns: Number

Returns the arccosine of the input value in radians, in the range of zero to PI. If the input value is outside the appropriate range of +/- 1, then NaN is returned.

Name Type Description
value Number A number between -1 and 1 on which to perform the operation.
Returns: Number
Example

prints 1.266104

Acos(0.3)

Asin

Asin( value ) -> returns: Number

Returns the arcsine of the input value in radians, in the range of -PI/2 and PI/2. If the input value is outside the appropriate range of +/- 1, then NaN is returned.

Name Type Description
value Number A number between -1 and 1 on which to perform the operation.
Returns: Number
Example

prints 0.304693

Asin(0.3)

Atan

Atan( value ) -> returns: Number

Returns the arctangent of the input value in radians, in the range of -PI/2 and PI/2.

Name Type Description
value Number A number on which to perform the operation.
Returns: Number
Example

prints 0.785398

Atan(1)

Atan2

Atan2( y, x ) -> returns: Number

Returns the arctangent of the quotient of the input values in radians, in the range of -PI and zero or zero and PI depending on the sign of arguments.

Name Type Description
y Number A number representing the y-coordinate.
x Number A number representing the x-coordinate.
Returns: Number
Example

prints -2.356194

Atan2(-1, -1)

Average

Average( values ) -> returns: Number

Returns the average of a set of numbers.

Name Type Description
values Number[] A list or array of numbers on which to perform the operation.
Returns: Number
Example

prints 5

var array = [0,10]
Average(0,10,5,array)


Ceil

Ceil( value, numPlaces? ) -> returns: Number

Returns the input value rounded upwards to the given number of decimal places.

Name Type Description
value Number The number to round upward.
numPlaces Number optional The number of decimal places to round the value to. Default is 0. Trailing zeros will be truncated.
Returns: Number
Example

prints 2135.1

Ceil(2135.0905, 2)

Constrain

Constrain( value, min, max ) -> returns: Number

Since version 1.2

Constrains the given input value to minimum and maximum bounds. For example, if the input value is 10, the lower bound is 50, and the upper bound is 100, then 50 is returned.

Name Type Description
value Number The value to constrain to the given min and max bounds.
min Number The lower bound by which to constrain the input value. If the given value is less than the min, then min is returned.
max Number The upper bound by which to constrain the input value. If the given value is greater than the max, then max is returned.
Returns: Number
Example

returns 5

Constrain(5, 0, 10)

returns 0

Constrain(-3, 0, 10)

returns 10

Constrain(553, 0, 10)

Cos

Cos( value ) -> returns: Number

Returns the cosine of the input value in radians.

Name Type Description
value Number A number in radians on which to perform the operation.
Returns: Number
Example

prints 0.540302

Cos(1)

Exp

Exp( x ) -> returns: Number

Returns the value of e to the power of x, where e is the base of the natural logarithm 2.718281828.

Name Type Description
x Number The power, or number of times to multiply e to itself.
Returns: Number
Example

prints 7.389056

Exp(2)

Floor

Floor( value, numPlaces? ) -> returns: Number

Returns the input value rounded downward to the given number of decimal places.

Name Type Description
value Number A number to round downward.
numPlaces Number optional The number of decimal places to round the number. Default is 0. Trailing zeros will be truncated.
Returns: Number
Example

prints 2316.25

Floor(2316.2562, 2)

Log

Log( x ) -> returns: Number

Returns the natural logarithm (base e) of x.

Name Type Description
x Number A number on which to perform the operation.
Returns: Number
Example

prints 2.302585

Log(10)

Max

Max( inputArray ) -> returns: Number

Returns the highest value in a given array.

Name Type Description
inputArray Number[] An array of numbers. Can also be the first parameter of a list of numbers.
Returns: Number
Example

prints 89

Max([23,56,89])

prints 120

Min(23,5,120,43,9)

Mean

Mean( values ) -> returns: Number

Since version 1.1

Returns the mean value of an array of numbers.

Name Type Description
values Number[] A list or array of numbers from which to calculate the mean.
Returns: Number
Example
Use a single array as input

returns 5

var vals = [1,2,3,4,5,6,7,8,9];
Mean(vals);

Use comma separated values with array element

returns 5

var array = [0,10];
Mean(0,10,5,array);


Min

Min( inputArray ) -> returns: Number

Returns the lowest value in a given array.

Name Type Description
inputArray Number[] An array of numbers. Can also be the first parameter of a list of numbers.
Returns: Number
Example

prints 23

Min([23,56,89])

prints 5

Min(23,5,120,43,9)

Pow

Pow( x, y ) -> returns: Number

Returns the value of x to the power of y.

Name Type Description
x Number The base value.
y Number The exponent. This indicates the number of times to multiply x by itself.
Returns: Number
Example

prints 9

Pow(3, 2)

Random

Random( ) -> returns: Number

Returns a random number between 0 and 1.

Name Type Description
Returns: Number
Example
Random()

Round

Round( value, numPlaces? ) -> returns: Number

Returns the input value, rounded to the given number of decimal places.

Name Type Description
value Number A number to round.
numPlaces Number optional The number of decimal places to round the number to. Default is 0. Trailing zeros will be truncated.
Returns: Number
Example

prints 2316.26

Round(2316.2562, 2)

Sin

Sin( value ) -> returns: Number

Returns the sine of the input value.

Name Type Description
value Number A number in radians on which to perform the operation.
Returns: Number
Example

prints 0.841741

Sin(1)

Sqrt

Sqrt( value ) -> returns: Number

Returns the square root of a number.

Name Type Description
value Number A number on which to calculate the square root.
Returns: Number
Example

prints 3

Sqrt(9)

Stdev

Stdev( inputArray ) -> returns: Number

Returns the standard deviation (population standard deviation) of a set of numbers.

Name Type Description
inputArray Number[] An array of numbers on which to perform the operation. Can also be the first parameter of a list of numbers.
Returns: Number
Example

prints 27.5

Stdev(23,56,89,12,45,78)

Sum

Sum( inputArray ) -> returns: Number

Returns the sum of a set of numbers.

Name Type Description
inputArray Array An array of numbers on which to perform the operation. Can also be the first parameter of a list of numbers.
Returns: Number
Example

prints 303

Sum(23,56,89,12,45,78)

Tan

Tan( value ) -> returns: Number

Returns the tangent of an angle in radians.

Name Type Description
value Number A number on which to calculate the tangent.
Returns: Number
Example

prints 0.57389

Tan(0.521)

Variance

Variance( inputArray ) -> returns: Number

Returns the variance (population variance) of a set of numbers.

Name Type Description
inputArray Number[] An array of numbers on which to perform the operation. Can also be the first parameter of a list of numbers.
Returns: Number
Example

prints 756.25

Variance(12,23,45,56,78,89)


Feedback on this topic?