mathjs 10.4.2 → 10.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +36 -0
- package/docs/datatypes/matrices.md +17 -0
- package/docs/expressions/syntax.md +11 -4
- package/docs/reference/functions/fix.md +1 -0
- package/docs/reference/functions/floor.md +4 -0
- package/docs/reference/functions/lgamma.md +46 -0
- package/docs/reference/functions/pinv.md +44 -0
- package/docs/reference/functions/pow.md +8 -2
- package/docs/reference/functions/resolve.md +2 -2
- package/docs/reference/functions/simplifyConstant.md +52 -0
- package/docs/reference/functions/stirlingS2.md +5 -1
- package/docs/reference/functions.md +2 -0
- package/lib/browser/math.js +6 -6
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesCeil.generated.js +6 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesDet.generated.js +5 -2
- package/lib/cjs/entry/dependenciesAny/dependenciesFix.generated.js +9 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesFloor.generated.js +6 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesIndexNode.generated.js +0 -3
- package/lib/cjs/entry/dependenciesAny/dependenciesLgamma.generated.js +23 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesPinv.generated.js +53 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesPow.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesStirlingS2.generated.js +6 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +16 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesCeil.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesFix.generated.js +6 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesFloor.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesIndexNode.generated.js +0 -3
- package/lib/cjs/entry/dependenciesNumber/dependenciesLgamma.generated.js +20 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesStirlingS2.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber.generated.js +8 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +96 -95
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +11 -11
- package/lib/cjs/entry/pureFunctionsAny.generated.js +227 -196
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +36 -25
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +6 -0
- package/lib/cjs/expression/embeddedDocs/function/arithmetic/pow.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/pinv.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/probability/lgamma.js +15 -0
- package/lib/cjs/expression/node/IndexNode.js +26 -61
- package/lib/cjs/factoriesAny.js +16 -0
- package/lib/cjs/factoriesNumber.js +44 -27
- package/lib/cjs/function/algebra/resolve.js +3 -3
- package/lib/cjs/function/arithmetic/ceil.js +75 -39
- package/lib/cjs/function/arithmetic/fix.js +54 -16
- package/lib/cjs/function/arithmetic/floor.js +79 -37
- package/lib/cjs/function/arithmetic/nthRoot.js +1 -3
- package/lib/cjs/function/arithmetic/pow.js +25 -6
- package/lib/cjs/function/arithmetic/round.js +27 -47
- package/lib/cjs/function/combinatorics/stirlingS2.js +42 -12
- package/lib/cjs/function/matrix/det.js +37 -31
- package/lib/cjs/function/matrix/pinv.js +223 -0
- package/lib/cjs/function/probability/lgamma.js +146 -0
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/plain/number/arithmetic.js +17 -31
- package/lib/cjs/plain/number/probability.js +43 -3
- package/lib/cjs/type/matrix/function/sparse.js +6 -0
- package/lib/cjs/utils/latex.js +6 -0
- package/lib/cjs/utils/lruQueue.js +1 -3
- package/lib/cjs/utils/number.js +17 -2
- package/lib/cjs/utils/object.js +3 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesCeil.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesDet.generated.js +4 -2
- package/lib/esm/entry/dependenciesAny/dependenciesFix.generated.js +6 -0
- package/lib/esm/entry/dependenciesAny/dependenciesFloor.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesIndexNode.generated.js +0 -2
- package/lib/esm/entry/dependenciesAny/dependenciesLgamma.generated.js +12 -0
- package/lib/esm/entry/dependenciesAny/dependenciesPinv.generated.js +32 -0
- package/lib/esm/entry/dependenciesAny/dependenciesPow.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesStirlingS2.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesCeil.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesFix.generated.js +4 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesFloor.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesIndexNode.generated.js +0 -2
- package/lib/esm/entry/dependenciesNumber/dependenciesLgamma.generated.js +10 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesStirlingS2.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber.generated.js +1 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +90 -89
- package/lib/esm/entry/impureFunctionsNumber.generated.js +12 -12
- package/lib/esm/entry/pureFunctionsAny.generated.js +191 -162
- package/lib/esm/entry/pureFunctionsNumber.generated.js +24 -14
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +4 -0
- package/lib/esm/expression/embeddedDocs/function/arithmetic/pow.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/pinv.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/probability/lgamma.js +8 -0
- package/lib/esm/expression/node/BlockNode.js +3 -3
- package/lib/esm/expression/node/IndexNode.js +22 -59
- package/lib/esm/expression/parse.js +5 -5
- package/lib/esm/factoriesAny.js +2 -0
- package/lib/esm/factoriesNumber.js +21 -8
- package/lib/esm/function/algebra/decomposition/qr.js +2 -2
- package/lib/esm/function/algebra/resolve.js +3 -3
- package/lib/esm/function/algebra/solver/utils/solveValidation.js +5 -5
- package/lib/esm/function/algebra/sparse/csChol.js +2 -2
- package/lib/esm/function/algebra/sparse/csLeaf.js +2 -2
- package/lib/esm/function/algebra/sparse/csLu.js +3 -3
- package/lib/esm/function/arithmetic/ceil.js +61 -24
- package/lib/esm/function/arithmetic/fix.js +51 -13
- package/lib/esm/function/arithmetic/floor.js +65 -23
- package/lib/esm/function/arithmetic/nthRoot.js +1 -3
- package/lib/esm/function/arithmetic/nthRoots.js +1 -1
- package/lib/esm/function/arithmetic/pow.js +25 -6
- package/lib/esm/function/arithmetic/round.js +25 -43
- package/lib/esm/function/combinatorics/stirlingS2.js +41 -12
- package/lib/esm/function/matrix/det.js +35 -31
- package/lib/esm/function/matrix/expm.js +2 -2
- package/lib/esm/function/matrix/pinv.js +205 -0
- package/lib/esm/function/probability/gamma.js +1 -1
- package/lib/esm/function/probability/lgamma.js +137 -0
- package/lib/esm/function/string/bin.js +1 -1
- package/lib/esm/function/string/hex.js +1 -1
- package/lib/esm/function/string/oct.js +1 -1
- package/lib/esm/plain/number/arithmetic.js +16 -20
- package/lib/esm/plain/number/probability.js +33 -1
- package/lib/esm/type/complex/Complex.js +2 -2
- package/lib/esm/type/matrix/DenseMatrix.js +2 -2
- package/lib/esm/type/matrix/FibonacciHeap.js +2 -2
- package/lib/esm/type/matrix/SparseMatrix.js +13 -13
- package/lib/esm/type/matrix/function/sparse.js +6 -0
- package/lib/esm/type/unit/Unit.js +7 -7
- package/lib/esm/utils/latex.js +6 -0
- package/lib/esm/utils/lruQueue.js +1 -2
- package/lib/esm/utils/number.js +16 -4
- package/lib/esm/utils/object.js +3 -1
- package/lib/esm/version.js +1 -1
- package/package.json +20 -9
- package/types/index.d.ts +1806 -1363
- package/types/index.ts +705 -264
package/HISTORY.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# History
|
|
2
2
|
|
|
3
|
+
# 2022-05-02 version 10.5.1
|
|
4
|
+
|
|
5
|
+
- Fix #2526, #2529: improve TypeScript definitions of function `round`, `fix`,
|
|
6
|
+
`floor`, `ceil`, and `nthRoot`, and improved the number only implementations
|
|
7
|
+
of those functions (#2531, #2539). Thanks @simlaticak and @gwhitney.
|
|
8
|
+
- Fix #2532: matrix index symbol `end` not working when used inside
|
|
9
|
+
a sub-expression.
|
|
10
|
+
- Fix #2524: In generating AUTHORS list, ignore a list of specific commits
|
|
11
|
+
(e.g., to avoid spurious duplicates in list). (#2543)
|
|
12
|
+
- Add type definitions of function `resolve` (#2536). Thanks @mattvague.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# 2022-04-19, version 10.5.0
|
|
16
|
+
|
|
17
|
+
- Implement #1563: function `pinv`, Moore–Penrose inverse (#2521).
|
|
18
|
+
Thanks @HanchaiN.
|
|
19
|
+
- Optimize function `det` for integers by switching to the Bareiss algorithm:
|
|
20
|
+
no more round-off errors for integer input (#2516). Thanks @HanchaiN.
|
|
21
|
+
- Implement #2463: allow negative integer powers of invertible square matrices
|
|
22
|
+
(#2517). Thanks @HanchaiN.
|
|
23
|
+
- Implement the `lgamma` function (defined as log(gamma(z))) for number and
|
|
24
|
+
Complex types. Supersedes #320. (#2417). Thanks @yifanwww.
|
|
25
|
+
- Fix #2523: update to the latest complex.js to improve `sin(z)` for small
|
|
26
|
+
`im(z)` (#2525). Thanks @gwhitney.
|
|
27
|
+
- Fix #2526: update TypeScript definition of `ceil` (#2531). Thanks @simlaticak
|
|
28
|
+
- Change mocha reporter to 'dot' to avoid excessively long log files. (#2520)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# 2022-04-08, version 10.4.3
|
|
32
|
+
|
|
33
|
+
- Fix #2508: improve the precision of stirlingS2 (#2509). Thanks @gwhitney.
|
|
34
|
+
- Fix #2514: implement optional argument `base` in the number implementation
|
|
35
|
+
of function `log` (#2515). Thanks @gwhitney.
|
|
36
|
+
- Improve the documentation on operator `;` (#2512). Thanks @gwhitney.
|
|
37
|
+
|
|
38
|
+
|
|
3
39
|
# 2022-03-29, version 10.4.2
|
|
4
40
|
|
|
5
41
|
- Fix #2499: different behavior for unit conversion "degC" and "K" (#2501).
|
|
@@ -342,6 +342,23 @@ const m1 = math.matrix([[0, 1], [0, 0]], 'sparse')
|
|
|
342
342
|
const m2 = math.identity(1000, 1000, 'sparse')
|
|
343
343
|
```
|
|
344
344
|
|
|
345
|
+
You can also coerce an array or matrix into sparse storage format with the
|
|
346
|
+
`sparse` function.
|
|
347
|
+
```js
|
|
348
|
+
const md = math.matrix([[0, 1], [0,0]]) // dense
|
|
349
|
+
const ms = math.sparse(md) // sparse
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Caution: `sparse` called on a JavaScript array of _n_ plain numbers produces
|
|
353
|
+
a matrix with one column and _n_ rows -- in contrast to `matrix`, which
|
|
354
|
+
produces a 1-dimensional matrix object with _n_ entries, i.e., a vector
|
|
355
|
+
(_not_ a 1 by _n_ "row vector" nor an _n_ by 1 "column vector", but just a plain
|
|
356
|
+
vector of length _n_).
|
|
357
|
+
```js
|
|
358
|
+
const mv = math.matrix([0, 0, 1]) // Has size [3]
|
|
359
|
+
const mc = math.sparse([0, 0, 1]) // A "column vector," has size [3, 1]
|
|
360
|
+
```
|
|
361
|
+
|
|
345
362
|
## API
|
|
346
363
|
|
|
347
364
|
All relevant functions in math.js support Matrices and Arrays. Functions like `math.add` and `math.subtract`, `math.sqrt` handle matrices element wise. There is a set of functions specifically for creating or manipulating matrices, such as:
|
|
@@ -24,7 +24,11 @@ the lower level syntax of math.js. Differences are:
|
|
|
24
24
|
not bitwise xor.
|
|
25
25
|
- Implicit multiplication, like `2 pi`, is supported and has special rules.
|
|
26
26
|
- Relational operators (`<`, `>`, `<=`, `>=`, `==`, and `!=`) are chained, so the expression `5 < x < 10` is equivalent to `5 < x and x < 10`.
|
|
27
|
-
|
|
27
|
+
- Multi-expression constructs like `a = 1; b = 2; a + b` or
|
|
28
|
+
`"a = 1;\n cos(a)\n sin(a)"` (where `\n` denotes newline)
|
|
29
|
+
produce a collection ("ResultSet") of values. Those expressions
|
|
30
|
+
terminated by `;` are evaluated for side effect only and their values
|
|
31
|
+
are suppressed from the result.
|
|
28
32
|
|
|
29
33
|
## Operators
|
|
30
34
|
|
|
@@ -545,8 +549,11 @@ can be replaced by using indexes. Indexes are enclosed in square brackets, and
|
|
|
545
549
|
contain a number or a range for each of the matrix dimensions. A range can have
|
|
546
550
|
its start and/or end undefined. When the start is undefined, the range will start
|
|
547
551
|
at 1, when the end is undefined, the range will end at the end of the matrix.
|
|
552
|
+
|
|
548
553
|
There is a context variable `end` available as well to denote the end of the
|
|
549
|
-
matrix.
|
|
554
|
+
matrix. This variable cannot be used in multiple nested indices. In that case,
|
|
555
|
+
`end` will be resolved as the end of the innermost matrix. To solve this,
|
|
556
|
+
resolving of the nested index needs to be split in two separate operations.
|
|
550
557
|
|
|
551
558
|
*IMPORTANT: matrix indexes and ranges work differently from the math.js indexes
|
|
552
559
|
in JavaScript: They are one-based with an included upper-bound, similar to most
|
|
@@ -651,7 +658,7 @@ Parentheses are parsed as a function call when there is a symbol or accessor on
|
|
|
651
658
|
the left hand side, like `sqrt(4)` or `obj.method(4)`. In other cases the
|
|
652
659
|
parentheses are interpreted as an implicit multiplication.
|
|
653
660
|
|
|
654
|
-
Math.js will always evaluate implicit multiplication before explicit multiplication `*`, so that the expression `x * y z` is parsed as `x * (y * z)`. Math.js also gives implicit multiplication higher precedence than division, *except* when the division matches the pattern `[number] / [number] [symbol]` or `[number] / [number] [left paren]`. In that special case, the division is evaluated first:
|
|
661
|
+
Math.js will always evaluate implicit multiplication before explicit multiplication `*`, so that the expression `x * y z` is parsed as `x * (y * z)`. Math.js also gives implicit multiplication higher precedence than division, *except* when the division matches the pattern `[unaryPrefixOp]?[number] / [number] [symbol]` or `[unaryPrefixOp]?[number] / [number] [left paren]`. In that special case, the division is evaluated first:
|
|
655
662
|
|
|
656
663
|
```js
|
|
657
664
|
math.evaluate('20 kg / 4 kg') // 5 Evaluated as (20 kg) / (4 kg)
|
|
@@ -661,7 +668,7 @@ math.evaluate('20 / 4 kg') // 5 kg Evaluated as (20 / 4) kg
|
|
|
661
668
|
The behavior of implicit multiplication can be summarized by these operator precedence rules, listed from highest to lowest precedence:
|
|
662
669
|
|
|
663
670
|
- Function calls: `[symbol] [left paren]`
|
|
664
|
-
- Explicit division `/` when the division matches this pattern: `[number] / [number] [symbol]` or `[number] / [number] [left paren]`
|
|
671
|
+
- Explicit division `/` when the division matches this pattern: `[+-~]?[number] / [+-~]?[number] [symbol]` or `[number] / [number] [left paren]`
|
|
665
672
|
- Implicit multiplication
|
|
666
673
|
- All other division `/` and multiplication `*`
|
|
667
674
|
|
|
@@ -52,6 +52,10 @@ math.floor(c, 1) // returns Complex 3.2 - 2.8i
|
|
|
52
52
|
|
|
53
53
|
math.floor([3.2, 3.8, -4.7]) // returns Array [3, 3, -5]
|
|
54
54
|
math.floor([3.21, 3.82, -4.71], 1) // returns Array [3.2, 3.8, -4.8]
|
|
55
|
+
|
|
56
|
+
math.floor(math.tau, [2, 3]) // returns Array [6.28, 6.283]
|
|
57
|
+
|
|
58
|
+
// Note that floor(array, array) currently not implemented.
|
|
55
59
|
```
|
|
56
60
|
|
|
57
61
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
|
2
|
+
|
|
3
|
+
# Function lgamma
|
|
4
|
+
|
|
5
|
+
Logarithm of the gamma function for real, positive numbers and complex numbers,
|
|
6
|
+
using Lanczos approximation for numbers and Stirling series for complex numbers.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
math.lgamma(n)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Parameters
|
|
16
|
+
|
|
17
|
+
Parameter | Type | Description
|
|
18
|
+
--------- | ---- | -----------
|
|
19
|
+
`n` | number | Complex | A real or complex number
|
|
20
|
+
|
|
21
|
+
### Returns
|
|
22
|
+
|
|
23
|
+
Type | Description
|
|
24
|
+
---- | -----------
|
|
25
|
+
number | Complex | The log gamma of `n`
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Throws
|
|
29
|
+
|
|
30
|
+
Type | Description
|
|
31
|
+
---- | -----------
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
math.lgamma(5) // returns 3.178053830347945
|
|
38
|
+
math.lgamma(0) // returns Infinity
|
|
39
|
+
math.lgamma(-0.5) // returns NaN
|
|
40
|
+
math.lgamma(math.i) // returns -0.6509231993018536 - 1.8724366472624294i
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## See also
|
|
45
|
+
|
|
46
|
+
[gamma](gamma.md)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
|
2
|
+
|
|
3
|
+
# Function pinv
|
|
4
|
+
|
|
5
|
+
Calculate the Moore–Penrose inverse of a matrix.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Syntax
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
math.pinv(x)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Parameters
|
|
15
|
+
|
|
16
|
+
Parameter | Type | Description
|
|
17
|
+
--------- | ---- | -----------
|
|
18
|
+
`x` | number | Complex | Array | Matrix | Matrix to be inversed
|
|
19
|
+
|
|
20
|
+
### Returns
|
|
21
|
+
|
|
22
|
+
Type | Description
|
|
23
|
+
---- | -----------
|
|
24
|
+
number | Complex | Array | Matrix | The inverse of `x`.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Throws
|
|
28
|
+
|
|
29
|
+
Type | Description
|
|
30
|
+
---- | -----------
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
math.pinv([[1, 2], [3, 4]]) // returns [[-2, 1], [1.5, -0.5]]
|
|
37
|
+
math.pinv([[1, 0], [0, 1], [0, 1]]) // returns [[1, 0, 0], [0, 0.5, 0.5]]
|
|
38
|
+
math.pinv(4) // returns 0.25
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## See also
|
|
43
|
+
|
|
44
|
+
[inv](inv.md)
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
# Function pow
|
|
4
4
|
|
|
5
5
|
Calculates the power of x to y, `x ^ y`.
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
Matrix exponentiation is supported for square matrices `x` and integers `y`:
|
|
8
|
+
when `y` is nonnegative, `x` may be any square matrix; and when `y` is
|
|
9
|
+
negative, `x` must be invertible, and then this function returns
|
|
10
|
+
inv(x)^(-y).
|
|
8
11
|
|
|
9
12
|
For cubic roots of negative numbers, the function returns the principal
|
|
10
13
|
root by default. In order to let the function return the real root,
|
|
@@ -48,6 +51,9 @@ math.pow(a, 2) // returns Complex -5 + 12i
|
|
|
48
51
|
|
|
49
52
|
const b = [[1, 2], [4, 3]]
|
|
50
53
|
math.pow(b, 2) // returns Array [[9, 8], [16, 17]]
|
|
54
|
+
|
|
55
|
+
const c = [[1, 2], [4, 3]]
|
|
56
|
+
math.pow(c, -1) // returns Array [[-0.6, 0.4], [0.8, -0.2]]
|
|
51
57
|
```
|
|
52
58
|
|
|
53
59
|
|
|
@@ -15,14 +15,14 @@ resolve(expr, scope)
|
|
|
15
15
|
|
|
16
16
|
Parameter | Type | Description
|
|
17
17
|
--------- | ---- | -----------
|
|
18
|
-
`node` | Node | The expression tree to be simplified
|
|
18
|
+
`node` | Node | Node[] | The expression tree (or trees) to be simplified
|
|
19
19
|
`scope` | Object | Scope specifying variables to be resolved
|
|
20
20
|
|
|
21
21
|
### Returns
|
|
22
22
|
|
|
23
23
|
Type | Description
|
|
24
24
|
---- | -----------
|
|
25
|
-
Node | Returns `node` with variables recursively substituted.
|
|
25
|
+
Node | Node[] | Returns `node` with variables recursively substituted.
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
### Throws
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
|
2
|
+
|
|
3
|
+
# Function simplifyConstant
|
|
4
|
+
|
|
5
|
+
simplifyConstant() takes a mathjs expression (either a Node representing
|
|
6
|
+
a parse tree or a string which it parses to produce a node), and replaces
|
|
7
|
+
any subexpression of it consisting entirely of constants with the computed
|
|
8
|
+
value of that subexpression.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Syntax
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
simplifyConstant(expr)
|
|
15
|
+
simplifyConstant(expr, options)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Parameters
|
|
19
|
+
|
|
20
|
+
Parameter | Type | Description
|
|
21
|
+
--------- | ---- | -----------
|
|
22
|
+
`node` | Node | string | The expression to be simplified
|
|
23
|
+
`options` | Object | Simplification options, as per simplify()
|
|
24
|
+
|
|
25
|
+
### Returns
|
|
26
|
+
|
|
27
|
+
Type | Description
|
|
28
|
+
---- | -----------
|
|
29
|
+
Node | Returns expression with constant subexpressions evaluated
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Throws
|
|
33
|
+
|
|
34
|
+
Type | Description
|
|
35
|
+
---- | -----------
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
math.simplifyConstant('x + 4*3/6') // Node "x + 2"
|
|
42
|
+
math.simplifyConstant('z cos(0)') // Node "z 1"
|
|
43
|
+
math.simplifyConstant('(5.2 + 1.08)t', {exactFractions: false}) // Node "6.28 t"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## See also
|
|
48
|
+
|
|
49
|
+
[simplify](simplify.md),
|
|
50
|
+
[simplifyCore](simplifyCore.md),
|
|
51
|
+
[resolve](resolve.md),
|
|
52
|
+
[derivative](derivative.md)
|
|
@@ -7,7 +7,11 @@ a set of n labelled objects into k nonempty unlabelled subsets.
|
|
|
7
7
|
stirlingS2 only takes integer arguments.
|
|
8
8
|
The following condition must be enforced: k <= n.
|
|
9
9
|
|
|
10
|
-
If n = k or k = 1, then s(n,k) = 1
|
|
10
|
+
If n = k or k = 1 <= n, then s(n,k) = 1
|
|
11
|
+
If k = 0 < n, then s(n,k) = 0
|
|
12
|
+
|
|
13
|
+
Note that if either n or k is supplied as a BigNumber, the result will be
|
|
14
|
+
as well.
|
|
11
15
|
|
|
12
16
|
|
|
13
17
|
## Syntax
|
|
@@ -144,6 +144,7 @@ Function | Description
|
|
|
144
144
|
[math.matrixFromRows(...arr)](functions/matrixFromRows.md) | Create a dense matrix from vectors as individual rows.
|
|
145
145
|
[math.ones(m, n, p, ...)](functions/ones.md) | Create a matrix filled with ones.
|
|
146
146
|
[math.partitionSelect(x, k)](functions/partitionSelect.md) | Partition-based selection of an array or 1D matrix.
|
|
147
|
+
[math.pinv(x)](functions/pinv.md) | Calculate the Moore–Penrose inverse of a matrix.
|
|
147
148
|
[math.range(start, end [, step])](functions/range.md) | Create an array from a range.
|
|
148
149
|
[math.reshape(x, sizes)](functions/reshape.md) | Reshape a multi dimensional array to fit the specified dimensions.
|
|
149
150
|
[math.resize(x, size [, defaultValue])](functions/resize.md) | Resize a matrix.
|
|
@@ -168,6 +169,7 @@ Function | Description
|
|
|
168
169
|
[math.factorial(n)](functions/factorial.md) | Compute the factorial of a value Factorial only supports an integer value as argument.
|
|
169
170
|
[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.
|
|
170
171
|
[math.kldivergence(x, y)](functions/kldivergence.md) | Calculate the Kullback-Leibler (KL) divergence between two distributions.
|
|
172
|
+
[math.lgamma(n)](functions/lgamma.md) | Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.
|
|
171
173
|
[math.multinomial(a)](functions/multinomial.md) | Multinomial Coefficients compute the number of ways of picking a1, a2, .
|
|
172
174
|
[math.permutations(n [, k])](functions/permutations.md) | Compute the number of ways of obtaining an ordered subset of `k` elements from a set of `n` elements.
|
|
173
175
|
[math.pickRandom(array)](functions/pickRandom.md) | Random pick one or more values from a one dimensional array.
|