Image inserted by SSuite Office Fandango Desktop EditorSSuite Basic-Math User's Guide

Index of Contents

Introduction / Special NotesNumber MethodsStandard Math ConstantsCustom Math Constants
Standard FunctionsBitwise OperatorsExamples of Bitwise OperationsExpressions
Simple rules to expressionsOperatorsOperator PrecedenceCustom Functions
Algebra functionsArithmetic functionsBitwise functionsCombinatorics functions
Complex functionsGeometry functionsLogical functionsMatrix functions
Probability functionsRelational functionsSet functionsSpecial functions
Statistics functionsString functionsTrigonometry functionsUnit functions
Utils functionsEsoteric FunctionsConversions and ConstantsDonate



Introduction

Standard browser arithmetic operators are used to perform arithmetic between variables and/or values in our spreadsheet applications.

Given that y = 5, the table below explains the arithmetic operators:

Operator Description Example Result in y Result in x
+ Addition = y + 2 y = 5 x = 7
- Subtraction = y - 2 y = 5 x = 3
* Multiplication = y * 2 y = 5 x = 10
/ Division = y / 2 y = 5 x = 2.5
% Modulus (division remainder) = y % 2 y = 5 x = 1
** Exponent ( =5**2 Or $5^2 ) = y ** 2 y = 5 x = 25

Moving around the spreadsheet with your keyboard:

Move up one cell        Tab Move right one cell =

Move down one cell      Enter Or Return Move down one cell =


End Move cursor to end of line inside the cell

Home Move cursor to start of line inside the cell


Using the "Clear Cache" option

Image embedded and inserted by SSuite Office Fandango Desktop Editor

This feature deletes all the old data created by all the instances that were opened and used in previous sessions. It also deletes all the spreadsheets or tables that were auto-saved for each instance of every opened spreadsheet table. This feature is a typical garbage clearance function.



Opening a New Table Instance or Browser Tab

Image embedded and inserted by SSuite Office Fandango Desktop Editor

When using this feature, a whole new individual instance of the spreadsheet app, that you originally opened, is created in a new tab just like a desktop application. All your data or text is then auto-saved separately just as in the first web application. When closing each editor tab, your data or text is then auto-saved for later use or access as you need it.


Setting the Table Row Count

Image embedded and inserted by SSuite Office Fandango Desktop Editor

It is now possible to set the table row count if you want to create larger spreadsheets. The default size for each spreadsheet table instance is 50 rows by 26 columns. The more rows you add to your table, the slower the calculations will run. This is an unfortunate situation as the browser is single threaded and also the update algorithm for each cell takes a lot of processing.


Anything more than 1000 rows will start to limit and degrade your user experience, but if your computer's CPU is strong enough, you may add as many rows as your system can handle. Each spreadsheet table instance may have its own custom row count.


Saving your spreadsheet as a PDF document

Image embedded and inserted by SSuite Office Fandango Desktop Editor

It is now possible to save/export your spreadsheet as a PDF document. Just click on the "Print..." button at the top right of the application's toolbar, wait for your browser's print preview to open and select "Save as PDF" from the printer's selection list. You may also just print your spreadsheet if you wish to do so. Watch a short video demo.


Printing your spreadsheet

Image embedded and inserted by SSuite Office Fandango Desktop Editor

It is now possible to print your spreadsheet quick and easy. Just click on the "Print..." button at the top right of the application's toolbar, wait for your browser's print preview to open and set your printing preferences as needed. Please note that in order to print the cell background colours, you need to enable the "Background Graphics" printing option on Chromium based browsers, and "Print Backgrounds" in FireFox.


 
 

Special Notes

Please be aware that the "Math" prefix for functions are case sensitive when using standard browser math functions, otherwise lowercase letters may be used if you wish to use our own custom math functions.

They must be entered exactly as below:

Standard Browser Functions: Math.PI , Math.ceil(x), Math.SQRT2

Custom Spreadsheet Functions: math.pi, math.ceil(x), math.SQRT2


Our spreadsheet accepts either an "=" sign or a "$" sign when creating functions or equations.

  • When using the "=" sign for functions, cell references may be used and the [math] prefix must be used in front of functions. Cell references are not case sensitive e.g. [A1] or [a1] may be used in your functions.

    =1+2/(15-4)
    =a1+b3/(C5-D8) Or =a1+b3*(C5-D8)         //Implicit multiplication is not supported
    =math.derivative('x^2', 'x', {simplify: false})
    =math.det([[-2, 2, A3], [-1, B4, 3], [2, c1, -1] ])
    =Math.floor((Math.random() * 100) + 1)
    =math.sort(['Langdon','Tom','Sara'],function sortByLength(a, b) {return a.length - b.length})


    Cell references cannot be used inside strings!


  • When using the "$" sign for equations or functions, cell references can't be used, just the direct value e.g. $sqrt(3^2 + 4^2). Much more complex equations may be created when using the "$" and there is no the need for the [math] prefix.

    $1+2/(15-4)
    $1+2(15-4)                     //Implicit multiplication may be used
    $derivative('x^2', 'x', {simplify: false})
    $det([[-2, 2, 3],[-1, 1, 3],[2, 0, -1] ])
    $floor((random() * 100) + 1)
    $sort(["Langdon","Tom","Sara"], sortByLength(a, b) = size(a)[1] - size(b)[1])


 
 

As you may have already noticed, our spreadsheet also supports cell references:

A1:90 A2:180

e.g. =Math.sin(90 * Math.PI / 180) OR =Math.sin(a1 * Math.PI / A2)

The cell references are not case sensitive, either [A1] or [a1] may be used in your equations.


Take Note - When using "Google Fonts", the "$" prefix, and any math functions in your equations or functions, your spreadsheet will not be compatible with our desktop spreadsheet software e.g. SSuite Office Spreadsheets

Use only "System Fonts", the "=" sign, and simple arithmetic e.g. (=A1+B1-C1), if you wish to open, edit, or save your spreadsheets with our Desktop spreadsheet applications.

Google fonts, the "$" prefix, and all math functions, are not compatible with our desktop software.


 

To use more advanced methods, use the following notation for each function:

=Math.ceil(4.4)     // returns 5

=Math.floor(4.7)    // returns 4

=Math.sin(90 * Math.PI / 180)     // returns 1 (the sine of 90 degrees)

=Math.min(0, 150, 30, 20, -8, -200// returns -200

=Math.random()     // returns a random number

Example

Return a random number between 1 and 100:

=Math.floor((Math.random() * 100) + 1)

=Math.sqrt(16)      // Returns the square root of 16

 


 

Number Methods

Example 1
=(100 + 23).toString();   // returns 123 from expression 100 + 23

Example 2
=
9.656.toExponential(2)     // returns 9.66e+0
=
9.656.toExponential(4)     // returns 9.6560e+0
=
9.656.toExponential(6)     // returns 9.656000e+0

Example 3
=
9.656.toFixed(0)           // returns 10
=9.656.toFixed(2)           // returns 9.66
=9.656.toFixed(4)           // returns 9.6560
=9.656.toFixed(6)           // returns 9.656000

Example 4
=9.656.toPrecision()        // returns 9.656
=9.656.toPrecision(2)       // returns 9.7
=9.656.toPrecision(4)       // returns 9.656
=9.656.toPrecision(6)       // returns 9.65600

Example 5
=Boolean(10 > 9)        // returns true = 1
=(10 > 9)               // also returns true
=10 > 9                 // also returns true
=Boolean(A4 > E8      // will return either 1 or 0 / True=1 False=0



 

Standard Math Constants

Math.E        // returns Euler's number
Math.PI       // returns PI
Math.SQRT2    // returns the square root of 2
Math.SQRT1_2  // returns the square root of 1/2
Math.LN2      // returns the natural logarithm of 2
Math.LN10     // returns the natural logarithm of 10
Math.LOG2E    // returns base 2 logarithm of E
Math.LOG10E   // returns base 10 logarithm of E


Custom Math Constants

=math.constant | $constant >> e.g. =math.LN2 | $LN2

Constant Description Value
e, E Euler’s number, the base of the natural logarithm. 2.718281828459045
i Imaginary unit, defined as ii=-1. A complex number is described as a + bi, where a is the real part, and b is the imaginary part. sqrt(-1)
Infinity Infinity, a number which is larger than the maximum number that can be handled by a floating point number. Infinity
LN2 Returns the natural logarithm of 2. 0.6931471805599453
LN10 Returns the natural logarithm of 10. 2.302585092994046
LOG2E Returns the base-2 logarithm of E. 1.4426950408889634
LOG10E Returns the base-10 logarithm of E. 0.4342944819032518
NaN Not a number. NaN
null Value null. null
phi Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as (1 + sqrt(5)) / 2 1.618033988749895
pi, PI The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter. 3.141592653589793
SQRT1_2 Returns the square root of 1/2. 0.7071067811865476
SQRT2 Returns the square root of 2. 1.4142135623730951
tau Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi. 6.283185307179586
undefined An undefined value. Preferably, use null to indicate undefined values. undefined
version Returns the version number of math.js. that has been loaded For example 0.24.1



 

Math Functions =Math.method(x) | =math.method(x) | $method(x)


Method Description
abs(x) Returns the absolute value of x
acos(x) Returns the arccosine of x, in radians
asin(x) Returns the arcsine of x, in radians
atan(x) Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians
atan2(y, x) Returns the arctangent of the quotient of its arguments
ceil(x) Returns the value of x rounded up to its nearest integer
cos(x) Returns the cosine of x (x is in radians)
exp(x) Returns the value of Ex
floor(x) Returns the value of x rounded down to its nearest integer
log(x) Returns the natural logarithm (base E) of x
max(x,y,...,n) Returns the number with the highest value
min(x,y,...,n) Returns the number with the lowest value
pow(x, y) Returns the value of x to the power of y
random() Returns a random number between 0 and 1
round(x) Returns the value of x rounded to its nearest integer
sin(x) Returns the sine of x (x is in radians)
sqrt(x) Returns the square root of x
tan(x) Returns the tangent of an angle
trunc(x) Returns the integer part of a number (x)
cbrt(x) Returns the cubic root of a number (x)
tanh(x) Returns the hyperbolic tangent of a number x
cosh(x) Returns the hyperbolic cosine of a number x
atanh(x) Returns the hyperbolic arctangent of a specified number x
asinh(x) Returns the hyperbolic arcsine of a number x
acosh(x) Returns the hyperbolic arccosine of a number x

 
 

Bitwise Operators

Operator Name Description
& AND Sets each bit to 1 if both bits are 1
| OR Sets each bit to 1 if one of two bits is 1
^ XOR Sets each bit to 1 if only one of two bits is 1
~ NOT Inverts all the bits
<< Zero fill left shift Shifts left by pushing zeros in from the right and let the leftmost bits fall off
>> Signed right shift Shifts right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off
>>> Zero fill right shift Shifts right by pushing zeros in from the left, and let the rightmost bits fall off

 


 

Examples of Bitwise Operations

Operation Result Same as Result
= 5 & 1 1 0101 & 0001  0001
= 5 | 1 5 0101 | 0001  0101
= ~ 5 10 (4bit unsigned) / -6 (32bit signed)
 ~0101  1010
= 5 << 1 10 0101 << 1  1010
= 5 ^ 1 4 0101 ^ 0001  0100
= 5 >> 1 2 0101 >> 1  0010
= 5 >>> 1 2 0101 >>> 1  0010




Expressions

Our spreadsheet now contains a flexible and easy to use expression parser. The parser supports all data types, functions and constants.

The expression parser is aimed at end users: mathematicians, engineers, students, pupils. The syntax of the expression parser differs from JavaScript and the low-level math.js library.


When writing out an expression, it can be used in two ways:


In its Natural state: Any expression may be entered starting with a "$" sign...

Example 1

$evaluate('sqrt(3^2 + 4^2)')        // 5          Strings don't support cell references
=math.evaluate('sqrt(-4)')          // 2i         Strings don't support cell references

$sqrt(3^2 + 4^2)                    // 5          Doesn't support cell references
=math.sqrt(-4)                      // 2i         Supports cell references

$evaluate('2 inch to cm')           // 5.08 cm    Strings don't support cell references
=math.evaluate('90 km/h to m/s')    // 25m / s    Strings don't support cell references

$evaluate('cos(45 deg)')            // 0.707106   Strings don't support cell references
$evaluate('f(x, y) = x^y')          // f(x, y)    Strings don't support cell references


Algebra (symbolic computation)

$simplify('2x + 3x').toString()     // "5 * x"    Strings don't support cell references
$simplify('x^2 + x + 3 + x^2')      // 2*x^2+x+3  Strings don't support cell references
$simplify('2x + 3x').toString())    // "5 * x"    Strings don't support cell references
$simplify('x * y * -x / (x ^ 2)')   // '-y'       Strings don't support cell references

$derivative('2x^2 + 3x + 4', 'x')   // 4 * x + 3  Strings don't support cell references
$derivative('sin(2x)', 'x')         // 2*cos(2*x) Strings don't support cell references

$rationalize('2x/y - y/(x+1)')      // 2*x^2-y^2  Strings don't support cell references
$rationalize('x+x+x+y',{y:1})       // 3*x+1      Strings don't support cell references


Example 2

Using the standard "=" sign:

A1:3 A2:4

=math.sqrt(3^2 + 4^2)               // 5          supports cell references
=math.sqrt(A1^2 + A2^2)             // 5          supports cell references
=math.evaluate('cos(45 deg)')       // 0.707106   strings don't suppport cell references

Create a currency value:

=math.format(A2,function formatCurrency(value) {return '$'+value.toFixed(2)})
// $4.00 supports cell references

=math.subset([[1, 2], [3, a2]],math.index(0, 1)) // 2 supports cell references


  • Evaluate - Syntax describes how to write expressions

    math.evaluate(expr)                       =math.evaluate('(2+3)/4')
    math.evaluate(expr, scope)                =math.evaluate('a * b',{a:A1,b:A2})
    math.evaluate([expr1, expr2, ...])        =math.evaluate(['a=3', 'b=4', 'a*b'])
    math.evaluate([expr1, expr2, ...], scope) =math.evaluate(['a * b','b/c'],{a:3,b:A2,c:9})

    math.evaluate(expr)                        $evaluate('(2+3)/4')
    math.evaluate(expr, scope)                 $evaluate('a * b',{a:3,b:4})
    math.evaluate([expr1, expr2, ...])         $evaluate(['a=3', 'b=4', 'a*b'])
    math.evaluate([expr1, expr2, ...], scope)  $evaluate(['a * b','b/c'],{a:3,b:4,c:9})


    Just remember that string expressions don't support cell references!





Simple rules to expressions

Implicit multiplication

The behavior of implicit multiplication can be summarized by these operator precedence rules, listed from highest to lowest precedence:

  • Function calls: [symbol] [left paren]
  • Explicit division / when the division matches this pattern: [number] / [number] [symbol] or [number] / [number] [left paren]
  • Implicit multiplication
  • All other division / and multiplication *

Here are some more examples using implicit multiplication:

Expression in Cell Evaluated as Result
$(1 + 3) pi (1 + 3) * pi 12.566370614359172
$(4 - 1) 2 (4 - 1) * 2 6
$3 / 4 mm (3 / 4) * mm 0.75 mm
$2 + 3 i 2 + (3 * i) 2 + 3i
$(1 + 2) (4 - 2) (1 + 2) * (4 - 2) 6
$sqrt(4) (1 + 2) sqrt(4) * (1 + 2) 6
$8 pi / 2 pi (8 * pi) / (2 * pi) 4
$pi / 2 pi pi / (2 * pi) 0.5
$1 / 2i (1 / 2) * i 0.5 i
$8.314 J / mol K 8.314 J / (mol * K) 8.314 J / (mol * K)


The following operators are available with the "$" prefix:

Operator Name Syntax Associativity Example Result
(, ) Grouping (x) None 2 * (3 + 4) 14
[, ] Matrix, Index [...] None [[1,2],[3,4]] [[1,2],[3,4]]
{, } Object {...} None {a: 1, b: 2} {a: 1, b: 2}
, Parameter separator x, y Left to right max(2, 1, 5) 5
. Property accessor obj.prop Left to right obj={a: 12}; obj.a 12
; Statement separator x; y Left to right a=2; b=3; a*b [6]
; Row separator [x; y] Left to right [1,2;3,4] [[1,2],[3,4]]
\n Statement separator x \n y Left to right a=2 \n b=3 \n a*b [2,3,6]
+ Add x + y Left to right 4 + 5 9
+ Unary plus +y Right to left +4 4
- Subtract x - y Left to right 7 - 3 4
- Unary minus -y Right to left -4 -4
* Multiply x * y Left to right 2 * 3 6
.* Element-wise multiply x .* y Left to right [1,2,3] .* [1,2,3] [1,4,9]
/ Divide x / y Left to right 6 / 2 3
./ Element-wise divide x ./ y Left to right [9,6,4] ./ [3,2,2] [3,3,2]
%, mod Modulus x % y Left to right 8 % 3 2
^ Power x ^ y Right to left 2 ^ 3 8
.^ Element-wise power x .^ y Right to left [2,3] .^ [3,3] [8,27]
' Transpose y' Left to right [[1,2],[3,4]]' [[1,3],[2,4]]
! Factorial y! Left to right 5! 120
& Bitwise and x & y Left to right 5 & 3 1
~ Bitwise not ~x Right to left ~2 -3
| Bitwise or x | y Left to right 5 | 3 7
^| Bitwise xor x ^| y Left to right 5 ^| 2 7
<< Left shift x << y Left to right 4 << 1 8
>> Right arithmetic shift x >> y Left to right 8 >> 1 4
>>> Right logical shift x >>> y Left to right -8 >>> 1 2147483644
and Logical and x and y Left to right true and false false
not Logical not not y Right to left not true false
or Logical or x or y Left to right true or false true
xor Logical xor x xor y Left to right true xor true false
= Assignment x = y Right to left a = 5 5
? : Conditional expression x ? y : z Right to left 15 > 100 ? 1 : -1 -1
: Range x : y Right to left 1:4 [1,2,3,4]
to, in Unit conversion x to y Left to right 2 inch to cm 5.08 cm
== Equal x == y Left to right 2 == 4 - 2 true
!= Unequal x != y Left to right 2 != 3 true
< Smaller x < y Left to right 2 < 3 true
> Larger x > y Left to right 2 > 3 false
<= Smallereq x <= y Left to right 4 <= 3 false
>= Largereq x >= y Left to right 2 + 4 >= 6 true


Precedence

These operators have the following precedence, from highest to lowest when used with the "$" prefix:

Operators Description
(...)
[...]
{...}
Grouping
Matrix
Object
x(...)
x[...]
obj.prop
:
Function call
Matrix index
Property accessor
Key/value separator
' Matrix transpose
! Factorial
^, .^ Exponentiation
+, -, ~, not Unary plus, unary minus, bitwise not, logical not
See section below Implicit multiplication
*, /, .*, ./, %, mod Multiply, divide, modulus
+, - Add, subtract
: Range
to, in Unit conversion
<<, >>, >>> Bitwise left shift, bitwise right arithmetic shift, bitwise right logical shift
==, !=, <, >, <=, >= Relational
& Bitwise and
^| Bitwise xor
| Bitwise or
and Logical and
xor Logical xor
or Logical or
?, : Conditional expression
= Assignment
, Parameter and column separator
; Row separator
\n, ; Statement separators





Functions from our Custom Math unit...


=math.xgcd(36163, 21199)   // returns [1247, -7, 12]

$xgcd(36163, 21199)        // returns [1247, -7, 12]



Algebra functions #

Function Description
derivative(expr, variable) Takes the derivative of an expression expressed in parser Nodes.
math.lsolve(L, b) Finds one solution of a linear equation system by forwards substitution.
math.lsolve(L, b) Finds all solutions of a linear equation system by forwards substitution.
math.lup(A) Calculate the Matrix LU decomposition with partial pivoting.
math.lusolve(A, b) Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.
math.qr(A) Calculate the Matrix QR decomposition.
rationalize(expr) Transform a rationalizable expression in a rational fraction.
simplify(expr) Simplify an expression tree.
math.slu(A, order, threshold) Calculate the Sparse Matrix LU decomposition with full pivoting.
math.usolve(U, b) Finds one solution of a linear equation system by backward substitution.
math.usolve(U, b) Finds all solutions of a linear equation system by backward substitution.

Arithmetic functions #

Function Description
math.abs(x) Calculate the absolute value of a number.
math.add(x, y) Add two or more values, x + y.
math.cbrt(x [, allRoots]) Calculate the cubic root of a value.
math.ceil(x) Round a value towards plus infinity If x is complex, both real and imaginary part are rounded towards plus infinity.
math.cube(x) Compute the cube of a value, x * x * x.
math.divide(x, y) Divide two values, x / y.
math.dotDivide(x, y) Divide two matrices element wise.
math.dotMultiply(x, y) Multiply two matrices element wise.
math.dotPow(x, y) Calculates the power of x to y element wise.
math.exp(x) Calculate the exponent of a value.
math.expm1(x) Calculate the value of subtracting 1 from the exponential value.
math.fix(x) Round a value towards zero.
math.floor(x) Round a value towards minus infinity.
math.gcd(a, b) Calculate the greatest common divisor for two or more values or arrays.
math.hypot(a, b, …) Calculate the hypotenusa of a list with values.
math.lcm(a, b) Calculate the least common multiple for two or more values or arrays.
math.log(x [, base]) Calculate the logarithm of a value.
math.log10(x) Calculate the 10-base logarithm of a value.
math.log1p(x) Calculate the logarithm of a value+1.
math.log2(x) Calculate the 2-base of a value.
math.mod(x, y) Calculates the modulus, the remainder of an integer division.
math.multiply(x, y) Multiply two or more values, x * y.
math.norm(x [, p]) Calculate the norm of a number, vector or matrix.
math.nthRoot(a) Calculate the nth root of a value.
math.nthRoots(x) Calculate the nth roots of a value.
math.pow(x, y) Calculates the power of x to y, x ^ y.
math.round(x [, n]) Round a value towards the nearest integer.
math.sign(x) Compute the sign of a value.
math.sqrt(x) Calculate the square root of a value.
math.square(x) Compute the square of a value, x * x.
math.subtract(x, y) Subtract two values, x - y.
math.unaryMinus(x) Inverse the sign of a value, apply a unary minus operation.
math.unaryPlus(x) Unary plus operation.
math.xgcd(a, b) Calculate the extended greatest common divisor for two values.

Bitwise functions #

Function Description
math.bitAnd(x, y) Bitwise AND two values, x & y.
math.bitNot(x) Bitwise NOT value, ~x.
math.bitOr(x, y) Bitwise OR two values, x | y.
math.bitXor(x, y) Bitwise XOR two values, x ^ y.
math.leftShift(x, y) Bitwise left logical shift of a value x by y number of bits, x << y.
math.rightArithShift(x, y) Bitwise right arithmetic shift of a value x by y number of bits, x >> y.
math.rightLogShift(x, y) Bitwise right logical shift of value x by y number of bits, x >>> y.

Combinatorics functions #

Function Description
math.bellNumbers(n) The Bell Numbers count the number of partitions of a set.
math.catalan(n) The Catalan Numbers enumerate combinatorial structures of many different types.
math.composition(n, k) The composition counts of n into k parts.
math.stirlingS2(n, k) The Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets.

Complex functions #

Function Description
math.arg(x) Compute the argument of a complex value.
math.conj(x) Compute the complex conjugate of a complex value.
math.im(x) Get the imaginary part of a complex number.
math.re(x) Get the real part of a complex number.

Geometry functions #

Function Description
math.distance([x1, y1], [x2, y2]) Calculates: The eucledian distance between two points in N-dimensional spaces.
math.intersect(endPoint1Line1, endPoint2Line1, endPoint1Line2, endPoint2Line2) Calculates the point of intersection of two lines in two or three dimensions and of a line and a plane in three dimensions.

Logical functions #

Function Description
math.and(x, y) Logical and.
math.not(x) Logical not.
math.or(x, y) Logical or.
math.xor(x, y) Logical xor.

Matrix functions #

Function Description
math.apply(A, dim, callback) Apply a function that maps an array to a scalar along a given axis of a matrix or array.
math.column(value, index) Return a column from a Matrix.
math.concat(a, b, c, … [, dim]) Concatenate two or more matrices.
math.cross(x, y) Calculate the cross product for two vectors in three dimensional space.
math.ctranspose(x) Transpose and complex conjugate a matrix.
math.det(x) Calculate the determinant of a matrix.
math.diag(X) Create a diagonal matrix or retrieve the diagonal of a matrix When x is a vector, a matrix with vector x on the diagonal will be returned.
math.diff(arr) Create a new matrix or array of the difference between elements of the given array The optional dim parameter lets you specify the dimension to evaluate the difference of If no dimension parameter is passed it is assumed as dimension 0 Dimension is zero-based in javascript and one-based in the parser and can be a number or bignumber Arrays must be ‘rectangular’ meaning arrays like [1, 2] If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays.
math.dot(x, y) Calculate the dot product of two vectors.
math.eigs(x) Compute eigenvalue and eigenvector of a real symmetric matrix.
math.expm(x) Compute the matrix exponential, expm(A) = e^A.
math.filter(x, test) Filter the items in an array or one dimensional matrix.
math.flatten(x) Flatten a multi dimensional matrix into a single dimensional matrix.
math.forEach(x, callback) Iterate over all elements of a matrix/array, and executes the given callback function.
math.getMatrixDataType(x) Find the data type of all elements in a matrix or array, for example ‘number’ if all items are a number and ‘Complex’ if all values are complex numbers.
math.identity(n) Create a 2-dimensional identity matrix with size m x n or n x n.
math.inv(x) Calculate the inverse of a square matrix.
math.kron(x, y) Calculates the kronecker product of 2 matrices or vectors.
math.map(x, callback) Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.
math.ones(m, n, p, …) Create a matrix filled with ones.
math.partitionSelect(x, k) Partition-based selection of an array or 1D matrix.
math.range(start, end [, step]) Create an array from a range.
math.reshape(x, sizes) Reshape a multi dimensional array to fit the specified dimensions.
math.resize(x, size [, defaultValue]) Resize a matrix.
math.rotate(w, theta) Rotate a vector of size 1x2 counter-clockwise by a given angle Rotate a vector of size 1x3 counter-clockwise by a given angle around the given axis.
math.rotationMatrix(theta) Create a 2-dimensional counter-clockwise rotation matrix (2x2) for a given angle (expressed in radians).
math.row(value, index) Return a row from a Matrix.
math.size(x) Calculate the size of a matrix or scalar.
math.sort(x) Sort the items in a matrix.
X = math.sqrtm(A) Calculate the principal square root of a square matrix.
math.squeeze(x) Squeeze a matrix, remove inner and outer singleton dimensions from a matrix.
math.subset(x, index [, replacement]) Get or set a subset of a matrix or string.
math.trace(x) Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.
math.transpose(x) Transpose a matrix.
math.zeros(m, n, p, …) Create a matrix filled with zeros.

Probability functions #

Function Description
math.combinations(n, k) Compute the number of ways of picking k unordered outcomes from n possibilities.
math.combinationsWithRep(n, k) Compute the number of ways of picking k unordered outcomes from n possibilities, allowing individual outcomes to be repeated more than once.
math.factorial(n) Compute the factorial of a value Factorial only supports an integer value as argument.
math.gamma(n) Compute the gamma function of a value using Lanczos approximation for small values, and an extended Stirling approximation for large values.
math.kldivergence(x, y) Calculate the Kullback-Leibler (KL) divergence between two distributions.
math.multinomial(a) Multinomial Coefficients compute the number of ways of picking a1, a2, .
math.permutations(n [, k]) Compute the number of ways of obtaining an ordered subset of k elements from a set of n elements.
math.pickRandom(array) Random pick one or more values from a one dimensional array.
math.random([min, max]) Return a random number larger or equal to min and smaller than max using a uniform distribution.
math.randomInt([min, max]) Return a random integer number larger or equal to min and smaller than max using a uniform distribution.

Relational functions #

Function Description
math.compare(x, y) Compare two values.
math.compareNatural(x, y) Compare two values of any type in a deterministic, natural way.
math.compareText(x, y) Compare two strings lexically.
math.deepEqual(x, y) Test element wise whether two matrices are equal.
math.equal(x, y) Test whether two values are equal.
math.equalText(x, y) Check equality of two strings.
math.larger(x, y) Test whether value x is larger than y.
math.largerEq(x, y) Test whether value x is larger or equal to y.
math.smaller(x, y) Test whether value x is smaller than y.
math.smallerEq(x, y) Test whether value x is smaller or equal to y.
math.unequal(x, y) Test whether two values are unequal.

Set functions #

Function Description
math.setCartesian(set1, set2) Create the cartesian product of two (multi)sets.
math.setDifference(set1, set2) Create the difference of two (multi)sets: every element of set1, that is not the element of set2.
math.setDistinct(set) Collect the distinct elements of a multiset.
math.setIntersect(set1, set2) Create the intersection of two (multi)sets.
math.setIsSubset(set1, set2) Check whether a (multi)set is a subset of another (multi)set.
math.setMultiplicity(element, set) Count the multiplicity of an element in a multiset.
math.setPowerset(set) Create the powerset of a (multi)set.
math.setSize(set) Count the number of elements of a (multi)set.
math.setSymDifference(set1, set2) Create the symmetric difference of two (multi)sets.
math.setUnion(set1, set2) Create the union of two (multi)sets.

Special functions #

Function Description
math.erf(x) Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x.

Statistics functions #

Function Description
math.mad(a, b, c, …) Compute the median absolute deviation of a matrix or a list with values.
math.max(a, b, c, …) Compute the maximum value of a matrix or a list with values.
math.mean(a, b, c, …) Compute the mean value of matrix or a list with values.
math.median(a, b, c, …) Compute the median of a matrix or a list with values.
math.min(a, b, c, …) Compute the minimum value of a matrix or a list of values.
math.mode(a, b, c, …) Computes the mode of a set of numbers or a list with values(numbers or characters).
math.prod(a, b, c, …) Compute the product of a matrix or a list with values.
math.quantileSeq(A, prob[, sorted]) Compute the prob order quantile of a matrix or a list with values.
math.std(a, b, c, …) Compute the standard deviation of a matrix or a list with values.
math.sum(a, b, c, …) Compute the sum of a matrix or a list with values.
math.variance(a, b, c, …) Compute the variance of a matrix or a list with values.

String functions #

Function Description
math.bin(value) Format a number as binary.
math.format(value [, precision]) Format a value of any type into a string.
math.hex(value) Format a number as hexadecimal.
math.oct(value) Format a number as octal.
math.print(template, values [, precision]) Interpolate values into a string template.

Trigonometry functions #

Function Description
math.acos(x) Calculate the inverse cosine of a value.
math.acosh(x) Calculate the hyperbolic arccos of a value, defined as acosh(x) = ln(sqrt(x^2 - 1) + x).
math.acot(x) Calculate the inverse cotangent of a value, defined as acot(x) = atan(1/x).
math.acoth(x) Calculate the hyperbolic arccotangent of a value, defined as acoth(x) = atanh(1/x) = (ln((x+1)/x) + ln(x/(x-1))) / 2.
math.acsc(x) Calculate the inverse cosecant of a value, defined as acsc(x) = asin(1/x).
math.acsch(x) Calculate the hyperbolic arccosecant of a value, defined as acsch(x) = asinh(1/x) = ln(1/x + sqrt(1/x^2 + 1)).
math.asec(x) Calculate the inverse secant of a value.
math.asech(x) Calculate the hyperbolic arcsecant of a value, defined as asech(x) = acosh(1/x) = ln(sqrt(1/x^2 - 1) + 1/x).
math.asin(x) Calculate the inverse sine of a value.
math.asinh(x) Calculate the hyperbolic arcsine of a value, defined as asinh(x) = ln(x + sqrt(x^2 + 1)).
math.atan(x) Calculate the inverse tangent of a value.
math.atan2(y, x) Calculate the inverse tangent function with two arguments, y/x.
math.atanh(x) Calculate the hyperbolic arctangent of a value, defined as atanh(x) = ln((1 + x)/(1 - x)) / 2.
math.cos(x) Calculate the cosine of a value.
math.cosh(x) Calculate the hyperbolic cosine of a value, defined as cosh(x) = 1/2 * (exp(x) + exp(-x)).
math.cot(x) Calculate the cotangent of a value.
math.coth(x) Calculate the hyperbolic cotangent of a value, defined as coth(x) = 1 / tanh(x).
math.csc(x) Calculate the cosecant of a value, defined as csc(x) = 1/sin(x).
math.csch(x) Calculate the hyperbolic cosecant of a value, defined as csch(x) = 1 / sinh(x).
math.sec(x) Calculate the secant of a value, defined as sec(x) = 1/cos(x).
math.sech(x) Calculate the hyperbolic secant of a value, defined as sech(x) = 1 / cosh(x).
math.sin(x) Calculate the sine of a value.
math.sinh(x) Calculate the hyperbolic sine of a value, defined as sinh(x) = 1/2 * (exp(x) - exp(-x)).
math.tan(x) Calculate the tangent of a value.
math.tanh(x) Calculate the hyperbolic tangent of a value, defined as tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1).

Unit functions #

Function Description
math.to(x, unit) Change the unit of a value.

Utils functions #

Function Description
math.clone(x) Clone an object.
math.hasNumericValue(x) Test whether a value is an numeric value.
math.isInteger(x) Test whether a value is an integer number.
math.isNaN(x) Test whether a value is NaN (not a number).
math.isNegative(x) Test whether a value is negative: smaller than zero.
math.isNumeric(x) Test whether a value is an numeric value.
math.isPositive(x) Test whether a value is positive: larger than zero.
math.isPrime(x) Test whether a value is prime: has no divisors other than itself and one.
math.isZero(x) Test whether a value is zero.
math.numeric(x) Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.
math.typeOf(x) Determine the type of a variable.




 

Quick Conversions

Some examples of unit conversions: (units must be in lowercase)

  • $26 fahrenheit to celsius            // Returns -3.3333 celcius
  • $18 mile to km                       // Returns 28.968 km / kilometer
  • $25 ounce to gram                    // Returns 708.74 gram
  • $25 ounce to gram to kg              // Returns 0.70874 kg / kilogram
  • $88 inch to cm                       // Returns 223.52 cm / centimeter
  • $88 inch to m                        // Returns 2.2352 m / meter
  • $8 fluidounce to milliliter          // Returns 236,59 milliliter / ml
  • $18 poundmass to kg                  // Returns 8.1647 kg / kilogram

foot, link, angstrom, ft, mil, sqft, sqrd, acre, hectare, mile, inch, chain, sqin, sqmi, litre, milliliter, cuin, cuyd, gill, pint, gallon, oilbarrel,floz, pt, tonne, poundforce, grain, gram, ounce, fluidounce, hundredweight, min, sec, hour, day, year, millennium, hertz, deg, gradian, arcmin, celsius, fahrenheit, kelvin, candela, cd, mole, newton, joule, kip, BTU, eV, electronvolt, psi, Pa, bar, atm, torr, cmH2O, mmhg, mmh2o farad, V, ohm, henry, siemens, tesla, weber, bits, bytes, meters, coulomb, ampere, volt . . .


Complete List of Units

meters:"meter" inches:"inch" feet:"foot" yards:"yard" miles:"mile" links:"link" rods:"rod" chains:"chain" angstroms:"angstrom" lt:"l" litres:"litre" liter:"litre" liters:"litre" teaspoons:"teaspoon" tablespoons:"tablespoon" minims:"minim" fluiddrams:"fluiddram" fluidounces:"fluidounce" gills:"gill" cups:"cup" pints:"pint" quarts:"quart" gallons:"gallon" beerbarrels:"beerbarrel" oilbarrels:"oilbarrel" hogsheads:"hogshead" gtts:"gtt" grams:"gram" tons:"ton" tonnes:"tonne" grains:"grain" drams:"dram" ounces:"ounce" poundmasses:"poundmass" hundredweights:"hundredweight" sticks:"stick" lb:"lbm" lbs:"lbm" kips:"kip" kgf:"kilogramforce" acres:"acre" hectares:"hectare" sqfeet:"sqft" sqyard:"sqyd" sqmile:"sqmi" sqmiles:"sqmi" mmhg:"mmHg" mmh2o:"mmH2O" cmh2o:"cmH2O" seconds:"second" secs:"second" minutes:"minute" mins:"minute" hours:"hour" hr:"hour" hrs:"hour" days:"day" weeks:"week" months:"month" years:"year" decades:"decade" centuries:"century" millennia:"millennium" hertz:"hertz" radians:"radian" degrees:"degree" gradians:"gradian" cycles:"cycle" arcsecond:"arcsec" arcseconds:"arcsec" arcminute:"arcmin" arcminutes:"arcmin" BTUs:"BTU" watts:"watt" joules:"joule" amperes:"ampere" coulombs:"coulomb" volts:"volt" ohms:"ohm" farads:"farad" webers:"weber" teslas:"tesla" electronvolts:"electronvolt" moles:"mole" bit:"bits" byte:"bytes"



Universal Constants e.g. $speedOfLight >> 2.9979e+8 m/s

  • gravitationConstant
  • planckConstant
  • reducedPlanckConstant
  • magneticConstant
  • electricConstant
  • vacuumImpedance
  • coulomb
  • elementaryCharge
  • bohrMagneton
  • conductanceQuantum
  • inverseConductanceQuantum
  • magneticFluxQuantum
  • nuclearMagneton
  • klitzing
  • bohrRadius
  • classicalElectronRadius
  • electronMass
  • fermiCoupling
  • fineStructure
  • hartreeEnergy
  • protonMass
  • deuteronMass
  • neutronMass
  • quantumOfCirculation
  • rydberg
  • thomsonCrossSection
  • weakMixingAngle
  • efimovFactor
  • atomicMass
  • avogadro
  • boltzmann
  • faraday
  • firstRadiation
  • loschmidt
  • gasConstant
  • molarPlanckConstant
  • molarVolume
  • sackurTetrode
  • secondRadiation
  • stefanBoltzmann
  • wienDisplacement
  • molarMass
  • molarMassC12
  • gravity
  • planckLength
  • planckMass
  • planckTime
  • planckCharge
  • planckTemperature
  • speedOfLight









 

Esoteric Functions       Works only with the "=" sign prefix

numbers.generate.fibonacci(n)

Calculates the nth Fibonacci number.
Parameters
n:Int | Desired Fibonacci number to calculate.

Returns num:Int The nth Fibonacci number.

numbers.random.bates(n, b, a)

Generates a random number according to a Bates distribution inside the interval [a,b]. Both arguments are optional.

Parameters
n : Int Number of times to sum.
b : Number, optional Right endpoint of interval.Default value is 1.
a : Number, optional Left endpoint of the interal. Default value is 0.

Returns num : Number Random number according to a Bates distribution on [a,b].

numbers.random.irwinHall(n, sub)

Generates a random number according to an Irwin-Hall distribution, given a maximum sum, n, and a number to subtract, sub.

Parameters
n : Number Maximum sum.
sub : Number Number to subtract.

Returns num : Number Random number according to an Irwin-Hall distribution.

numbers.prime.coprime(a, b)

Determine if two integers are coprime.

Parameters
a : Int First integer.
b : Int Second integer

Returns bool : Boolean true if a, b are coprime, false otherwise.

numbers.prime.millerRabin(n, k)

Determines if an integer, n, is prime in polynomial time using the Miller-Rabin primality test, with an accuracy rate (number of trials) k.

Parameters
n : Int The number to test for primality.
k : Int The accuracy rate.

Returns bool : Boolean true if n is prime, false otherwise.

numbers.prime.simple(n)

Determines if an integer, n, is prime using brute force.

Parameters
n : Int The number to test for primality.
Returns bool : Boolean true if n is prime, false otherwise.

numbers.calculus.LanczosGamma(n)

Lanczos' approximation to the gamma function of a number, n.

Parameters
n : Number A number

Returns num : Number Gamma of n.

numbers.calculus.StirlingGamma(n)

Striling's approximation to the gamma function of a number, n.

Parameters
n : Number A number.
Returns num : Number Gamma of n.

numbers.basic.binomial(n, k)

Calculates the binomial coefficient of n,k (n choose k).

Parameters
n : Int Number of available choices.
k : Int Number of choices selected.

Returns num : Int The number of combinations of choices, n choose k.

numbers.basic.factorial(n)

Calculates the factorial of a positive integer, n.

Parameters
n : Int A positive integer.
Returns num : Int Factorial of n

numbers.basic.fallingFactorial(n, k)

Calculates the falling factorial of a positive integer n with k steps: n!/(n-k)!

Parameters
n : Int A positive integer.
k : Int The number of steps to fall.

Returns r : Int Falling factorial of n with k steps. If k > n then 0 is returned.

numbers.basic.gcd(a, b)

Calculates the greatest common divisor (gcd) amongst two integers.

Parameters
a : Int First integer.
b : Int Second integer.

Returns num : Int The gcd of a,b. If a or b are Infinity or -Infinity, then Infinity is returned. If a or b are not numbers, then NaN is returned.

numbers.basic.lcm(a, b)

Calculates the lowest common multiple (lcm) amongst two integers.

Parameters
a : Int First integer.
b : Int Second integer.

Returns num : Int The lcm of a,b. If a or b are Infinity or -Infinity, then 0 is returned. If a or b are not numbers, then NaN is returned.

numbers.basic.modInverse(a, m)

Calculates the modular multiplicative inverse x of an integer a and modulus m, ax = 1 (mod m).

Parameters
a : Int An integer.
m : Int Modulus.

Returns x : Int An integer such that ax = 1 (mod m).

numbers.basic.numbersEqual(a, b, epsilon)

Determines if two numbers, a,b, are equal within a given margin of precision, epsilon.

Parameters
a : Number First number.
b : Number Second number.
epsilon : Number Precision.

Returns bool : Boolean

numbers.basic.permutation(n, k)

Calculate the permutation (n choose k)

Parameters
n : Int Number of total elements
k : Int Fixed number of elements

Returns num : Number Number of ordered variations

Errors: An error is thrown if:
n cannot be less than or equal to 0.
k cannot be greater than n.

numbers.basic.subtraction(arr)

Calculates the differences of elements of an array, using the first element as the starting point.

Parameters
arr : Array An array of numbers.
Returns num : Number The difference of the elements of arr.

Errors
An error is thrown if:
not all elements of arr are numbers
arr is not an array

numbers.basic.sum(arr)

Calculates the sum of the elements of an array.

Parameters
arr : Array An array of numbers.
Returns num : Number The sum of the elements of arr.

Errors
An error is thrown if:
not all elements of arr are numbers
arr is not an array



Be Nice and Click Here to Donate!




Donate and help support our efforts in providing you with free office software...