Function references - bornova/numara-calculator GitHub Wiki
Algebra
derivative
Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.
Syntax: derivative(expr, variable) derivative(expr, variable, {simplify: boolean})
derivative("2x^3", "x")
derivative("2x^3", "x", {simplify: false})
derivative("2x^2 + 3x + 4", "x")
derivative("sin(2x)", "x")
f = parse("x^2 + x")
x = parse("x")
df = derivative(f, x)
df.evaluate({x: 3})
Also see: simplify, parse, evaluate
leafCount
Computes the number of leaves in the parse tree of the given expression
Syntax: leafCount(expr)
leafCount("e^(i*pi)-1")
leafCount(parse("{a: 22/7, b: 10^(1/2)}"))
Also see: simplify
lsolve
Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.
Syntax: x=lsolve(L, b)
a = [-2, 3; 2, 1]
b = [11, 9]
x = lsolve(a, b)
Also see: lsolveAll, lup, lusolve, usolve, matrix, sparse
lsolveAll
Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.
Syntax: x=lsolveAll(L, b)
a = [-2, 3; 2, 1]
b = [11, 9]
x = lsolve(a, b)
Also see: lsolve, lup, lusolve, usolve, matrix, sparse
lup
Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U
Syntax: lup(m)
lup([2, 1], [1, 4](/bornova/numara-calculator/wiki/2,-1],-[1,-4))
lup(matrix([2, 1], [1, 4](/bornova/numara-calculator/wiki/2,-1],-[1,-4)))
lup(sparse([2, 1], [1, 4](/bornova/numara-calculator/wiki/2,-1],-[1,-4)))
Also see: lusolve, lsolve, usolve, matrix, sparse, slu, qr
lusolve
Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.
Syntax: x=lusolve(A, b) x=lusolve(lu, b)
a = [-2, 3; 2, 1]
b = [11, 9]
x = lusolve(a, b)
Also see: lup, slu, lsolve, usolve, matrix, sparse
lyap
Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P
Syntax: lyap(A,Q)
lyap([-2, 0], [1, -4](/bornova/numara-calculator/wiki/-2,-0],-[1,--4), [3, 1], [1, 3](/bornova/numara-calculator/wiki/3,-1],-[1,-3))
A = [-2, 0], [1, -4](/bornova/numara-calculator/wiki/-2,-0],-[1,--4)
Q = [3, 1], [1, 3](/bornova/numara-calculator/wiki/3,-1],-[1,-3)
lyap(A,Q)
polynomialRoot
Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.
Syntax: x=polynomialRoot(-6, 3) x=polynomialRoot(4, -4, 1) x=polynomialRoot(-8, 12, -6, 1)
a = polynomialRoot(-6, 11, -6, 1)
qr
Calculates the Matrix QR decomposition. Matrix A is decomposed in two matrices (Q, R) where Q is an orthogonal matrix and R is an upper triangular matrix.
Syntax: qr(A)
qr([1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0](/bornova/numara-calculator/wiki/1,--1,--4],-[1,--4,--2],-[1,--4,--2],-[1,---1,-0))
rationalize
Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.
Syntax: rationalize(expr) rationalize(expr, scope) rationalize(expr, scope, detailed)
rationalize("2x/y - y/(x+1)")
rationalize("2x/y - y/(x+1)", true)
Also see: simplify
resolve
Recursively substitute variables in an expression tree.
Syntax: resolve(node, scope)
resolve(parse("1 + x"), { x: 7 })
resolve(parse("size(text)"), { text: "Hello World" })
resolve(parse("x + y"), { x: parse("3z") })
resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })
schur
Performs a real Schur decomposition of the real matrix A = UTU'
Syntax: schur(A)
schur([1, 0], [-4, 3](/bornova/numara-calculator/wiki/1,-0],-[-4,-3))
A = [1, 0], [-4, 3](/bornova/numara-calculator/wiki/1,-0],-[-4,-3)
schur(A)
simplify
Simplify an expression tree.
Syntax: simplify(expr) simplify(expr, rules)
simplify("3 + 2 / 4")
simplify("2x + x")
f = parse("x * (x + 2 + x)")
simplified = simplify(f)
simplified.evaluate({x: 2})
Also see: simplifyCore, derivative, evaluate, parse, rationalize, resolve
simplifyConstant
Replace constant subexpressions of node with their values.
Syntax: simplifyConstant(expr) simplifyConstant(expr, options)
simplifyConstant("(3-3)*x")
simplifyConstant(parse("z-cos(tau/8)"))
Also see: simplify, simplifyCore, evaluate
simplifyCore
Perform simple one-pass simplifications on an expression tree.
Syntax: simplifyCore(node)
simplifyCore(parse("0*x"))
simplifyCore(parse("(x+0)*2"))
Also see: simplify, simplifyConstant, evaluate
slu
Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U
Syntax: slu(A, order, threshold)
slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)
Also see: lusolve, lsolve, usolve, matrix, sparse, lup, qr
sylvester
Solves the real-valued Sylvester equation AX+XB=C for X
Syntax: sylvester(A,B,C)
sylvester([-1, -2], [1, 1](/bornova/numara-calculator/wiki/-1,--2],-[1,-1), [-2, 1], [-1, 2](/bornova/numara-calculator/wiki/-2,-1],-[-1,-2), [-3, 2], [3, 0](/bornova/numara-calculator/wiki/-3,-2],-[3,-0))
A = [-1, -2], [1, 1](/bornova/numara-calculator/wiki/-1,--2],-[1,-1); B = [2, -1], [1, -2](/bornova/numara-calculator/wiki/2,--1],-[1,--2); C = [-3, 2], [3, 0](/bornova/numara-calculator/wiki/-3,-2],-[3,-0)
sylvester(A, B, C)
symbolicEqual
Returns true if the difference of the expressions simplifies to 0
Syntax: symbolicEqual(expr1, expr2) symbolicEqual(expr1, expr2, options)
symbolicEqual("x*y","y*x")
symbolicEqual("abs(x^2)", "x^2")
symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})
usolve
Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.
Syntax: x=usolve(U, b)
x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])
Also see: usolveAll, lup, lusolve, lsolve, matrix, sparse
usolveAll
Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.
Syntax: x=usolve(U, b)
x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])
Also see: usolve, lup, lusolve, lsolve, matrix, sparse
Arithmetic
abs
Compute the absolute value.
Syntax: abs(x)
abs(3.5)
abs(-4.2)
Also see: sign
cbrt
Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When x is a number or complex number, an optional second argument allRoots can be provided to return all three cubic roots. If not provided, the principal root is returned
Syntax: cbrt(x) cbrt(x, allRoots)
cbrt(64)
cube(4)
cbrt(-8)
cbrt(2 + 3i)
cbrt(8i)
cbrt(8i, true)
cbrt(27 m^3)
Also see: square, sqrt, cube, multiply
ceil
Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.
Syntax: ceil(x) ceil(x, n) ceil(unit, valuelessUnit) ceil(unit, n, valuelessUnit)
ceil(3.2)
ceil(3.8)
ceil(-4.2)
ceil(3.241cm, cm)
ceil(3.241cm, 2, cm)
cube
Compute the cube of a value. The cube of x is x * x * x.
Syntax: cube(x)
cube(2)
2^3
2 * 2 * 2
Also see: multiply, square, pow
exp
Calculate the exponent of a value.
Syntax: exp(x)
exp(1.3)
e ^ 1.3
log(exp(1.3))
x = 2.4
(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula
Also see: expm, expm1, pow, log
expm
Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.
Syntax: exp(x)
expm([0,2],[0,0](/bornova/numara-calculator/wiki/0,2],[0,0))
Also see: exp
expm1
Calculate the value of subtracting 1 from the exponential value.
Syntax: expm1(x)
expm1(2)
pow(e, 2) - 1
log(expm1(2) + 1)
fix
Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.
Syntax: fix(x) fix(x, n) fix(unit, valuelessUnit) fix(unit, n, valuelessUnit)
fix(3.2)
fix(3.8)
fix(-4.2)
fix(-4.8)
fix(3.241cm, cm)
fix(3.241cm, 2, cm)
floor
Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.
Syntax: floor(x) floor(x, n) floor(unit, valuelessUnit) floor(unit, n, valuelessUnit)
floor(3.2)
floor(3.8)
floor(-4.2)
floor(3.241cm, cm)
floor(3.241cm, 2, cm)
gcd
Compute the greatest common divisor.
Syntax: gcd(a, b) gcd(a, b, c, ...)
gcd(8, 12)
gcd(-4, 6)
gcd(25, 15, -10)
hypot
Calculate the hypotenuse of a list with values.
Syntax: hypot(a, b, c, ...) hypot([a, b, c, ...])
hypot(3, 4)
sqrt(3^2 + 4^2)
hypot(-2)
hypot([3, 4, 5])
invmod
Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)
Syntax: invmod(a, b)
invmod(8, 12)
invmod(7, 13)
invmod(15151, 15122)
lcm
Compute the least common multiple.
Syntax: lcm(x, y)
lcm(4, 6)
lcm(6, 21)
lcm(6, 21, 5)
Also see: gcd
log
Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).
Syntax: log(x) log(x, base)
log(3.5)
a = log(2.4)
exp(a)
10 ^ 4
log(10000, 10)
log(10000) / log(10)
b = log(1024, 2)
2 ^ b
Also see: exp, log1p, log2, log10
log10
Compute the 10-base logarithm of a value.
Syntax: log10(x)
log10(0.00001)
log10(10000)
10 ^ 4
log(10000) / log(10)
log(10000, 10)
log1p
Calculate the logarithm of a value+1
Syntax: log1p(x) log1p(x, base)
log1p(2.5)
exp(log1p(1.4))
pow(10, 4)
log1p(9999, 10)
log1p(9999) / log(10)
Also see: exp, log, log2, log10
log2
Calculate the 2-base of a value. This is the same as calculating log(x, 2).
Syntax: log2(x)
log2(0.03125)
log2(16)
log2(16) / log2(2)
pow(2, 4)
Also see: exp, log1p, log, log10
norm
Calculate the norm of a number, vector or matrix.
Syntax: norm(x) norm(x, p)
abs(-3.5)
norm(-3.5)
norm(3 - 4i)
norm([1, 2, -3], Infinity)
norm([1, 2, -3], -Infinity)
norm([3, 4], 2)
norm([1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4), 1)
norm([1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4), "inf")
norm([1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4), "fro")
nthRoot
Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".
Syntax: nthRoot(a) nthRoot(a, root)
4 ^ 3
nthRoot(64, 3)
nthRoot(9, 2)
sqrt(9)
nthRoots
Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.
Syntax: nthRoots(A) nthRoots(A, root)
nthRoots(1)
nthRoots(1, 3)
round
round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.
Syntax: round(x) round(x, n) round(unit, valuelessUnit) round(unit, n, valuelessUnit)
round(3.2)
round(3.8)
round(-4.2)
round(-4.8)
round(pi, 3)
round(123.45678, 2)
round(3.241cm, 2, cm)
round([3.2, 3.8, -4.7])
sign
Compute the sign of a value. The sign of a value x is 1 when x>0, -1 when x<0, and 0 when x=0.
Syntax: sign(x)
sign(3.5)
sign(-4.2)
sign(0)
Also see: abs
sqrt
Compute the square root value. If x = y * y, then y is the square root of x.
Syntax: sqrt(x)
sqrt(25)
5 * 5
sqrt(-1)
Also see: square, sqrtm, multiply, nthRoot, nthRoots, pow
sqrtm
Calculate the principal square root of a square matrix. The principal square root matrix X of another matrix A is such that X * X = A.
Syntax: sqrtm(x)
sqrtm([33, 24], [48, 57](/bornova/numara-calculator/wiki/33,-24],-[48,-57))
Also see: sqrt, abs, square, multiply
square
Compute the square of a value. The square of x is x * x.
Syntax: square(x)
square(3)
sqrt(9)
3^2
3 * 3
Also see: multiply, pow, sqrt, cube
xgcd
Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.
Syntax: xgcd(a, b)
xgcd(8, 12)
gcd(8, 12)
xgcd(36163, 21199)
Bitwise
bitAnd
Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0
Syntax: x & y bitAnd(x, y)
5 & 3
bitAnd(53, 131)
[1, 12, 31] & 42
Also see: bitNot, bitOr, bitXor, leftShift, rightArithShift, rightLogShift
bitNot
Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.
Syntax: ~x bitNot(x)
~1
~2
bitNot([2, -3, 4])
Also see: bitAnd, bitOr, bitXor, leftShift, rightArithShift, rightLogShift
bitOr
Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.
Syntax: x | y bitOr(x, y)
5 | 3
bitOr([1, 2, 3], 4)
Also see: bitAnd, bitNot, bitXor, leftShift, rightArithShift, rightLogShift
bitXor
Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.
Syntax: bitXor(x, y)
bitOr(1, 2)
bitXor([2, 3, 4], 4)
Also see: bitAnd, bitNot, bitOr, leftShift, rightArithShift, rightLogShift
leftShift
Bitwise left logical shift of a value x by y number of bits.
Syntax: x << y leftShift(x, y)
4 << 1
8 >> 1
Also see: bitAnd, bitNot, bitOr, bitXor, rightArithShift, rightLogShift
rightArithShift
Bitwise right arithmetic shift of a value x by y number of bits.
Syntax: x >> y rightArithShift(x, y)
8 >> 1
4 << 1
-12 >> 2
Also see: bitAnd, bitNot, bitOr, bitXor, leftShift, rightLogShift
rightLogShift
Bitwise right logical shift of a value x by y number of bits.
Syntax: x >>> y rightLogShift(x, y)
8 >>> 1
4 << 1
-12 >>> 2
Also see: bitAnd, bitNot, bitOr, bitXor, leftShift, rightArithShift
Combinatorics
bellNumbers
The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. bellNumbers only takes integer arguments. The following condition must be enforced: n >= 0.
Syntax: bellNumbers(n)
bellNumbers(3)
bellNumbers(8)
Also see: stirlingS2
catalan
The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.
Syntax: catalan(n)
catalan(3)
catalan(8)
Also see: bellNumbers
composition
The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.
Syntax: composition(n, k)
composition(5, 3)
Also see: combinations
stirlingS2
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. stirlingS2 only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.
Syntax: stirlingS2(n, k)
stirlingS2(5, 3)
Also see: bellNumbers, bernoulli
Complex
arg
Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).
Syntax: arg(x)
arg(2 + 2i)
atan2(3, 2)
arg(2 + 3i)
conj
Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.
Syntax: conj(x)
conj(2 + 3i)
conj(2 - 3i)
conj(-5.2i)
im
Get the imaginary part of a complex number.
Syntax: im(x)
im(2 + 3i)
re(2 + 3i)
im(-5.2i)
im(2.4)
re
Get the real part of a complex number.
Syntax: re(x)
re(2 + 3i)
im(2 + 3i)
re(-5.2i)
re(2.4)
Constants
e
Euler's number, the base of the natural logarithm. Approximately equal to 2.71828
Syntax: e
e
e ^ 2
exp(2)
log(e)
Also see: exp
false
Boolean value false
Syntax: false
false
Also see: true
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.
Syntax: i
i
i * i
sqrt(-1)
Infinity
Infinity, a number which is larger than the maximum number that can be handled by a floating point number.
Syntax: Infinity
Infinity
1 / 0
LN10
Returns the natural logarithm of 10, approximately equal to 2.302
Syntax: LN10
LN10
log(10)
LN2
Returns the natural logarithm of 2, approximately equal to 0.693
Syntax: LN2
LN2
log(2)
LOG10E
Returns the base-10 logarithm of E, approximately equal to 0.434
Syntax: LOG10E
LOG10E
log(e, 10)
LOG2E
Returns the base-2 logarithm of E, approximately equal to 1.442
Syntax: LOG2E
LOG2E
log(e, 2)
NaN
Not a number
Syntax: NaN
NaN
0 / 0
null
Value null
Syntax: 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 and is approximately 1.618034...
Syntax: phi
phi
pi
The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159
Syntax: pi
pi
sin(pi/2)
Also see: tau
SQRT1_2
Returns the square root of 1/2, approximately equal to 0.707
Syntax: SQRT1_2
SQRT1_2
sqrt(1/2)
SQRT2
Returns the square root of 2, approximately equal to 1.414
Syntax: SQRT2
SQRT2
sqrt(2)
tau
Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.
Syntax: tau
tau
2 * pi
Also see: pi
true
Boolean value true
Syntax: true
true
Also see: false
e
Euler's number, the base of the natural logarithm. Approximately equal to 2.71828
Syntax: e
e
e ^ 2
exp(2)
log(e)
Also see: exp
pi
The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159
Syntax: pi
pi
sin(pi/2)
Also see: tau
version
A string with the version number of math.js
Syntax: version
version
Construction
bigint
Create a bigint, an integer with an arbitrary number of digits, from a number or string.
Syntax: bigint(x)
123123123123123123 # a large number will lose digits
bigint("123123123123123123")
bignumber(["1", "3", "5"])
Also see: boolean, bignumber, number, complex, fraction, index, matrix, string, unit
bignumber
Create a big number from a number or string.
Syntax: bignumber(x)
0.1 + 0.2
bignumber(0.1) + bignumber(0.2)
bignumber("7.2")
bignumber("7.2e500")
bignumber([0.1, 0.2, 0.3])
Also see: boolean, bigint, complex, fraction, index, matrix, string, unit
boolean
Convert a string or number into a boolean.
Syntax: x boolean(x)
boolean(0)
boolean(1)
boolean(3)
boolean("true")
boolean("false")
boolean([1, 0, 1, 1])
Also see: bignumber, complex, index, matrix, number, string, unit
complex
Create a complex number.
Syntax: complex() complex(re, im) complex(string)
complex()
complex(2, 3)
complex("7 - 2i")
Also see: bignumber, boolean, index, matrix, number, string, unit
createUnit
Create a user-defined unit and register it with the Unit type.
Syntax: createUnit(definitions) createUnit(name, definition)
createUnit("foo")
createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})
createUnit("mph", "1 mile/hour")
fraction
Create a fraction from a number or from integer numerator and denominator.
Syntax: fraction(num) fraction(matrix) fraction(num,den) fraction({n: num, d: den})
fraction(0.125)
fraction(1, 3) + fraction(2, 5)
fraction({n: 333, d: 53})
fraction([sqrt(9), sqrt(10), sqrt(11)])
Also see: bignumber, boolean, complex, index, matrix, string, unit
index
Create an index to get or replace a subset of a matrix
Syntax: [start] [start:end] [start:step:end] [start1, start 2, ...] [start1:end1, start2:end2, ...] [start1:step1:end1, start2:step2:end2, ...]
A = [1, 2, 3; 4, 5, 6]
A[1, :]
A[1, 2] = 50
A[1:2, 1:2] = 1
B = [1, 2, 3]
B[B>1 and B<3]
Also see: bignumber, boolean, complex, matrix, number, range, string, unit
matrix
Create a matrix.
Syntax: [] [a1, b1, ...; a2, b2, ...] matrix() matrix("dense") matrix([...])
[]
[1, 2, 3]
[1, 2, 3; 4, 5, 6]
matrix()
matrix([3, 4])
matrix([3, 4; 5, 6], "sparse")
matrix([3, 4; 5, 6], "sparse", "number")
Also see: bignumber, boolean, complex, index, number, string, unit, sparse
number
Create a number or convert a string or boolean into a number.
Syntax: x number(x) number(unit, valuelessUnit)
2
2e3
4.05
number(2)
number("7.2")
number(true)
number([true, false, true, true])
number(unit("52cm"), "m")
Also see: bignumber, bigint, boolean, complex, fraction, index, matrix, string, unit
sparse
Create a sparse matrix.
Syntax: sparse() sparse([a1, b1, ...; a1, b2, ...]) sparse([a1, b1, ...; a1, b2, ...], "number")
sparse()
sparse([3, 4; 5, 6])
sparse([3, 0; 5, 0], "number")
Also see: bignumber, boolean, complex, index, number, string, unit, matrix
splitUnit
Split a unit in an array of units whose sum is equal to the original unit.
Syntax: splitUnit(unit: Unit, parts: Unit[])
splitUnit(1 m, ["feet", "inch"])
Also see: unit, createUnit
string
Create a string or convert a value to a string
Syntax: "text" string(x)
"Hello World!"
string(4.2)
string(3 + 2i)
Also see: bignumber, boolean, complex, index, matrix, number, unit
unit
Create a unit.
Syntax: value unit unit(value, unit) unit(string)
5.5 mm
3 inch
unit(7.1, "kilogram")
unit("23 deg")
Also see: bignumber, boolean, complex, index, matrix, number, string
Geometry
distance
Calculates the Euclidean distance between two points.
Syntax: distance([x1, y1], [x2, y2]) distance([x1, y1], [x2, y2](/bornova/numara-calculator/wiki/x1,-y1],-[x2,-y2))
distance([0,0], [4,4])
distance([0,0], [4,4](/bornova/numara-calculator/wiki/0,0],-[4,4))
intersect
Computes the intersection point of lines and/or planes.
Syntax: intersect(expr1, expr2, expr3, expr4) intersect(expr1, expr2, expr3)
intersect([0, 0], [10, 10], [10, 0], [0, 10])
intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])
Logical
and
Logical and. Test whether two values are both defined with a nonzero/nonempty value.
Syntax: x and y and(x, y)
true and false
true and true
2 and 4
not
Logical not. Flips the boolean value of given argument.
Syntax: not x not(x)
not true
not false
not 2
not 0
nullish
Nullish coalescing operator. Returns the right-hand operand when the left-hand operand is null or undefined, and otherwise returns the left-hand operand.
Syntax: x ?? y nullish(x, y)
null ?? 42
undefined ?? 42
0 ?? 42
false ?? 42
null ?? undefined ?? 42
or
Logical or. Test if at least one value is defined with a nonzero/nonempty value.
Syntax: x or y or(x, y)
true or false
false or false
0 or 4
xor
Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.
Syntax: x xor y xor(x, y)
true xor false
false xor false
true xor true
0 xor 4
Matrix
column
Return a column from a matrix or array.
Syntax: column(x, index)
A = [1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4)
column(A, 1)
column(A, 2)
Also see: row, matrixFromColumns
concat
Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.
Syntax: concat(A, B, C, ...) concat(A, B, C, ..., dim)
A = [1, 2; 5, 6]
B = [3, 4; 7, 8]
concat(A, B)
concat(A, B, 1)
concat(A, B, 2)
Also see: det, diag, identity, inv, ones, range, size, squeeze, subset, trace, transpose, zeros
count
Count the number of elements of a matrix, array or string.
Syntax: count(x)
a = [1, 2; 3, 4; 5, 6]
count(a)
size(a)
count("hello world")
Also see: size
cross
Calculate the cross product for two vectors in three dimensional space.
Syntax: cross(A, B)
cross([1, 1, 0], [0, 1, 1])
cross([3, -3, 1], [4, 9, 2])
cross([2, 3, 4], [5, 6, 7])
ctranspose
Complex Conjugate and Transpose a matrix
Syntax: x' ctranspose(x)
a = [1, 2, 3; 4, 5, 6]
a'
ctranspose(a)
Also see: concat, det, diag, identity, inv, ones, range, size, squeeze, subset, trace, zeros
det
Calculate the determinant of a matrix
Syntax: det(x)
det([1, 2; 3, 4])
det([-2, 2, 3; -1, 1, 3; 2, 0, -1])
Also see: concat, diag, identity, inv, ones, range, size, squeeze, subset, trace, transpose, zeros
diag
Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.
Syntax: diag(x) diag(x, k)
diag(1:3)
diag(1:3, 1)
a = [1, 2, 3; 4, 5, 6; 7, 8, 9]
diag(a)
Also see: concat, det, identity, inv, ones, range, size, squeeze, subset, trace, transpose, zeros
diff
Create a new matrix or array with the difference of the passed matrix or array.,Dim parameter is optional and used to indicate the dimension of the array/matrix to apply the difference,If no dimension parameter is passed it is assumed as dimension 0,Dimension is zero-based in javascript and one-based in the parser,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
Syntax: diff(arr) diff(arr, dim)
A = [1, 2, 4, 7, 0]
diff(A)
diff(A, 1)
B = [1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4)
diff(B)
diff(B, 1)
diff(B, 2)
diff(B, bignumber(2))
diff([[1, 2], matrix([3, 4])], 2)
Also see: subtract, partitionSelect
dot
Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn
Syntax: dot(A, B) A * B
dot([2, 4, 1], [2, 2, 3])
[2, 4, 1] * [2, 2, 3]
eigs
Calculate the eigenvalues and optionally eigenvectors of a square matrix
Syntax: eigs(x)
eigs([5, 2.3], [2.3, 1](/bornova/numara-calculator/wiki/5,-2.3],-[2.3,-1))
eigs([1, 2, 3], [4, 5, 6], [7, 8, 9](/bornova/numara-calculator/wiki/1,-2,-3],-[4,-5,-6],-[7,-8,-9), { precision: 1e-6, eigenvectors: false })
Also see: inv
fft
Calculate N-dimensional Fourier transform
Syntax: fft(x)
fft([1, 0], [1, 0](/bornova/numara-calculator/wiki/1,-0],-[1,-0))
Also see: ifft
filter
Filter items in a matrix.
Syntax: filter(x, test)
isPositive(x) = x > 0
filter([6, -2, -1, 4, 3], isPositive)
filter([6, -2, 0, 1, 0], x != 0)
flatten
Flatten a multi dimensional matrix into a single dimensional matrix.
Syntax: flatten(x)
a = [1, 2, 3; 4, 5, 6]
size(a)
b = flatten(a)
size(b)
Also see: concat, resize, size, squeeze
forEach
Iterates over all elements of a matrix/array, and executes the given callback function.
Syntax: forEach(x, callback)
numberOfPets = {}
addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;
forEach(["Dog","Cat","Cat"], addPet)
numberOfPets
getMatrixDataType
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. If a matrix contains more than one data type, it will return "mixed".
Syntax: getMatrixDataType(x)
getMatrixDataType([1, 2, 3])
getMatrixDataType([5 cm], [2 inch](/bornova/numara-calculator/wiki/5-cm],-[2-inch))
getMatrixDataType([1, "text"])
getMatrixDataType([1, bignumber(4)])
Also see: matrix, sparse, typeOf
identity
Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.
Syntax: identity(n) identity(m, n) identity([m, n])
identity(3)
identity(3, 5)
a = [1, 2, 3; 4, 5, 6]
identity(size(a))
Also see: concat, det, diag, inv, ones, range, size, squeeze, subset, trace, transpose, zeros
ifft
Calculate N-dimensional inverse Fourier transform
Syntax: ifft(x)
ifft([2, 2], [0, 0](/bornova/numara-calculator/wiki/2,-2],-[0,-0))
Also see: fft
inv
Calculate the inverse of a matrix
Syntax: inv(x)
inv([1, 2; 3, 4])
inv(4)
1 / 4
Also see: concat, det, diag, identity, ones, range, size, squeeze, subset, trace, transpose, zeros
kron
Calculates the Kronecker product of 2 matrices or vectors.
Syntax: kron(x, y)
kron([1, 0], [0, 1](/bornova/numara-calculator/wiki/1,-0],-[0,-1), [1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4))
kron([1,1], [2,3,4])
Also see: multiply, dot, cross
map
Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array or the matrices/arrays.
Syntax: map(x, callback) map(x, y, ..., callback)
map([1, 2, 3], square)
map([1, 2], [3, 4], f(a,b) = a + b)
mapSlices
Generate a matrix one dimension less than A by applying callback to each slice of A along dimension dim.
Syntax: mapSlices(A, dim, callback)
A = [1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4)
mapSlices(A, 1, sum)
mapSlices(A, 2, prod)
matrixFromColumns
Create a dense matrix from vectors as individual columns.
Syntax: matrixFromColumns(...arr) matrixFromColumns(row1, row2) matrixFromColumns(row1, row2, row3)
matrixFromColumns([1, 2, 3], [4],[5],[6](/bornova/numara-calculator/wiki/4],[5],[6))
Also see: matrix, matrixFromRows, matrixFromFunction, zeros
matrixFromFunction
Create a matrix by evaluating a generating function at each index.
Syntax: matrixFromFunction(size, fn) matrixFromFunction(size, fn, format) matrixFromFunction(size, fn, format, datatype) matrixFromFunction(size, format, fn) matrixFromFunction(size, format, datatype, fn)
f(I) = I[1] - I[2]
matrixFromFunction([3,3], f)
g(I) = I[1] - I[2] == 1 ? 4 : 0
matrixFromFunction([100, 100], "sparse", g)
matrixFromFunction([5], random)
Also see: matrix, matrixFromRows, matrixFromColumns, zeros
matrixFromRows
Create a dense matrix from vectors as individual rows.
Syntax: matrixFromRows(...arr) matrixFromRows(row1, row2) matrixFromRows(row1, row2, row3)
matrixFromRows([1, 2, 3], [4],[5],[6](/bornova/numara-calculator/wiki/4],[5],[6))
Also see: matrix, matrixFromColumns, matrixFromFunction, zeros
ones
Create a matrix containing ones.
Syntax: ones(m) ones(m, n) ones(m, n, p, ...) ones([m]) ones([m, n]) ones([m, n, p, ...])
ones(3)
ones(3, 5)
ones([2,3]) * 4.5
a = [1, 2, 3; 4, 5, 6]
ones(size(a))
Also see: concat, det, diag, identity, inv, range, size, squeeze, subset, trace, transpose, zeros
partitionSelect
Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.
Syntax: partitionSelect(x, k) partitionSelect(x, k, compare)
partitionSelect([5, 10, 1], 2)
partitionSelect(["C", "B", "A", "D"], 1, compareText)
arr = [5, 2, 1]
partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]
arr
partitionSelect(arr, 1, 'desc') # returns 2, arr is now: [5, 2, 1]
arr
Also see: sort
pinv
Calculate the Moore–Penrose inverse of a matrix
Syntax: pinv(x)
pinv([1, 2; 3, 4])
pinv([1, 0], [0, 1], [0, 1](/bornova/numara-calculator/wiki/1,-0],-[0,-1],-[0,-1))
pinv(4)
Also see: inv
reshape
Reshape a multi dimensional array to fit the specified dimensions.
Syntax: reshape(x, sizes)
reshape([1, 2, 3, 4, 5, 6], [2, 3])
reshape([1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4), [1, 4])
reshape([1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4), [4])
reshape([1, 2, 3, 4], [-1, 2])
Also see: size, squeeze, resize
resize
Resize a matrix.
Syntax: resize(x, size) resize(x, size, defaultValue)
resize([1,2,3,4,5], [3])
resize([1,2,3], [5])
resize([1,2,3], [5], -1)
resize(2, [2, 3])
resize("hello", [8], "!")
Also see: size, subset, squeeze, reshape
rotate
Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.
Syntax: rotate(w, theta) rotate(w, theta, v)
rotate([1, 0], pi / 2)
rotate(matrix([1, 0]), unit("35deg"))
rotate([1, 0, 0], unit("90deg"), [0, 0, 1])
rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))
Also see: matrix, rotationMatrix
rotationMatrix
Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.
Syntax: rotationMatrix(theta) rotationMatrix(theta, v) rotationMatrix(theta, v, format)
rotationMatrix(pi / 2)
rotationMatrix(unit("45deg"), [0, 0, 1])
rotationMatrix(1, matrix([0, 0, 1]), "sparse")
row
Return a row from a matrix or array.
Syntax: row(x, index)
A = [1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4)
row(A, 1)
row(A, 2)
Also see: column, matrixFromRows
size
Calculate the size of a matrix.
Syntax: size(x)
size(2.3)
size("hello world")
a = [1, 2; 3, 4; 5, 6]
size(a)
size(1:6)
Also see: concat, count, det, diag, identity, inv, ones, range, squeeze, subset, trace, transpose, zeros
sort
Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.
Syntax: sort(x) sort(x, compare)
sort([5, 10, 1])
sort(["C", "B", "A", "D"], "natural")
sortByLength(a, b) = size(a)[1] - size(b)[1]
sort(["Langdon", "Tom", "Sara"], sortByLength)
sort(["10", "1", "2"], "natural")
Also see: map, filter, forEach
squeeze
Remove inner and outer singleton dimensions from a matrix.
Syntax: squeeze(x)
a = zeros(3,2,1)
size(squeeze(a))
b = zeros(1,1,3)
size(squeeze(b))
Also see: concat, det, diag, identity, inv, ones, range, size, subset, trace, transpose, zeros
subset
Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation l:u. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.
Syntax: value(index) value(index) = replacement subset(value, [index]) subset(value, [index], replacement)
d = [1, 2; 3, 4]
e = []
e[1, 1:2] = [5, 6]
e[2, :] = [7, 8]
f = d * e
f[2, 1]
f[:, 1]
f[1,2], [1,3](/bornova/numara-calculator/wiki/1,2],-[1,3) = [9, 10; 11, 12]
f
Also see: concat, det, diag, identity, inv, ones, range, size, squeeze, trace, transpose, zeros
trace
Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.
Syntax: trace(A)
A = [1, 2, 3; -1, 2, 3; 2, 0, 3]
trace(A)
Also see: concat, det, diag, identity, inv, ones, range, size, squeeze, subset, transpose, zeros
transpose
Transpose a matrix
Syntax: x' transpose(x)
a = [1, 2, 3; 4, 5, 6]
a'
transpose(a)
Also see: concat, det, diag, identity, inv, ones, range, size, squeeze, subset, trace, zeros
zeros
Create a matrix containing zeros.
Syntax: zeros(m) zeros(m, n) zeros(m, n, p, ...) zeros([m]) zeros([m, n]) zeros([m, n, p, ...])
zeros(3)
zeros(3, 5)
a = [1, 2, 3; 4, 5, 6]
zeros(size(a))
Also see: concat, det, diag, identity, inv, ones, range, size, squeeze, subset, trace, transpose
Numeric
solveODE
Numerical Integration of Ordinary Differential Equations.
Syntax: solveODE(func, tspan, y0) solveODE(func, tspan, y0, options)
f(t,y) = y
tspan = [0, 4]
solveODE(f, tspan, 1)
solveODE(f, tspan, [1, 2])
solveODE(f, tspan, 1, { method:"RK23", maxStep:0.1 })
Also see: derivative, simplifyCore
Operators
add
Add two values.
Syntax: x + y add(x, y)
a = 2.1 + 3.6
a - 3.6
3 + 2i
3 cm + 2 inch
"2.3" + "4"
Also see: subtract
divide
Divide two values.
Syntax: x / y divide(x, y)
a = 2 / 3
a * 3
4.5 / 2
3 + 4 / 2
(3 + 4) / 2
18 km / 4.5
Also see: multiply
dotDivide
Divide two values element wise.
Syntax: x ./ y dotDivide(x, y)
a = [1, 2, 3; 4, 5, 6]
b = [2, 1, 1; 3, 2, 5]
a ./ b
Also see: multiply, dotMultiply, divide
dotMultiply
Multiply two values element wise.
Syntax: x .* y dotMultiply(x, y)
a = [1, 2, 3; 4, 5, 6]
b = [2, 1, 1; 3, 2, 5]
a .* b
Also see: multiply, divide, dotDivide
dotPow
Calculates the power of x to y element wise.
Syntax: x .^ y dotPow(x, y)
a = [1, 2, 3; 4, 5, 6]
a .^ 2
Also see: pow
mod
Calculates the modulus, the remainder of an integer division.
Syntax: x % y x mod y mod(x, y)
7 % 3
11 % 2
10 mod 4
isOdd(x) = x % 2
isOdd(2)
isOdd(3)
Also see: divide
multiply
multiply two values.
Syntax: x * y multiply(x, y)
a = 2.1 * 3.4
a / 3.4
2 * 3 + 4
2 * (3 + 4)
3 * 2.1 km
Also see: divide
pow
Calculates the power of x to y, x^y.
Syntax: x ^ y pow(x, y)
2^3
2*2*2
1 + e ^ (pi * i)
pow([1, 2], [4, 3](/bornova/numara-calculator/wiki/1,-2],-[4,-3), 2)
pow([1, 2], [4, 3](/bornova/numara-calculator/wiki/1,-2],-[4,-3), -1)
Also see: multiply, nthRoot, nthRoots, sqrt
subtract
subtract two values.
Syntax: x - y subtract(x, y)
a = 5.3 - 2
a + 2
2/3 - 1/6
2 * 3 - 3
2.1 km - 500m
Also see: add
unaryMinus
Inverse the sign of a value. Converts booleans and strings to numbers.
Syntax: -x unaryMinus(x)
-4.5
-(-5.6)
-"22"
Also see: add, subtract, unaryPlus
unaryPlus
Converts booleans and strings to numbers.
Syntax: +x unaryPlus(x)
+true
+"2"
Also see: add, subtract, unaryMinus
Probability
bernoulli
The nth Bernoulli number
Syntax: bernoulli(n)
bernoulli(4)
bernoulli(fraction(12))
Also see: combinations, gamma, stirlingS2
combinations
Compute the number of combinations of n items taken k at a time
Syntax: combinations(n, k)
combinations(7, 5)
Also see: combinationsWithRep, permutations, factorial
combinationsWithRep
Compute the number of combinations of n items taken k at a time with replacements.
Syntax: combinationsWithRep(n, k)
combinationsWithRep(7, 5)
Also see: combinations, permutations, factorial
factorial
Compute the factorial of a value
Syntax: n! factorial(n)
5!
5 * 4 * 3 * 2 * 1
3!
Also see: combinations, combinationsWithRep, permutations, gamma
gamma
Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.
Syntax: gamma(n)
gamma(4)
3!
gamma(1/2)
sqrt(pi)
Also see: factorial
kldivergence
Calculate the Kullback-Leibler (KL) divergence between two distributions.
Syntax: kldivergence(x, y)
kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])
lgamma
Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.
Syntax: lgamma(n)
lgamma(4)
lgamma(1/2)
lgamma(i)
lgamma(complex(1.1, 2))
Also see: gamma
multinomial
Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from n possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.
Syntax: multinomial(A)
multinomial([1, 2, 1])
Also see: combinations, factorial
permutations
Compute the number of permutations of n items taken k at a time
Syntax: permutations(n) permutations(n, k)
permutations(5)
permutations(5, 3)
Also see: combinations, combinationsWithRep, factorial
pickRandom
Pick a random entry from a given array.
Syntax: pickRandom(array) pickRandom(array, number) pickRandom(array, weights) pickRandom(array, number, weights) pickRandom(array, weights, number)
pickRandom(0:10)
pickRandom([1, 3, 1, 6])
pickRandom([1, 3, 1, 6], 2)
pickRandom([1, 3, 1, 6], [2, 3, 2, 1])
pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])
pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)
random
Return a random number.
Syntax: random() random(max) random(min, max) random(size) random(size, max) random(size, min, max)
random()
random(10, 20)
random([2, 3])
Also see: pickRandom, randomInt
randomInt
Return a random integer number
Syntax: randomInt(max) randomInt(min, max) randomInt(size) randomInt(size, max) randomInt(size, min, max)
randomInt(10, 20)
randomInt([2, 3], 10)
Also see: pickRandom, random
Relational
compare
Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.
Syntax: compare(x, y)
compare(2, 3)
compare(3, 2)
compare(2, 2)
compare(5cm, 40mm)
compare(2, [1, 2, 3])
Also see: equal, unequal, smaller, smallerEq, largerEq, compareNatural, compareText
compareNatural
Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.
Syntax: compareNatural(x, y)
compareNatural(2, 3)
compareNatural(3, 2)
compareNatural(2, 2)
compareNatural(5cm, 40mm)
compareNatural("2", "10")
compareNatural(2 + 3i, 2 + 4i)
compareNatural([1, 2, 4], [1, 2, 3])
compareNatural([1, 5], [1, 2, 3])
compareNatural([1, 2], [1, 2])
compareNatural({a: 2}, {a: 4})
Also see: equal, unequal, smaller, smallerEq, largerEq, compare, compareText
compareText
Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.
Syntax: compareText(x, y)
compareText("B", "A")
compareText("A", "B")
compareText("A", "A")
compareText("2", "10")
compare("2", "10")
compare(2, 10)
compareNatural("2", "10")
compareText("B", ["A", "B", "C"])
Also see: compare, compareNatural
deepEqual
Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.
Syntax: deepEqual(x, y)
deepEqual([1,3,4], [1,3,4])
deepEqual([1,3,4], [1,3])
Also see: equal, unequal, smaller, larger, smallerEq, largerEq, compare
equal
Check equality of two values. Returns true if the values are equal, and false if not.
Syntax: x == y equal(x, y)
2+2 == 3
2+2 == 4
a = 3.2
b = 6-2.8
a == b
50cm == 0.5m
Also see: unequal, smaller, larger, smallerEq, largerEq, compare, deepEqual, equalText
equalText
Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.
Syntax: equalText(x, y)
equalText("Hello", "Hello")
equalText("a", "A")
equal("2e3", "2000")
equalText("2e3", "2000")
equalText("B", ["A", "B", "C"])
Also see: compare, compareNatural, compareText, equal
larger
Check if value x is larger than y. Returns true if x is larger than y, and false if not. Comparing a value with NaN returns false.
Syntax: x > y larger(x, y)
2 > 3
5 > 2*2
a = 3.3
b = 6-2.8
(a > b)
(b < a)
5 cm > 2 inch
Also see: equal, unequal, smaller, smallerEq, largerEq, compare
largerEq
Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.
Syntax: x >= y largerEq(x, y)
2 >= 1+1
2 > 1+1
a = 3.2
b = 6-2.8
(a >= b)
Also see: equal, unequal, smallerEq, smaller, compare
smaller
Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not. Comparing a value with NaN returns false.
Syntax: x < y smaller(x, y)
2 < 3
5 < 2*2
a = 3.3
b = 6-2.8
(a < b)
5 cm < 2 inch
Also see: equal, unequal, larger, smallerEq, largerEq, compare
smallerEq
Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.
Syntax: x <= y smallerEq(x, y)
2 <= 1+1
2 < 1+1
a = 3.2
b = 6-2.8
(a <= b)
Also see: equal, unequal, larger, smaller, largerEq, compare
unequal
Check unequality of two values. Returns true if the values are unequal, and false if they are equal.
Syntax: x != y unequal(x, y)
2+2 != 3
2+2 != 4
a = 3.2
b = 6-2.8
a != b
50cm != 0.5m
5 cm != 2 inch
Also see: equal, smaller, larger, smallerEq, largerEq, compare, deepEqual
Set
setCartesian
Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.
Syntax: setCartesian(set1, set2)
setCartesian([1, 2], [3, 4])
Also see: setUnion, setIntersect, setDifference, setPowerset
setDifference
Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.
Syntax: setDifference(set1, set2)
setDifference([1, 2, 3, 4], [3, 4, 5, 6])
setDifference([1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4), [3, 4], [5, 6](/bornova/numara-calculator/wiki/3,-4],-[5,-6))
Also see: setUnion, setIntersect, setSymDifference
setDistinct
Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.
Syntax: setDistinct(set)
setDistinct([1, 1, 1, 2, 2, 3])
Also see: setMultiplicity
setIntersect
Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.
Syntax: setIntersect(set1, set2)
setIntersect([1, 2, 3, 4], [3, 4, 5, 6])
setIntersect([1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4), [3, 4], [5, 6](/bornova/numara-calculator/wiki/3,-4],-[5,-6))
Also see: setUnion, setDifference
setIsSubset
Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.
Syntax: setIsSubset(set1, set2)
setIsSubset([1, 2], [3, 4, 5, 6])
setIsSubset([3, 4], [3, 4, 5, 6])
Also see: setUnion, setIntersect, setDifference
setMultiplicity
Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.
Syntax: setMultiplicity(element, set)
setMultiplicity(1, [1, 2, 2, 4])
setMultiplicity(2, [1, 2, 2, 4])
Also see: setDistinct, setSize
setPowerset
Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.
Syntax: setPowerset(set)
setPowerset([1, 2, 3])
Also see: setCartesian
setSize
Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.
Syntax: setSize(set) setSize(set, unique)
setSize([1, 2, 2, 4])
setSize([1, 2, 2, 4], true)
Also see: setUnion, setIntersect, setDifference
setSymDifference
Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.
Syntax: setSymDifference(set1, set2)
setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])
setSymDifference([1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4), [3, 4], [5, 6](/bornova/numara-calculator/wiki/3,-4],-[5,-6))
Also see: setUnion, setIntersect, setDifference
setUnion
Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.
Syntax: setUnion(set1, set2)
setUnion([1, 2, 3, 4], [3, 4, 5, 6])
setUnion([1, 2], [3, 4](/bornova/numara-calculator/wiki/1,-2],-[3,-4), [3, 4], [5, 6](/bornova/numara-calculator/wiki/3,-4],-[5,-6))
Also see: setIntersect, setDifference
Signal
freqz
Calculates the frequency response of a filter given its numerator and denominator coefficients.
Syntax: freqz(b, a) freqz(b, a, w)
freqz([1, 2], [1, 2, 3])
freqz([1, 2], [1, 2, 3], [0, 1])
freqz([1, 2], [1, 2, 3], 512)
zpk2tf
Compute the transfer function of a zero-pole-gain model.
Syntax: zpk2tf(z, p, k)
zpk2tf([1, 2], [-1, -2], 1)
zpk2tf([1, 2], [-1, -2])
zpk2tf([1 - 3i, 2 + 2i], [-1, -2])
Special
erf
Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x
Syntax: erf(x)
erf(0.2)
erf(-0.5)
erf(4)
zeta
Compute the Riemann Zeta Function using an infinite series and Riemann's Functional Equation for the entire complex plane
Syntax: zeta(s)
zeta(0.2)
zeta(-0.5)
zeta(4)
Statistics
corr
Compute the correlation coefficient of a two list with values, For matrices, the matrix correlation coefficient is calculated.
Syntax: corr(A,B)
corr([2, 4, 6, 8],[1, 2, 3, 6])
corr(matrix([1, 2.2, 3, 4.8, 5], [1, 2, 3, 4, 5](/bornova/numara-calculator/wiki/1,-2.2,-3,-4.8,-5],-[1,-2,-3,-4,-5)), matrix([4, 5.3, 6.6, 7, 8], [1, 2, 3, 4, 5](/bornova/numara-calculator/wiki/4,-5.3,-6.6,-7,-8],-[1,-2,-3,-4,-5)))
Also see: max, mean, min, median, min, prod, std, sum
cumsum
Compute the cumulative sum of all values.
Syntax: cumsum(a, b, c, ...) cumsum(A)
cumsum(2, 3, 4, 1)
cumsum([2, 3, 4, 1])
cumsum([1, 2; 3, 4])
cumsum([1, 2; 3, 4], 1)
cumsum([1, 2; 3, 4], 2)
Also see: max, mean, median, min, prod, std, sum, variance
mad
Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.
Syntax: mad(a, b, c, ...) mad(A)
mad(10, 20, 30)
mad([1, 2, 3])
Also see: mean, median, std, abs
max
Compute the maximum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.
Syntax: max(a, b, c, ...) max(A) max(A, dimension)
max(2, 3, 4, 1)
max([2, 3, 4, 1])
max([2, 5; 4, 3])
max([2, 5; 4, 3], 1)
max([2, 5; 4, 3], 2)
max(2.7, 7.1, -4.5, 2.0, 4.1)
min(2.7, 7.1, -4.5, 2.0, 4.1)
Also see: mean, median, min, prod, std, sum, variance
mean
Compute the arithmetic mean of a list of values.
Syntax: mean(a, b, c, ...) mean(A) mean(A, dimension)
mean(2, 3, 4, 1)
mean([2, 3, 4, 1])
mean([2, 5; 4, 3])
mean([2, 5; 4, 3], 1)
mean([2, 5; 4, 3], 2)
mean([1.0, 2.7, 3.2, 4.0])
Also see: max, median, min, prod, std, sum, variance
median
Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.
Syntax: median(a, b, c, ...) median(A)
median(5, 2, 7)
median([3, -1, 5, 7])
Also see: max, mean, min, prod, std, sum, variance, quantileSeq
min
Compute the minimum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.
Syntax: min(a, b, c, ...) min(A) min(A, dimension)
min(2, 3, 4, 1)
min([2, 3, 4, 1])
min([2, 5; 4, 3])
min([2, 5; 4, 3], 1)
min([2, 5; 4, 3], 2)
min(2.7, 7.1, -4.5, 2.0, 4.1)
max(2.7, 7.1, -4.5, 2.0, 4.1)
Also see: max, mean, median, prod, std, sum, variance
mode
Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.
Syntax: mode(a, b, c, ...) mode(A) mode(A, a, b, B, c, ...)
mode(2, 1, 4, 3, 1)
mode([1, 2.7, 3.2, 4, 2.7])
mode(1, 4, 6, 1, 6)
Also see: max, mean, min, median, prod, std, sum, variance
prod
Compute the product of all values.
Syntax: prod(a, b, c, ...) prod(A)
prod(2, 3, 4)
prod([2, 3, 4])
prod([2, 5; 4, 3])
Also see: max, mean, min, median, min, std, sum, variance
quantileSeq
Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probability are: Number, BigNumber.
In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.
Syntax: quantileSeq(A, prob[, sorted]) quantileSeq(A, [prob1, prob2, ...][, sorted]) quantileSeq(A, N[, sorted])
quantileSeq([3, -1, 5, 7], 0.5)
quantileSeq([3, -1, 5, 7], [1/3, 2/3])
quantileSeq([3, -1, 5, 7], 2)
quantileSeq([-1, 3, 5, 7], 0.5, true)
Also see: mean, median, min, max, prod, std, sum, variance
std
Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".
Syntax: std(a, b, c, ...) std(A) std(A, dimension) std(A, normalization) std(A, dimension, normalization)
std(2, 4, 6)
std([2, 4, 6, 8])
std([2, 4, 6, 8], "uncorrected")
std([2, 4, 6, 8], "biased")
std([1, 2, 3; 4, 5, 6])
Also see: max, mean, min, median, prod, sum, variance
sum
Compute the sum of all values.
Syntax: sum(a, b, c, ...) sum(A) sum(A, dimension)
sum(2, 3, 4, 1)
sum([2, 3, 4, 1])
sum([2, 5; 4, 3])
Also see: max, mean, median, min, prod, std, variance
variance
Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".
Syntax: variance(a, b, c, ...) variance(A) variance(A, dimension) variance(A, normalization) variance(A, dimension, normalization)
variance(2, 4, 6)
variance([2, 4, 6, 8])
variance([2, 4, 6, 8], "uncorrected")
variance([2, 4, 6, 8], "biased")
variance([1, 2, 3; 4, 5, 6])
Also see: max, mean, min, median, min, prod, std, sum
Trigonometry
acos
Compute the inverse cosine of a value in radians.
Syntax: acos(x)
acos(0.5)
acos(cos(2.3))
acosh
Calculate the hyperbolic arccos of a value, defined as acosh(x) = ln(sqrt(x^2 - 1) + x).
Syntax: acosh(x)
acosh(1.5)
acot
Calculate the inverse cotangent of a value.
Syntax: acot(x)
acot(0.5)
acot(cot(0.5))
acot(2)
acoth
Calculate the inverse hyperbolic tangent of a value, defined as acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2.
Syntax: acoth(x)
acoth(2)
acoth(0.5)
acsc
Calculate the inverse cotangent of a value.
Syntax: acsc(x)
acsc(2)
acsc(csc(0.5))
acsc(0.5)
acsch
Calculate the inverse hyperbolic cosecant of a value, defined as acsch(x) = ln(1/x + sqrt(1/x^2 + 1)).
Syntax: acsch(x)
acsch(0.5)
asec
Calculate the inverse secant of a value.
Syntax: asec(x)
asec(0.5)
asec(sec(0.5))
asec(2)
asech
Calculate the inverse secant of a value.
Syntax: asech(x)
asech(0.5)
asin
Compute the inverse sine of a value in radians.
Syntax: asin(x)
asin(0.5)
asin(sin(0.5))
asinh
Calculate the hyperbolic arcsine of a value, defined as asinh(x) = ln(x + sqrt(x^2 + 1)).
Syntax: asinh(x)
asinh(0.5)
atan
Compute the inverse tangent of a value in radians.
Syntax: atan(x)
atan(0.5)
atan(tan(0.5))
atan2
Computes the principal value of the arc tangent of y/x in radians.
Syntax: atan2(y, x)
atan2(2, 2) / pi
angle = 60 deg in rad
x = cos(angle)
y = sin(angle)
atan2(y, x)
atanh
Calculate the hyperbolic arctangent of a value, defined as atanh(x) = ln((1 + x)/(1 - x)) / 2.
Syntax: atanh(x)
atanh(0.5)
cos
Compute the cosine of x in radians.
Syntax: cos(x)
cos(2)
cos(pi / 4) ^ 2
cos(180 deg)
cos(60 deg)
sin(0.2)^2 + cos(0.2)^2
cosh
Compute the hyperbolic cosine of x in radians.
Syntax: cosh(x)
cosh(0.5)
cot
Compute the cotangent of x in radians. Defined as 1/tan(x)
Syntax: cot(x)
cot(2)
1 / tan(2)
coth
Compute the hyperbolic cotangent of x in radians.
Syntax: coth(x)
coth(2)
1 / tanh(2)
csc
Compute the cosecant of x in radians. Defined as 1/sin(x)
Syntax: csc(x)
csc(2)
1 / sin(2)
csch
Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)
Syntax: csch(x)
csch(2)
1 / sinh(2)
sec
Compute the secant of x in radians. Defined as 1/cos(x)
Syntax: sec(x)
sec(2)
1 / cos(2)
sech
Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)
Syntax: sech(x)
sech(2)
1 / cosh(2)
sin
Compute the sine of x in radians.
Syntax: sin(x)
sin(2)
sin(pi / 4) ^ 2
sin(90 deg)
sin(30 deg)
sin(0.2)^2 + cos(0.2)^2
sinh
Compute the hyperbolic sine of x in radians.
Syntax: sinh(x)
sinh(0.5)
tan
Compute the tangent of x in radians.
Syntax: tan(x)
tan(0.5)
sin(0.5) / cos(0.5)
tan(pi / 4)
tan(45 deg)
tanh
Compute the hyperbolic tangent of x in radians.
Syntax: tanh(x)
tanh(0.5)
sinh(0.5) / cosh(0.5)
Type
range
Create a range. Lower bound of the range is included, upper bound is excluded.
Syntax: start:end start:step:end range(start, end) range(start, end, step) range(string)
1:5
3:-1:-3
range(3, 7)
range(0, 12, 2)
range("4:10")
range(1m, 1m, 3m)
a = [1, 2, 3, 4; 5, 6, 7, 8]
a[1:2, 1:2]
Also see: concat, det, diag, identity, inv, ones, size, squeeze, subset, trace, transpose, zeros
Units
to
Change the unit of a value.
Syntax: x to unit to(x, unit)
5 inch to cm
3.2kg to g
16 bytes in bits
toBest
Converts to the most appropriate display unit.
Syntax: toBest(x) toBest(x, unitList) toBest(x, unitList, options)
toBest(unit(5000, "m"))
toBest(unit(3500000, "W"))
toBest(unit(0.000000123, "A"))
toBest(unit(10, "m"), "cm")
toBest(unit(10, "m"), "mm,km", {offset: 1.5})
Utils
bin
Format a number as binary
Syntax: bin(value)
bin(2)
clone
Clone a variable. Creates a copy of primitive variables, and a deep copy of matrices
Syntax: clone(x)
clone(3.5)
clone(2 - 4i)
clone(45 deg)
clone([1, 2; 3, 4])
clone("hello world")
format
Format a value of any type as string.
Syntax: format(value) format(value, precision)
format(2.3)
format(3 - 4i)
format([])
format(pi, 3)
Also see: print
hasNumericValue
Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.
Syntax: hasNumericValue(x)
hasNumericValue(2)
hasNumericValue("2")
isNumeric("2")
hasNumericValue(0)
hasNumericValue(bignumber(500))
hasNumericValue(fraction(0.125))
hasNumericValue(2 + 3i)
hasNumericValue([2.3, "foo", false])
Also see: isInteger, isZero, isNegative, isPositive, isNaN, isNumeric
hex
Format a number as hexadecimal
Syntax: hex(value)
hex(240)
isBounded
Test whether a value or its entries are bounded.
Syntax: isBounded(x)
isBounded(Infinity)
isBounded(bigint(3))
isBounded([3, -Infinity, -3])
Also see: isFinite, isNumeric, isNaN, isNegative, isPositive
isFinite
Test whether a value is finite, elementwise on collections.
Syntax: isFinite(x)
isFinite(Infinity)
isFinite(bigint(3))
isFinite([3, -Infinity, -3])
Also see: isBounded, isNumeric, isNaN, isNegative, isPositive
isInteger
Test whether a value is an integer number.
Syntax: isInteger(x)
isInteger(2)
isInteger(3.5)
isInteger([3, 0.5, -2])
Also see: isNegative, isNumeric, isPositive, isZero
isNaN
Test whether a value is NaN (not a number)
Syntax: isNaN(x)
isNaN(2)
isNaN(0 / 0)
isNaN(NaN)
isNaN(Infinity)
Also see: isNegative, isNumeric, isPositive, isZero, isFinite, isBounded
isNegative
Test whether a value is negative: smaller than zero.
Syntax: isNegative(x)
isNegative(2)
isNegative(0)
isNegative(-4)
isNegative([3, 0.5, -2])
Also see: isInteger, isNumeric, isPositive, isZero
isNumeric
Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.
Syntax: isNumeric(x)
isNumeric(2)
isNumeric("2")
hasNumericValue("2")
isNumeric(0)
isNumeric(bignumber(500))
isNumeric(fraction(0.125))
isNumeric(2 + 3i)
isNumeric([2.3, "foo", false])
Also see: isInteger, isZero, isNegative, isPositive, isNaN, hasNumericValue, isFinite, isBounded
isPositive
Test whether a value is positive: larger than zero.
Syntax: isPositive(x)
isPositive(2)
isPositive(0)
isPositive(-4)
isPositive([3, 0.5, -2])
Also see: isInteger, isNumeric, isNegative, isZero
isPrime
Test whether a value is prime: has no divisors other than itself and one.
Syntax: isPrime(x)
isPrime(3)
isPrime(-2)
isPrime([2, 17, 100])
Also see: isInteger, isNumeric, isNegative, isZero
isZero
Test whether a value is zero.
Syntax: isZero(x)
isZero(2)
isZero(0)
isZero(-4)
isZero([3, 0, -2, 0])
Also see: isInteger, isNumeric, isNegative, isPositive
numeric
Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.
Syntax: numeric(x)
numeric("4")
numeric("4", "number")
numeric("4", "bigint")
numeric("4", "BigNumber")
numeric("4", "Fraction")
numeric(4, "Fraction")
numeric(fraction(2, 5), "number")
Also see: number, bigint, fraction, bignumber, string, format
oct
Format a number as octal
Syntax: oct(value)
oct(56)
Interpolate values into a string template.
Syntax: print(template, values) print(template, values, precision)
print("Lucy is $age years old", {age: 5})
print("The value of pi is $pi", {pi: pi}, 3)
print("Hello, $user.name!", {user: {name: "John"}})
print("Values: $1, $2, $3", [6, 9, 4])
Also see: format
typeOf
Get the type of a variable.
Syntax: typeOf(x)
typeOf(3.5)
typeOf(2 - 4i)
typeOf(45 deg)
typeOf("hello world")
Also see: getMatrixDataType
Special constants
Atomic mass constant
atomicMass
Avogadro's number
avogadro
Bohr magneton
bohrMagneton
Bohr radius
bohrRadius
Boltzmann constant
boltzmann
Classical electron radius
classicalElectronRadius
Conductance quantum
conductanceQuantum
Coulomb's constant. Deprecated in favor of coulombConstant
coulombConstant
Coulomb's constant
coulombConstant
Deuteron Mass
deuteronMass
Efimov factor
efimovFactor
Electric constant (vacuum permeability)
electricConstant
Electron mass
electronMass
Elementary charge
elementaryCharge
Faraday constant
faraday
Fermi coupling constant
fermiCoupling
Fine-structure constant
fineStructure
First radiation constant
firstRadiation
Gas constant
gasConstant
Newtonian constant of gravitation
gravitationConstant
Standard acceleration of gravity (standard acceleration of free-fall on Earth)
gravity
Hartree energy
hartreeEnergy
Inverse conductance quantum
inverseConductanceQuantum
Von Klitzing constant
klitzing
Loschmidt constant at T=273.15 K and p=101.325 kPa
loschmidt
Magnetic constant (vacuum permeability)
magneticConstant
Magnetic flux quantum
magneticFluxQuantum
Molar mass constant
molarMass
Molar mass constant of carbon-12
molarMassC12
Molar Planck constant
molarPlanckConstant
Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa
molarVolume
Neutron mass
neutronMass
Nuclear magneton
nuclearMagneton
Planck charge
planckCharge
Planck constant
planckConstant
Planck length
planckLength
Planck mass
planckMass
Planck temperature
planckTemperature
Planck time
planckTime
Proton mass
protonMass
Quantum of circulation
quantumOfCirculation
Reduced Planck constant
reducedPlanckConstant
Rydberg constant
rydberg
Sackur-Tetrode constant at T=1 K and p=101.325 kPa
sackurTetrode
Second radiation constant
secondRadiation
Speed of light in vacuum
speedOfLight
Stefan-Boltzmann constant
stefanBoltzmann
Thomson cross section
thomsonCrossSection
Characteristic impedance of vacuum
vacuumImpedance
Weak mixing angle
weakMixingAngle
Wien displacement law constant
wienDisplacement