UNPKG

22 kBMarkdownView Raw
1# Function reference
2
3## Expression functions
4
5Function | Description
6---- | -----------
7[math.compile(expr)](functions/compile.md) | Parse and compile an expression.
8[math.evaluate(expr [, scope])](functions/evaluate.md) | Evaluate an expression.
9[math.help(search)](functions/help.md) | Retrieve help on a function or data type.
10[math.parser()](functions/parser.md) | Create a parser.
11
12## Algebra functions
13
14Function | Description
15---- | -----------
16[derivative(expr, variable)](functions/derivative.md) | Takes the derivative of an expression expressed in parser Nodes.
17[math.lsolve(L, b)](functions/lsolve.md) | Finds one solution of a linear equation system by forwards substitution.
18[math.lsolveAll(L, b)](functions/lsolveAll.md) | Finds all solutions of a linear equation system by forwards substitution.
19[math.lup(A)](functions/lup.md) | Calculate the Matrix LU decomposition with partial pivoting.
20[math.lusolve(A, b)](functions/lusolve.md) | Solves the linear system `A * x = b` where `A` is an [n x n] matrix and `b` is a [n] column vector.
21[math.qr(A)](functions/qr.md) | Calculate the Matrix QR decomposition.
22[rationalize(expr)](functions/rationalize.md) | Transform a rationalizable expression in a rational fraction.
23[simplify(expr)](functions/simplify.md) | Simplify an expression tree.
24[math.slu(A, order, threshold)](functions/slu.md) | Calculate the Sparse Matrix LU decomposition with full pivoting.
25[math.usolve(U, b)](functions/usolve.md) | Finds one solution of a linear equation system by backward substitution.
26[math.usolveAll(U, b)](functions/usolveAll.md) | Finds all solutions of a linear equation system by backward substitution.
27
28## Arithmetic functions
29
30Function | Description
31---- | -----------
32[math.abs(x)](functions/abs.md) | Calculate the absolute value of a number.
33[math.add(x, y)](functions/add.md) | Add two or more values, `x + y`.
34[math.cbrt(x [, allRoots])](functions/cbrt.md) | Calculate the cubic root of a value.
35[math.ceil(x)](functions/ceil.md) | Round a value towards plus infinity If `x` is complex, both real and imaginary part are rounded towards plus infinity.
36[math.cube(x)](functions/cube.md) | Compute the cube of a value, `x * x * x`.
37[math.divide(x, y)](functions/divide.md) | Divide two values, `x / y`.
38[math.dotDivide(x, y)](functions/dotDivide.md) | Divide two matrices element wise.
39[math.dotMultiply(x, y)](functions/dotMultiply.md) | Multiply two matrices element wise.
40[math.dotPow(x, y)](functions/dotPow.md) | Calculates the power of x to y element wise.
41[math.exp(x)](functions/exp.md) | Calculate the exponent of a value.
42[math.expm1(x)](functions/expm1.md) | Calculate the value of subtracting 1 from the exponential value.
43[math.fix(x)](functions/fix.md) | Round a value towards zero.
44[math.floor(x)](functions/floor.md) | Round a value towards minus infinity.
45[math.gcd(a, b)](functions/gcd.md) | Calculate the greatest common divisor for two or more values or arrays.
46[math.hypot(a, b, ...)](functions/hypot.md) | Calculate the hypotenusa of a list with values.
47[math.lcm(a, b)](functions/lcm.md) | Calculate the least common multiple for two or more values or arrays.
48[math.log(x [, base])](functions/log.md) | Calculate the logarithm of a value.
49[math.log10(x)](functions/log10.md) | Calculate the 10-base logarithm of a value.
50[math.log1p(x)](functions/log1p.md) | Calculate the logarithm of a `value+1`.
51[math.log2(x)](functions/log2.md) | Calculate the 2-base of a value.
52[math.mod(x, y)](functions/mod.md) | Calculates the modulus, the remainder of an integer division.
53[math.multiply(x, y)](functions/multiply.md) | Multiply two or more values, `x * y`.
54[math.norm(x [, p])](functions/norm.md) | Calculate the norm of a number, vector or matrix.
55[math.nthRoot(a)](functions/nthRoot.md) | Calculate the nth root of a value.
56[math.nthRoots(x)](functions/nthRoots.md) | Calculate the nth roots of a value.
57[math.pow(x, y)](functions/pow.md) | Calculates the power of x to y, `x ^ y`.
58[math.round(x [, n])](functions/round.md) | Round a value towards the nearest integer.
59[math.sign(x)](functions/sign.md) | Compute the sign of a value.
60[math.sqrt(x)](functions/sqrt.md) | Calculate the square root of a value.
61[math.square(x)](functions/square.md) | Compute the square of a value, `x * x`.
62[math.subtract(x, y)](functions/subtract.md) | Subtract two values, `x - y`.
63[math.unaryMinus(x)](functions/unaryMinus.md) | Inverse the sign of a value, apply a unary minus operation.
64[math.unaryPlus(x)](functions/unaryPlus.md) | Unary plus operation.
65[math.xgcd(a, b)](functions/xgcd.md) | Calculate the extended greatest common divisor for two values.
66
67## Bitwise functions
68
69Function | Description
70---- | -----------
71[math.bitAnd(x, y)](functions/bitAnd.md) | Bitwise AND two values, `x & y`.
72[math.bitNot(x)](functions/bitNot.md) | Bitwise NOT value, `~x`.
73[math.bitOr(x, y)](functions/bitOr.md) | Bitwise OR two values, `x | y`.
74[math.bitXor(x, y)](functions/bitXor.md) | Bitwise XOR two values, `x ^ y`.
75[math.leftShift(x,&nbsp;y)](functions/leftShift.md) | Bitwise left logical shift of a value x by y number of bits, `x << y`.
76[math.rightArithShift(x,&nbsp;y)](functions/rightArithShift.md) | Bitwise right arithmetic shift of a value x by y number of bits, `x >> y`.
77[math.rightLogShift(x,&nbsp;y)](functions/rightLogShift.md) | Bitwise right logical shift of value x by y number of bits, `x >>> y`.
78
79## Combinatorics functions
80
81Function | Description
82---- | -----------
83[math.bellNumbers(n)](functions/bellNumbers.md) | The Bell Numbers count the number of partitions of a set.
84[math.catalan(n)](functions/catalan.md) | The Catalan Numbers enumerate combinatorial structures of many different types.
85[math.composition(n,&nbsp;k)](functions/composition.md) | The composition counts of n into k parts.
86[math.stirlingS2(n,&nbsp;k)](functions/stirlingS2.md) | 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.
87
88## Complex functions
89
90Function | Description
91---- | -----------
92[math.arg(x)](functions/arg.md) | Compute the argument of a complex value.
93[math.conj(x)](functions/conj.md) | Compute the complex conjugate of a complex value.
94[math.im(x)](functions/im.md) | Get the imaginary part of a complex number.
95[math.re(x)](functions/re.md) | Get the real part of a complex number.
96
97## Geometry functions
98
99Function | Description
100---- | -----------
101[math.distance([x1,&nbsp;y1],&nbsp;[x2,&nbsp;y2])](functions/distance.md) | Calculates: The eucledian distance between two points in N-dimensional spaces.
102[math.intersect(endPoint1Line1, endPoint2Line1, endPoint1Line2, endPoint2Line2)](functions/intersect.md) | Calculates the point of intersection of two lines in two or three dimensions and of a line and a plane in three dimensions.
103
104## Logical functions
105
106Function | Description
107---- | -----------
108[math.and(x,&nbsp;y)](functions/and.md) | Logical `and`.
109[math.not(x)](functions/not.md) | Logical `not`.
110[math.or(x,&nbsp;y)](functions/or.md) | Logical `or`.
111[math.xor(x,&nbsp;y)](functions/xor.md) | Logical `xor`.
112
113## Matrix functions
114
115Function | Description
116---- | -----------
117[math.apply(A,&nbsp;dim,&nbsp;callback)](functions/apply.md) | Apply a function that maps an array to a scalar along a given axis of a matrix or array.
118[math.column(value,&nbsp;index)](functions/column.md) | Return a column from a Matrix.
119[math.concat(a,&nbsp;b,&nbsp;c,&nbsp;...&nbsp;[,&nbsp;dim])](functions/concat.md) | Concatenate two or more matrices.
120[math.count(x)](functions/count.md) | Count the number of elements of a matrix, array or string.
121[math.cross(x,&nbsp;y)](functions/cross.md) | Calculate the cross product for two vectors in three dimensional space.
122[math.ctranspose(x)](functions/ctranspose.md) | Transpose and complex conjugate a matrix.
123[math.det(x)](functions/det.md) | Calculate the determinant of a matrix.
124[math.diag(X)](functions/diag.md) | 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.
125[math.diff(arr)](functions/diff.md) | 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.
126[math.dot(x,&nbsp;y)](functions/dot.md) | Calculate the dot product of two vectors.
127[math.eigs(x)](functions/eigs.md) | Compute eigenvalue and eigenvector of a real symmetric matrix.
128[math.expm(x)](functions/expm.md) | Compute the matrix exponential, expm(A) = e^A.
129[math.filter(x,&nbsp;test)](functions/filter.md) | Filter the items in an array or one dimensional matrix.
130[math.flatten(x)](functions/flatten.md) | Flatten a multi dimensional matrix into a single dimensional matrix.
131[math.forEach(x,&nbsp;callback)](functions/forEach.md) | Iterate over all elements of a matrix/array, and executes the given callback function.
132[math.getMatrixDataType(x)](functions/getMatrixDataType.md) | 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.
133[math.identity(n)](functions/identity.md) | Create a 2-dimensional identity matrix with size m x n or n x n.
134[math.inv(x)](functions/inv.md) | Calculate the inverse of a square matrix.
135[math.kron(x,&nbsp;y)](functions/kron.md) | Calculates the kronecker product of 2 matrices or vectors.
136[math.map(x,&nbsp;callback)](functions/map.md) | Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.
137[math.ones(m,&nbsp;n,&nbsp;p,&nbsp;...)](functions/ones.md) | Create a matrix filled with ones.
138[math.partitionSelect(x,&nbsp;k)](functions/partitionSelect.md) | Partition-based selection of an array or 1D matrix.
139[math.range(start,&nbsp;end&nbsp;[,&nbsp;step])](functions/range.md) | Create an array from a range.
140[math.reshape(x,&nbsp;sizes)](functions/reshape.md) | Reshape a multi dimensional array to fit the specified dimensions.
141[math.resize(x,&nbsp;size&nbsp;[,&nbsp;defaultValue])](functions/resize.md) | Resize a matrix.
142[math.rotate(w,&nbsp;theta)](functions/rotate.md) | 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.
143[math.rotationMatrix(theta)](functions/rotationMatrix.md) | Create a 2-dimensional counter-clockwise rotation matrix (2x2) for a given angle (expressed in radians).
144[math.row(value,&nbsp;index)](functions/row.md) | Return a row from a Matrix.
145[math.size(x)](functions/size.md) | Calculate the size of a matrix or scalar.
146[math.sort(x)](functions/sort.md) | Sort the items in a matrix.
147[X&nbsp;=&nbsp;math.sqrtm(A)](functions/sqrtm.md) | Calculate the principal square root of a square matrix.
148[math.squeeze(x)](functions/squeeze.md) | Squeeze a matrix, remove inner and outer singleton dimensions from a matrix.
149[math.subset(x,&nbsp;index&nbsp;[,&nbsp;replacement])](functions/subset.md) | Get or set a subset of a matrix or string.
150[math.trace(x)](functions/trace.md) | Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.
151[math.transpose(x)](functions/transpose.md) | Transpose a matrix.
152[math.zeros(m,&nbsp;n,&nbsp;p,&nbsp;...)](functions/zeros.md) | Create a matrix filled with zeros.
153
154## Probability functions
155
156Function | Description
157---- | -----------
158[math.combinations(n,&nbsp;k)](functions/combinations.md) | Compute the number of ways of picking `k` unordered outcomes from `n` possibilities.
159[math.combinationsWithRep(n,&nbsp;k)](functions/combinationsWithRep.md) | Compute the number of ways of picking `k` unordered outcomes from `n` possibilities, allowing individual outcomes to be repeated more than once.
160[math.factorial(n)](functions/factorial.md) | Compute the factorial of a value Factorial only supports an integer value as argument.
161[math.gamma(n)](functions/gamma.md) | Compute the gamma function of a value using Lanczos approximation for small values, and an extended Stirling approximation for large values.
162[math.kldivergence(x,&nbsp;y)](functions/kldivergence.md) | Calculate the Kullback-Leibler (KL) divergence between two distributions.
163[math.multinomial(a)](functions/multinomial.md) | Multinomial Coefficients compute the number of ways of picking a1, a2, .
164[math.permutations(n&nbsp;[,&nbsp;k])](functions/permutations.md) | Compute the number of ways of obtaining an ordered subset of `k` elements from a set of `n` elements.
165[math.pickRandom(array)](functions/pickRandom.md) | Random pick one or more values from a one dimensional array.
166[math.random([min,&nbsp;max])](functions/random.md) | Return a random number larger or equal to `min` and smaller than `max` using a uniform distribution.
167[math.randomInt([min,&nbsp;max])](functions/randomInt.md) | Return a random integer number larger or equal to `min` and smaller than `max` using a uniform distribution.
168
169## Relational functions
170
171Function | Description
172---- | -----------
173[math.compare(x,&nbsp;y)](functions/compare.md) | Compare two values.
174[math.compareNatural(x,&nbsp;y)](functions/compareNatural.md) | Compare two values of any type in a deterministic, natural way.
175[math.compareText(x,&nbsp;y)](functions/compareText.md) | Compare two strings lexically.
176[math.deepEqual(x,&nbsp;y)](functions/deepEqual.md) | Test element wise whether two matrices are equal.
177[math.equal(x,&nbsp;y)](functions/equal.md) | Test whether two values are equal.
178[math.equalText(x,&nbsp;y)](functions/equalText.md) | Check equality of two strings.
179[math.larger(x,&nbsp;y)](functions/larger.md) | Test whether value x is larger than y.
180[math.largerEq(x,&nbsp;y)](functions/largerEq.md) | Test whether value x is larger or equal to y.
181[math.smaller(x,&nbsp;y)](functions/smaller.md) | Test whether value x is smaller than y.
182[math.smallerEq(x,&nbsp;y)](functions/smallerEq.md) | Test whether value x is smaller or equal to y.
183[math.unequal(x,&nbsp;y)](functions/unequal.md) | Test whether two values are unequal.
184
185## Set functions
186
187Function | Description
188---- | -----------
189[math.setCartesian(set1,&nbsp;set2)](functions/setCartesian.md) | Create the cartesian product of two (multi)sets.
190[math.setDifference(set1,&nbsp;set2)](functions/setDifference.md) | Create the difference of two (multi)sets: every element of set1, that is not the element of set2.
191[math.setDistinct(set)](functions/setDistinct.md) | Collect the distinct elements of a multiset.
192[math.setIntersect(set1,&nbsp;set2)](functions/setIntersect.md) | Create the intersection of two (multi)sets.
193[math.setIsSubset(set1,&nbsp;set2)](functions/setIsSubset.md) | Check whether a (multi)set is a subset of another (multi)set.
194[math.setMultiplicity(element,&nbsp;set)](functions/setMultiplicity.md) | Count the multiplicity of an element in a multiset.
195[math.setPowerset(set)](functions/setPowerset.md) | Create the powerset of a (multi)set.
196[math.setSize(set)](functions/setSize.md) | Count the number of elements of a (multi)set.
197[math.setSymDifference(set1,&nbsp;set2)](functions/setSymDifference.md) | Create the symmetric difference of two (multi)sets.
198[math.setUnion(set1,&nbsp;set2)](functions/setUnion.md) | Create the union of two (multi)sets.
199
200## Special functions
201
202Function | Description
203---- | -----------
204[math.erf(x)](functions/erf.md) | Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x.
205
206## Statistics functions
207
208Function | Description
209---- | -----------
210[math.mad(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/mad.md) | Compute the median absolute deviation of a matrix or a list with values.
211[math.max(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/max.md) | Compute the maximum value of a matrix or a list with values.
212[math.mean(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/mean.md) | Compute the mean value of matrix or a list with values.
213[math.median(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/median.md) | Compute the median of a matrix or a list with values.
214[math.min(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/min.md) | Compute the minimum value of a matrix or a list of values.
215[math.mode(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/mode.md) | Computes the mode of a set of numbers or a list with values(numbers or characters).
216[math.prod(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/prod.md) | Compute the product of a matrix or a list with values.
217[math.quantileSeq(A,&nbsp;prob[,&nbsp;sorted])](functions/quantileSeq.md) | Compute the prob order quantile of a matrix or a list with values.
218[math.std(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/std.md) | Compute the standard deviation of a matrix or a list with values.
219[math.sum(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/sum.md) | Compute the sum of a matrix or a list with values.
220[math.variance(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/variance.md) | Compute the variance of a matrix or a list with values.
221
222## String functions
223
224Function | Description
225---- | -----------
226[math.bin(value)](functions/bin.md) | Format a number as binary.
227[math.format(value&nbsp;[,&nbsp;precision])](functions/format.md) | Format a value of any type into a string.
228[math.hex(value)](functions/hex.md) | Format a number as hexadecimal.
229[math.oct(value)](functions/oct.md) | Format a number as octal.
230[math.print(template, values [, precision])](functions/print.md) | Interpolate values into a string template.
231
232## Trigonometry functions
233
234Function | Description
235---- | -----------
236[math.acos(x)](functions/acos.md) | Calculate the inverse cosine of a value.
237[math.acosh(x)](functions/acosh.md) | Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.
238[math.acot(x)](functions/acot.md) | Calculate the inverse cotangent of a value, defined as `acot(x) = atan(1/x)`.
239[math.acoth(x)](functions/acoth.md) | Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = atanh(1/x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.
240[math.acsc(x)](functions/acsc.md) | Calculate the inverse cosecant of a value, defined as `acsc(x) = asin(1/x)`.
241[math.acsch(x)](functions/acsch.md) | Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = asinh(1/x) = ln(1/x + sqrt(1/x^2 + 1))`.
242[math.asec(x)](functions/asec.md) | Calculate the inverse secant of a value.
243[math.asech(x)](functions/asech.md) | Calculate the hyperbolic arcsecant of a value, defined as `asech(x) = acosh(1/x) = ln(sqrt(1/x^2 - 1) + 1/x)`.
244[math.asin(x)](functions/asin.md) | Calculate the inverse sine of a value.
245[math.asinh(x)](functions/asinh.md) | Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.
246[math.atan(x)](functions/atan.md) | Calculate the inverse tangent of a value.
247[math.atan2(y,&nbsp;x)](functions/atan2.md) | Calculate the inverse tangent function with two arguments, y/x.
248[math.atanh(x)](functions/atanh.md) | Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.
249[math.cos(x)](functions/cos.md) | Calculate the cosine of a value.
250[math.cosh(x)](functions/cosh.md) | Calculate the hyperbolic cosine of a value, defined as `cosh(x) = 1/2 * (exp(x) + exp(-x))`.
251[math.cot(x)](functions/cot.md) | Calculate the cotangent of a value.
252[math.coth(x)](functions/coth.md) | Calculate the hyperbolic cotangent of a value, defined as `coth(x) = 1 / tanh(x)`.
253[math.csc(x)](functions/csc.md) | Calculate the cosecant of a value, defined as `csc(x) = 1/sin(x)`.
254[math.csch(x)](functions/csch.md) | Calculate the hyperbolic cosecant of a value, defined as `csch(x) = 1 / sinh(x)`.
255[math.sec(x)](functions/sec.md) | Calculate the secant of a value, defined as `sec(x) = 1/cos(x)`.
256[math.sech(x)](functions/sech.md) | Calculate the hyperbolic secant of a value, defined as `sech(x) = 1 / cosh(x)`.
257[math.sin(x)](functions/sin.md) | Calculate the sine of a value.
258[math.sinh(x)](functions/sinh.md) | Calculate the hyperbolic sine of a value, defined as `sinh(x) = 1/2 * (exp(x) - exp(-x))`.
259[math.tan(x)](functions/tan.md) | Calculate the tangent of a value.
260[math.tanh(x)](functions/tanh.md) | Calculate the hyperbolic tangent of a value, defined as `tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1)`.
261
262## Unit functions
263
264Function | Description
265---- | -----------
266[math.to(x,&nbsp;unit)](functions/to.md) | Change the unit of a value.
267
268## Utils functions
269
270Function | Description
271---- | -----------
272[math.clone(x)](functions/clone.md) | Clone an object.
273[math.hasNumericValue(x)](functions/hasNumericValue.md) | Test whether a value is an numeric value.
274[math.isInteger(x)](functions/isInteger.md) | Test whether a value is an integer number.
275[math.isNaN(x)](functions/isNaN.md) | Test whether a value is NaN (not a number).
276[math.isNegative(x)](functions/isNegative.md) | Test whether a value is negative: smaller than zero.
277[math.isNumeric(x)](functions/isNumeric.md) | Test whether a value is an numeric value.
278[math.isPositive(x)](functions/isPositive.md) | Test whether a value is positive: larger than zero.
279[math.isPrime(x)](functions/isPrime.md) | Test whether a value is prime: has no divisors other than itself and one.
280[math.isZero(x)](functions/isZero.md) | Test whether a value is zero.
281[math.numeric(x)](functions/numeric.md) | Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.
282[math.typeOf(x)](functions/typeOf.md) | Determine the type of a variable.
283
284
285
286<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->