Math.js Functions
All Math.js functions supported
Arithmetic functions
Function
What it does
Calculate the absolute value of a number
Add two or more values, x + y
Calculates the cubic root of a value
Round a value towards plus infinity If x is complex, both real and imaginary parts are rounded towards plus infinity
Compute the cube of a value, x * x * x
Divide two values, x / y
Calculates the power of x to y element-wise
Calculate the exponent of a value
Calculate the value of subtracting 1 from the exponential value
Round a value towards zero
Round a value towards minus infinity
Calculate the greatest common divisor for two or more values or arrays
Calculate the hypotenusa of a list with values
Calculate the least common multiple for two or more values or arrays
Calculate the logarithm of a value
Calculate the 10-base logarithm of a value
Calculate the logarithm of a value+1
Calculate the 2-base of a value
Calculates the modulus, the remainder of an integer division
Multiply two or more values, x * y
Calculate the norm of a number, vector or matrix
Calculate the nth root of a value
Calculate the nth roots of a value
Calculates the power of x to y, x ^ y
Round a value towards the nearest integer
Compute the sign of a value
Calculate the square root of a value
Compute the square of a value, x * x
Subtract two values, x - y
Inverse the sign of a value, apply a unary minus operation
Unary plus operation
Calculate the extended greatest common divisor for two values
Bitwise Functions
Functions
What it does
Bitwise AND two values, x & y
Bitwise NOT value, ~x
Bitwise OR two values, x | y
Bitwise XOR two values, x ^ y
Bitwise left logical shift of a value x by y number of bits, x << y
Bitwise right arithmetic shift of a value x by y number of bits, x >> y
Bitwise right logical shift of value x by y number of bits, x >>> y
Logical Functions
Function
What it does
Logical and
Logical not
Logical or
Logical xor
Matrix Functions
Function
What it does
Calculate the size of a matrix or scalar
Sort the items in a matrix
Probability Functions
Function
What it does
Compute the factorial of a value Factorial only supports an integer value as argument
Compute the gamma function of a value using Lanczos approximation for small values, and an extended Stirling approximation for large values
Random pick one or more values from a one dimensional array
Return a random number larger or equal to min and smaller than max using a uniform distribution
Return a random integer number larger or equal to min and smaller than max using a uniform distribution
Relational Functions
Function
Whate it does
Compare two values
Compare two values of any type in a deterministic, natural way
Test whether two values are equal
Test whether value x is larger than y
Test whether value x is larger or equal to y
Test whether value x is smaller than y
Test whether value x is smaller or equal to y
Test whether two values are unequal
Statistics Functions
Function
What it does
Compute the median absolute deviation of a matrix or a list with values
Compute the maximum value of a matrix or a list with values
Compute the mean value of matrix or a list with values
Compute the median of a matrix or a list with values
Compute the minimum value of a matrix or a list of values
Computes the mode of a set of numbers or a list with values(numbers or characters)
Compute the product of a matrix or a list with values
Compute the standard deviation of a matrix or a list with values
Compute the sum of a matrix or a list with values
Compute the variance of a matrix or a list with values
Trigonometry Functions
Function
What it does
Calculate the inverse cosine of a value
Calculate the hyperbolic arccos of a value, defined as acosh(x) = ln(sqrt(x^2 - 1) + x)
Calculate the inverse cotangent of a value, defined as acot(x) = atan(1/x)
Calculate the hyperbolic arccotangent of a value, defined as acoth(x) = atanh(1/x) = (ln((x+1)/x) + ln(x/(x-1))) / 2
Calculate the inverse cosecant of a value, defined as acsc(x) = asin(1/x)
Calculate the hyperbolic arccosecant of a value, defined as acsch(x) = asinh(1/x) = ln(1/x + sqrt(1/x^2 + 1))
Calculate the inverse secant of a value
Calculate the hyperbolic arcsecant of a value, defined as asech(x) = acosh(1/x) = ln(sqrt(1/x^2 - 1) + 1/x)
Calculate the inverse sine of a value
Calculate the hyperbolic arcsine of a value, defined as asinh(x) = ln(x + sqrt(x^2 + 1))
Calculate the inverse tangent of a value
Calculate the inverse tangent function with two arguments, y/x
Calculate the hyperbolic arctangent of a value, defined as atanh(x) = ln((1 + x)/(1 - x)) / 2
Calculate the cosine of a value
Calculate the hyperbolic cosine of a value, defined as cosh(x) = 1/2 * (exp(x) + exp(-x))
Calculate the cotangent of a value
Calculate the hyperbolic cotangent of a value, defined as coth(x) = 1 / tanh(x)
Calculate the cosecant of a value, defined as csc(x) = 1/sin(x)
Calculate the hyperbolic cosecant of a value, defined as csch(x) = 1 / sinh(x)
Calculate the secant of a value, defined as sec(x) = 1/cos(x)
Calculate the hyperbolic secant of a value, defined as sech(x) = 1 / cosh(x)
Calculate the sine of a value
Calculate the hyperbolic sine of a value, defined as sinh(x) = 1/2 * (exp(x) - exp(-x))
Calculate the tangent of a value
Calculate the hyperbolic tangent of a value, defined as tanh(x)=(exp(2 * x) - 1)/(exp(2 * x)+1)
Utils Functions
Function
What it does
Test whether a value is a numeric value
Test whether a value is an integer number
Test whether a value is NaN (not a number)
Test whether a value is negative: smaller than zero
Test whether a value is an numeric value
Test whether a value is positive: larger than zero
Test whether a value is prime: has no divisors other than itself and one
Test whether a value is zero
Last updated