Log functions

{log x}
Returns the base 10 logarithm of the value(s) in x
{ln x}
Returns the natural logarithm of the value(s) in x
{exp x}
Returns e to the value(s) in x, or in other words the natural anti-logarithm.

Trigonometric math functions

{sin x}
Returns the sine of the value(s) in x, where x is in radians.
{cos x}
Returns the cosine of the value(s) in x, where x is in radians.
{tan x}
Returns the tangent of the value(s) in x, where x is in radians.
{asin x}
Returns the arcsine of the value(s) in x. The returned values are in radians.
{acos x}
Returns the arccosine of the value(s) in x. The returned values are in radians.
{atan x}
Returns the arctangent of the value(s) in x. The returned values are in radians.
{pi}
Just returns the value of pi.
{polar x, y}

Returns a table value with the first column r being the radius and the second a being the angle of x and y converted to polar coordinates.

If only a single argument is given, its must have two columns and the first will be assumed to be x and the second y.

{cart r, a}

Returns a table value with the first column being the x value and the second being the y of the radius r and angle a converted to cartesian coordinates.

If only a single argument is given, its must have two columns and the first will be assumed to be r and the second a.

Hyperbolic functions

{sinh x}
Returns the hyperbolic sine of the value(s) in x.
{cosh x}
Returns the hyperbolic cosine of the value(s) in x.
{tanh x}
Returns the hyperbolic tangent of the value(s) in x.
{asinh x}
Returns the principle value of the inverse hyperbolic sine of the value(s) in x.
{acosh x}
Returns the principle value of the inverse hyperbolic cosine of the value(s) in x.
{atanh x}
Returns the principle value of the inverse hyperbolic tangent of the value(s) in x.

Complex Number functions

Please see the Complex Number help page for more information on complex number handling in Math Minion.
{complex r, i}
Returns a table value with columns r and i representing a complex number. However any two column numeric value can be used as a complex argument.
{cmult w, z}
Returns the complex product of multiplying the two complex value arguments.
{cdiv w, z}
Returns the complex result of dividing the w by z where both are complex values.
{cpow w, z}
Returns the complex result of raising w to the power z where both are complex values.
{cabs z}
Returns the absolute value of the complex value z. The result is a real number.
{cln z}
Returns the complex natural logarithm of the complex value z.
{cexp z}
Returns the complex value result of raising e to the complex value z, or in other words the natural anti-logarithm.
{csin z}
Returns the sine of the complex value z.
{ccos z}
Returns the cosine of the complex value z.
{ctan z}
Returns the tangent of the complex value z.
{casin z}
Returns the arcsine of the complex value z.
{cacos z}
Returns the arccosine of the complex value z.
{catan z}
Returns the arctangent of the complex value z.
{csinh z}
Returns the hyperbolic sine of the complex value z.
{ccosh z}
Returns the hyperbolic cosine of the complex value z.
{ctanh z}
Returns the hyperbolic tangent of the complex value z.
{casinh z}
Returns the inverse hyperbolic sine of the complex value z.
{cacosh z}
Returns theinverse hyperbolic cosine of the complex value z.
{catanh z}
Returns the inverse hyperbolic tangent of the complex value z.

Reduction Functions

{max x}
Returns the maximum of the values in x. If additional arguments are supplied, the maximum value of all their elements is returned.
{min x}
Returns the minimum of the values in x. If additional arguments are supplied, the minimum value of all their elements is returned.
{maxrows x}
Returns a column array with the maximums of the values in each row of x. If x is a table value, then all the numeric columns must have the same unit dimensions, but string columns are simply ignored.
{maxcols x}
Returns a row array with the maximums of the values in each column of x. String columns in table values are ignored.
{minrows x}
Returns a column array with the minimums of the values in each row of x. If x is a table value, then all the numeric columns must have the same unit dimensions, but string columns are simply ignored.
{mincols x}
Returns a row array with the minimums of the values in each column of x. String columns in table values are ignored.
{sum x}
Returns the summation of the values in x. If x is a table value, then all numeric columns must have the same dimensions. String columns are ignored.
{sumrows x}

Returns a column array with the summations of the values in each row of x. If x is a table value, then all the numeric columns must have the same unit dimensions, but string columns are simply ignored.

However if a second argument is given as a string, then that string is used as a column name for the sums and a table value is returned. Also in this case if x is a table value, any string columns are copied into the result as well.

{sumcols x}
Returns a row array with the summations of the values in each column of x. String columns in table values are ignored.

Comparison functions

{eq a, b}
Returns an element wise comparison of a and b with the corresponding elements in the return value being 1 if the a value is equal to the b value or 0 if it is not.

If a does not have the same number of elements as b, then the smaller number must be divisible into the larger without a remainder and those values will be duplicated appropriately to match with the larger number of values.

If a and b are tables, they must have the same number of rows and columns and have the same column types. A table of results will be returned using a's column names.

{ne a, b}
Returns an element wise comparison of a and b with the corresponding elements in the return value being 1 if the a value is not equal to the b value or 0 if it is.

If a does not have the same number of elements as b, then the smaller number must be divisible into the larger without a remainder and those values will be duplicated appropriately to match with the larger number of values.

If a and b are tables, they must have the same number of rows and columns and have the same column types. A table of results will be returned using a's column names.

{le a, b}
Returns an element wise comparison of a and b with the corresponding elements in the return value being 1 if the a value is less than or equal to the b value or 0 if it is not.

If a does not have the same number of elements as b, then the smaller number must be divisible into the larger without a remainder and those values will be duplicated appropriately to match with the larger number of values.

If a and b are tables, they must have the same number of rows and columns and have the same column types. A table of results will be returned using a's column names.

{lt a, b}
Returns an element wise comparison of a and b with the corresponding elements in the return value being 1 if the a value is less than the b value or 0 if it is not.

If a does not have the same number of elements as b, then the smaller number must be divisible into the larger without a remainder and those values will be duplicated appropriately to match with the larger number of values.

If a and b are tables, they must have the same number of rows and columns and have the same column types. A table of results will be returned using a's column names.

{ge a, b}
Returns an element wise comparison of a and b with the corresponding elements in the return value being 1 if the a value is greater than or equal to the b value or 0 if it is not.

If a does not have the same number of elements as b, then the smaller number must be divisible into the larger without a remainder and those values will be duplicated appropriately to match with the larger number of values.

If a and b are tables, they must have the same number of rows and columns and have the same column types. A table of results will be returned using a's column names.

{gt a, b}
Returns an element wise comparison of a and b with the corresponding elements in the return value being 1 if the a value is greater than the b value or 0 if it is not.

If a does not have the same number of elements as b, then the smaller number must be divisible into the larger without a remainder and those values will be duplicated appropriately to match with the larger number of values.

If a and b are tables, they must have the same number of rows and columns and have the same column types. A table of results will be returned using a's column names.

{and a, b}

If the first argument is a scalar then:

Returns true (the value 1) if the first value (index 1,1) of every argument is non-zero. If any element is unknown, then the result is unknown as well. If a zero value is encountered, then the values for the remaining arguments (left to right) will not be evaluated.

If the first argument is not a scalar then:

All the arguments are evaluated and they must all have either the same number of elements as the first argument or be scalars. The result will be a numeric value of the same size as the first argument, with each value set to 0.0 unless the comparable elements of all the arguments are nonzero. Scalar arguments will use their single value to compare with all element positions.

{or a, b}

If the first argument is a scalar then:

Returns the value of the first argument whose first element (index 1,1) is non-zero. If an element is encountered with an unknown value, then the result is unknown as well. In either case the remaining arguments are not evaluated.

If the first argument is not a scalar then:

All the arguments are evaluated and they must all have either the same number of elements as the first argument or be scalars. The result will be a numeric value of the same size as the first argument, with each value set to 1.0 unless the comparable elements of all the arguments are zero. Scalar arguments will use their single value to compare with all element positions.

{not a}
Each element of the return value is 1 if the corresponding element of a is 0 otherwise it will be 1.
{isnan a}
Each element of the return value is 1 if the corresponding element of a is a NaN (not a number - usually an arithmetic error).
{if a, b, c}
If the value of a is unknown or a scalar:
  • If the value of of a is known and not zero, the value of b is returned.
  • If the value of a is zero, the value of c is returned.
  • If the value of a is unknown, no value is returned
If the value of a is known and has more than one element, then:
  • b and c must have the same number of elements.
  • b and c must have the same unit dimensions
  • Each element of the returned value will be taken from the corresponding element of b if the corresponding element of a is not zero, or from c if it is zero.
  • If a does not have the same number of elements as b and c, then the smaller number must be divisible into the larger without a remainder and those values will be duplicated appropriately to match with the larger number of values.
If a is a string object, then elements that are zero length will be considered as having a zero value. In all cases if b is numeric, c must also be numeric and likewise if b is a string object, c must also be a string object.

Matrix functions

{append a, b}

Creates a new object which contains all the columns of all the arguments. All arguments must have the same number of rows.

If all of the columns aren't the same type (numeric, string or table) or if numeric and they have different unit dimensions, then a table value will be returned.

{array r, c, i}

Returns a string or numeric matrix with r rows and c columns with all elements initialized to the value of i. If only two arguments are supplied, they are assumed to be r and i with the number of columns being 1.

{cell roffset, coffset}
This function is only valid when used by a formula in the matrix object. It returns the value of a matrix cell, which is offset from the current cell by roffset and coffset.

Thus {cell -3, 1} when evaluated for a cell at row 10 and column 4, would return the value of the cell at row 7 and column 5.

{col}
This function is only valid when used by a formula in the matrix object. Returns the column number for the cell that is evaluating the function.
{cc a, b}

Returns a column array with all of the values of the arguments concatenated together. Matrices are first converted to arrays on a row by row basis. See the redim function if you wish to convert the result back into a matrix.

When the arguments to concat are table values, all arguments must have the same number and type of columns. In the resulting table each column will be the concatenation of the respective columns of the arguments. The name and display unit for each column will be taken from the first argument.

Short form of concat.

{cross a, b}
Calculates the cross product between two vectors. The number of elements in each argument must be divisible by 3. If the number of elements in either argument exceeds 3, then the cross product will be calculated for every three elements and returned in a matrix with 3 columns and each row containing the cross product. If one argument has fewer elements than the other, its values will be reused in order as necessary.
{det a}
Calculates the determinant of matrix a.
{dot a, b}
Performs a matrix multiplication of values a and b and returns the result
{eigval a}
Returns the eigenvalues for a square matrix a as a table with real and complex columns.
{eigvect a, v}

Attempts to return the eigenvector(s) for square matrix a, corresponding to the eigenvalue(s) in v. If there is more than one eigenvalue, the result will be a matrix with each column containing the corresponding eigenvector. If a vector cannot be found, that column will be zero filled.

Eigenvectors cannot be calculated for eigenvalues with nonzero imaginary components.

{invert a}
Performs a matrix inversion of a and returns the result.
{ncols x}
Returns the number of columns in x
{nrows x}
Returns the number of rows in x
{redim a, ncols}
Returns a value with the same number of elements as a, but arranged with ncols. Values are arranged on a row by row basis. The ncols value must divide evenly into the total number elements in a.
{row}
This function is only valid when used by a formula in the matrix object. Returns the row number for the cell that is evaluating the function.
{tr a}
Returns the transposition of a (i.e. the rows and columns are reversed). Short form of transpose.

If a is a table value, then a table value will be returned that is displayed with the columns being rows and rows being columns. This just for display and does not affect how the value is referenced or how functions and operations act upon it.

Statistical functions

{average x, by}
Returns the average of the values of x.

If the second parameter is 0 or missing, this will be the scalar average of all the values of x. If it is 1, then the result is a column vector whose values will be the averages of each row of x. If it is 2, then it will be a row vector of averages of the columns of x.

{median x, t}

Returns the median of the values of x. If the second parameter is 0 or missing, this will be the scalar median of all the values of x. If it is 1, then the result is a column vector whose values will be the medians of each row of x. If it is 2, then it will be a row vector of medians of the columns of x.

{geomean x, t}

Returns the geometric mean of the values of x. If the second parameter is 0 or missing, this will be the scalar geometric mean of all the values of x. If it is 1, then the result is a column vector whos values will be the geometric means of each row of x. If it is 2, then it will be a row vector of geometric means of the columns of x.

{harmmean x, t}

Returns the harmonic mean of the values of x. If the second parameter is 0 or missing, this will be the scalar harmonic mean of all the values of x. If it is 1, then the result is a column vector whose values will be the harmonic means of each row of x. If it is 2, then it will be a row vector of harmonic means of the columns of x.

{var x, t}

Returns the calculated variance for the sample x. Note that the unit type for this will be the square of the unit type of x. The square root of this is the standard deviation.

If the second parameter is 0 or missing, this will be the scalar variance of all the values of x. If it is 1, then the result is a column vector whose values will be the variance of each row of x. If it is 2, then it will be a row vector of variance of the columns of x.

{factorial x}
Returns a unitless matrix the same size as x, but with each element replaced the factorial of its value. If the value is not an integer, it will be rounded to the nearest integer and if the value is negative, it will be replaced with 1. Note that values greater than 170 will result in an "inf" value since the result would be greater than the largest floating point value for the device.
{lngamma x}

Returns the natural logarithm of the gamma function for x, where x > 0. Note that where x is an integer, then gamma x is equal to (x - 1)!. Thus for calculations that involve division of large factorials that might overflow, subtracting the ln gamma values might be a better alternative.

{permut n, k}

Returns the number of permutations of k objects that can be selected from a population of n objects, where the order of selection is significant.

{combin n, k}

Returns the number of combinations of k objects that can be selected from a population of n objects, where the order of selection is not significant.

{normdist x, u, s, c}

Returns the normal distribution for x, given a mean u and standard deviation s, where all three have the same unit type. If argument c is missing or is equal to 0, then a cumulative distribution is returned. If it is present and non-zero, then the probability mass function is returned.

{norminv p, u, s}

Returns the inverse of the normal distribution function for probability p, given a mean u and standard deviation s, where the mean and standard deviation must have the same unit type.

{binomdist n, s, p }

Returns the binomial distribution probability for n trials with s successes p probability of success on each trial.

The result will have the maximum rows and columns of any of the parameters, with smaller parameters having their values reused as necessary.

{betadist x, a, b }

Returns the cumulative beta probability density function for x (which must be 0 <= x <= 1) and the a (alpha) and b (beta) parameters.

The result will have the maximum rows and columns of any of the parameters, with smaller parameters having their values reused as necessary.

{chidist x2, df}

Returns the one tailed probability of the chi-squared distribution. The x2 value should be the chi squared value and df should be the degrees of freedom. See also the chitest function.

{chitest a, e}

Calculates the chi squared value and degrees of freedom from the actual and expected values in matrix values a and e respectively. These are then used with the chidist function to calculate the probability that the accepted values could match the expected values. Normally the a and e values should have the same number of rows and columns, but if they don't, the a sizes are used with values being reused as necessary.

{ttest a, b}

Uses the Student T test to determine the probability that two populations with an assumed equal variance have the same mean. Returns the two tailed distribution value.

{tptest a, b}

Uses the paired Student T test to determine the probability that two populations with an equal number of elements and variance paired by sample have the same mean. Returns the two tailed distribution value.

Table functions

Functions that work with tables (Many other single parameter functions also work)
{table n, c}
Creates a table value whose column names are the elements of n and values are taken from the columns of c and additional parameters. If n is a table value, then its column names are used

Alternatively pairs of names and values can be used as in

{table "First", x1, "Second", x2}

and so forth.

In either case, the value arguments should all have the same number of rows. If there are fewer names than values or vice versa, the lessor number is used and the extras are ignored.

Finally if there is only a single string argument starting with the word "table", then the argument is assumed to be CSV data of the form described in the Data Table help and a table value is constructed from it.

{nrows x}
Returns the number of rows in x
{ncols x}
Returns the number of columns in x
{colnames x}
Returns an array consisting of the column names of table x
{maxrows x}
Returns a column array with the maximums of the values in each row of x. If x is a table value, then all the numeric columns must have the same unit dimensions, but string columns are simply copied.
{maxcols x}
Returns a row array with the maximums of the values in each column of x. String columns in table values are ignored.
{minrows x}
Returns a column array with the minimums of the values in each row of x. If x is a table value, then all the numeric columns must have the same unit dimensions, but string columns are simply copied.
{mincols x}
Returns a row array with the minimums of the values in each column of x. String columns in table values are ignored.
{sum x}
Returns the summation of the values in x. If x is a table value, then all numeric columns must have the same dimensions. String columns are ignored.
{sumrows x}

Returns a column array with the summations of the values in each row of x. If x is a table value, then all the numeric columns must have the same unit dimensions, but string columns are simply ignored.

However if a second argument is given as a string, then that string is used as a column name for the sums and a table value is returned. Also in this case if x is a table value, any string columns are copied into the result as well.

{sumcols x}
Returns a row array with the summations of the values in each column of x. String columns in table values are ignored.
{concat a, b}

(concat can be abbreviated to just cc)

Returns a column array with all of the values of the arguments concatenated together. Matrices are first converted to arrays on a row by row basis. See the redim function if you wish to convert the result back into a matrix.

When the arguments to concat are table values, all arguments must have the same number and type of columns. In the resulting table each column will be the concatenation of the respective columns of the arguments. The name and display unit for each column will be taken from the first argument.

{append a, b}

Creates a new object which contains all the columns of all the arguments. All arguments must have the same number of rows.

If all of the columns aren't the same type (numeric, string or table) or if numeric and they have different unit dimensions, then a table value will be returned.

{groupsum t, c}

The t argument must be a table value and the c argument a string value with the name of a column in that table. The result is a table where the first column will contain all the unique values of that designated column. The other columns will be the sums of the rows that share that unique value. String columns are ignored.

{groupmax t, c}

The t argument must be a table value and the c argument a string value with the name of a column in that table. The result is a table where the first column will contain all the unique values of that designated column. The other columns will be the maximums of the rows that share that unique value. String columns are ignored.

{groupmin t, c}

The t argument must be a table value and the c argument a string value with the name of a column in that table. The result is a table where the first column will contain all the unique names of that designated column. The other columns will be the minimums of the rows that share that unique value. String columns are ignored.

{select from, selector}

Rows will be selected from the "from" argument, which can be a string, number or table value.

The "selector" can be either a numeric or string value. If it is a numeric value, it should have a single column and the same number of rows as the "from" value. The returned value will consist of all the rows of "from" for which the corresponding row value of "selector" is nonzero.

Alternatively if the "selector" value is a string value, then each row should consist of a query of the form

"column op value"

where column is the name of the column if "from" is a table or the number of the column if it is a numeric or string value. The "op" term is one of ("=", "!=", "<", "<=", ">", ">=", "?", "*"). The "value" term is some value that will be matched against each row of the column using the given operation. The value isn't a formula, but can have a unit if it is numeric. String comparisons are case insensitive and if the value is omitted it will match an empty or blank filled string.

The "?" operator means contains and only works with string values.

The "*" selects the column value if it matches the regular expression in value. It also only works with string values.

If the selector has more than one row, or multiple terms separated by a new line or comma, each result while be "ANDed" with the previous result, unless the "column" term is preceded by a "|" character. In that case an OR operation is performed with the previous result. An "&" character can optionally be used for AND operations to make the formula more descriptive.

Selector xamples might be:

  • "name = fred"
  • {cc "dept = sales", "age >= 30"}
  • {cc "dept = sales", "| dept = support", "& age >= 30"}
{tr a}
Returns the transposition of a (i.e. the rows and columns are reversed). Short form of transpose.

If a is a table value, then a table value will be returned that is displayed with the columns being rows and rows being columns. This just for display and does not affect how the value is referenced or how functions and operations act upon it.

{csv t, sep}

Returns a string representing the t table value argument in Comma Separated Value format.

If a string value is included as the second argument, it will be used as the separator instead a comma.

Lookup functions

{lookup i, in, v}
Looks up the value(s) of i in the array in and interpolates (or extrapolates) the corresponding value in v. The in and v arrays must have the same number of elements (at least 2). The returned value will be the same size as l with the conversion unit type of v.

Note - this function assumes the values to be in increasing order

{indexof x, in}

Returns a row array with two columns. The first column holds the row numbers of the first cell found in in, which has the same value as the first value of x. The second column holds the column number of that cell.

The cells are scanned row by row, with the first match being returned. If none of the cells match, then a zeroes are returned.

If x is not a scalar, then the process is repeated for each value of x, with the result being in the corresponding row of the returned value.

{select from, selector}

Rows will be selected from the "from" argument, which can be a string, number or table value.

The "selector" can be either a numeric or string value. If it is a numeric value, it should have a single column and the same number of rows as the "from" value. The returned value will consist of all the rows of "from" for which the corresponding row value of "selector" is nonzero.

Alternatively if the "selector" value is a string value, then each row should consist of a query of the form

"column op value"

where column is the name of the column if "from" is a table or the number of the column if it is a numeric or string value. The "op" term is one of ("=", "!=", "<", "<=", ">", ">=", "?", "*"). The "value" term is some value that will be matched against each row of the column using the given operation. The value isn't a formula, but can have a unit if it is numeric. String comparisons are case insensitive and if the value is omitted it will match an empty or blank filled string.

The "?" operator means contains and only works with string values.

The "*" selects the column value if it matches the regular expression in value. It also only works with string values.

If the selector has more than one row, or multiple terms separated by a new line or comma, each result while be "ANDed" with the previous result, unless the "column" term is preceded by a "|" character. In that case an OR operation is performed with the previous result. An "&" character can optionally be used for AND operations to make the formula more descriptive.

Selector xamples might be:

  • "name = fred"
  • {cc "dept = sales", "age >= 30"}
  • {cc "dept = sales", "| dept = support", "& age >= 30"}

String functions

{fmt f, x, u}

Formats a number x, using the format string f, optionally using a display unit.

The x value can be a numeric scalar, array or matrix.

The f parameteris a format string is styled on C format string and typically is of the form:

%12.4f

which says the field should be 12 characters wide with 4 characters after the decimal point in normal floating point format.

If c is used instead of f, the numbers will have commas added (e.g. 1,234,567.89).

An e can be used instead of the f for exponential format (e.g. 1.23457e+6).

You can even show numbers with an arbitrary base between 2 and 36. For instance a value could be represented in hex with %14.16x.

For the date units (date, dated, datem), you can use a / or - and that character will be used to separate the month, day and year. If the dated or datem units are being used, prefix the whole format with a d or m so it is the last four digits that are grouped as the year.

Note it is also permissable to omit the size number, i.e. %.2f would be fine and the number would just be right justified.

If the third parameter, u, is used, it must be the name of a unit compatible with the unit type of x.

Thus function
{fmt "%12.2f", 12.1234}
would return
12.12
, while
{fmt "%12.2f", 12.1234, "%"}
would return
1212.34).

{html v}

Returns a string value containing HTML that can be used to display the value of v.

{join s, sep}

Joins the elements of string array s into a single string, with the elements separated by the scalar string sep. If s has more than one column and more than one row, the result will be a column array with each row of s joined.

Also when s is a matrix, an optional third paramater can be supplied, in which case the second parameter is used to join the columns and the third parameter is used to join the rows, resulting in a scalar string.

{jsonparse s}

The s parameter must be a string consisting of legal JSON code. The result is a Math Minion JsonValue.

{split s, sep}

Splits the elements of string s into an array string, using the scalar string sep as the separator. If s isn't a scalar, the result will one row per value of s, with each value split into columns. The number of columns will be determined by the number of splits of the first element.

Also an optional third paramater can be supplied, in which case the second parameter is used to separate the columns and the third parameter is used to separate the rows, resulting in a string matrix. In this case, only the first value of s is used.

If no separator is supplied, then the first element of s will be split into a single array of individual characters.

{match rx, s}

A regular expression search is performed on the elements of s using the regular expression rx, with the matched portions of the strings being returned. If a match is not found, then an empty string "" is returned for that element.

The rx value does not need to be a scalar and the normal row order repeating is used for mismatched sizes.

{replace rm, rr, s}

A regular expression replacement is performed on the elements of s using the regular expression rm to match and rr to replace. The transformed result is returned (s is not modified). If a match is not found, then an empty string "" is returned for that element.

The rm and rr values must have the same number of elements, but do not have to be scalars or the same size as s.

{substr s, b, l}

Returns a string matrix of the same size as s, but consisting of sub-strings of the elements of s. The number b is the position of the first character of the substring in s and l is the length of the substring. If l is not supplied or is greater than the number of characters available, the substring will consist of all the characters after position b. If b and l are not the same size as s, their values will be reused as necessary until all the elements of s are processed.

If the b value is negative it will be the position from the end of the string. That is -1 would be the last character in the string.

{strfind s, f}

Finds the first occurrence of the regular expression f in the elements of string s. The result is a matrix with a number of rows equal to the total number of elements in s and two columns. The first column will contain the position in the s element of the beginning of f and the second column will contain the length of the found string. If f is not the same size as s, its values will be reused as necessary until all the elements of s are processed.

If the string is not found in a given element, the position for that element will be 0.

{strlen s}

Returns a numeric matrix of the same size as s, but with each element having the length of the corresponding element of s.

{lowercase s}

A string is returned where all the uppercase characters of s have been replaced with their lowercase equivalents.

{uppercase s}

A string is returned where all the lowercase characters of s have been replaced with their uppercase equivalents.

{utf8 a}

If a is a string, then the first element is converted to UTF8 bytes, which are returned as a numeric array with one byte value per element.

If a is a numeric value, then all the elements are assumed to be UTF8 byte values an a single element string value is constructed from them.

Time functions

{mktime d}
Converts a date represented by a unitless number in the form yyyymmdd.hhmmss into the number of seconds since 1970-01-01 00:00:00 (the unix time base). The inverse function is date.
{date s}
Converts value representing the number of seconds since 1970-01-01 00:00:00 (the unix time base), into a unitless number in the form yyyymmdd.hhmmss. It is the inverse function of mktime.
{now}
Returns the number of seconds since 1970-01-01 00:00:00 GMT (the unix time base). It will return the current time value every time it is evaluated.
{timezone}
Returns the number of seconds difference between the current device time zone and GMT.

3D Transform functions

These functions implement 3D graphical transformations, based on 4x4 transformation matrices. All assume the y axis is vertical, the x horizontal and z positive out of the screen.
{translate xyz}
Creates a 4x4 transformation matrix corresponding to an x, y, z translation using the three coordinates of the parameter array.
{scale xyz}
Creates a 4x4 transformation matrix corresponding to scaling the x, y and z values using the three scaling factors of the parameter array.
{roll angle}
Creates a 4x4 transformation matrix for rotations of angle radians around the z axis.
{pitch angle}
Creates a 4x4 transformation matrix for rotation of angle radians around the x axis.
{yaw angle}
Creates a 4x4 transformation matrix for rotation of angle radians around the y axis.
{transform trans, coords}

Applies the 4x4 transformation matrix in the first parameter to the x, y and z coordinates in the second parameter. The number of elements in the coordinates parameter must be a multiple of 3 and typically coords is a matrix with one or more rows, with x, y and z columns.

The result is a matrix the same size as coords, with the transformation applied to each group of 3 elements.

Miscellaneous functions

{abs x}
Returns the absolute value(s) of x
{alert m}
Shows an alert box with message m. If m is an array with more than one value, the first is used as the title and the second as the message.
{defunit x}
Returns a string value containing the default conversion unit name for x.
{baseunit x}

Returns a unit value with the default base conversion unit x.

For instance {baseunit 60 mph} would return a value of 1 m/s.

{eval s}
Evaluates the argument s, which must be a string value, as a formula. If s has more than one element, only the first is evaluated.
{evaljs c, a}

This function is disabled by default for security reasons. It can be enabled in code on a private server.

Executes the first argument c, which must be a string value, as Javascript code. If c has more than one element, only the first is evaluated. Additional arguments are optional and are converted to Javascript objects that the code can access.

The last calculated object is converted into an appropriate Math Minion value.

  • A string will become a single value Minion string value.
  • A number will become a single value Minion numeric value with a unit of fraction (i.e. unitless).
  • For arrays, the type of the first element will determine the type of Minion value created.
  • String and numeric arrays will have a single column and a number of rows corresponding to the returned array length. Numeric arrays will be unitless.
  • If the calculated array contains objects (dictionaries), then it will be assumed a table value is being returned with each column represented by an object in the array. Each object must have a "name" value and a "values" value. The "values" value must be an array corresponding to the row values of the column. All columns must have the same number of values.

    The object can also have a "unit" value, which should be a string corresponding to a unit that Math Minion can understand (e.g. ft/s). If the column contains strings, then a unit of "string" must be provided.
  • If an object (dictionary) is returned, then it is assumed to define a Minion value in the same manner as a table column above, except a "name" value is not needed and will be ignored and a "columns" value can be supplied to partition the values into rows and columns. The length of the "values" must be evenly divisible by the "columns" value if it is supplied.

    As with table columns, a unit of "string" is required to create a Minion string value. If no "unit" value is supplied, a unitless numeric value will be created.

If other arguments in addition to the code value are supplied, they are converted into Javascript objects and made available to the code in an array named "mm_args". String and numeric values will be converted into objects with "unit", "columns" and "values" elements as described above, while table values will be converted to arrays as also described above.

Note that for anything other than the simplest expressions, it is probably best to create the Javascript code in a separate expression using a beginning single quote to designate everything following as a string. This simplifies dealing with single and double quotes in the code.

{getbit n, x}
Returns the bit at bit position n of a numeric value x, where a n of 1 would be the least significant bit. The bit number does not have to be a scalar and the returned value will have one column for each bit number value and a row for each value of x
{int x}
Returns integer portion of x
{numeric x}

Returns a numeric matrix value of x. If x is already numeric it is simply returned.

If x is string value, then an attempt is made to interpret its values as numbers and if that isn't possible, a zero is used in its place.

If x is a table value, then all of the columns must be of the same unit dimensions. String columns are ignored.

{rand nr, nc}

Creates a matrix with nr rows and nc columns and with all elements set to random numbers between 0 and 1.

If the column argument is omitted, it is assumed to be 1 and if both arguments are omitted, they are both assumed to be 1.

{round x}
returns the nearest whole number of x. Thus an x value of {cc -3.49, -3.5, 3.49, 3.5} would return -3, -4, -4, 3, 4, 4. The x value must have a dimensionless unit type
{sign x}
Returns a unitless matrix the same size as x, but with each element replaced with 1 if the x element is greater or equal to 0 and -1 if the element is negative.
{sort x, n}
Returns a sorted copy of x.

If x is a table value it will be sorted on column number n.

If n is omitted, the first column is used. If n is negative, the sort is reversed

{isort x, n}
Creates a column array of indexes, such that if they are used with the index operator for x, the result would be a sorted copy of x

If x is a table value the sort will be on its column number n.

If n is omitted, the first column is used. If n is negative, the sort is reversed

{mod x, n}
Convenience function for x%n
{sqrt x}
Convenience function for x^0.5
{wfetch method, url, headers}

This uses XMLHttpRequest to perform net requests, but note that Cross Origin Resource Sharing (CORS) policies will probably prevent its use with servers you don't control.

The method and url arguments are what is passed to the request's open method. The headers argument, if supplied, should be a string matrix with the first column containing any header names and the second header values. A string array will also work with names and values alternating. This is passed to the request's setRequestHeader method.

The return value is the request responseText.