mathjs 9.5.0 → 10.0.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 +33 -0
- package/bin/cli.js +0 -0
- package/docs/reference/functions/format.md +5 -2
- package/docs/reference/functions/parser.md +4 -4
- package/examples/expressions.js +1 -1
- package/lib/browser/math.js +5 -5
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/constants.js +1 -1
- package/lib/cjs/core/function/config.js +1 -1
- package/lib/cjs/core/function/import.js +2 -1
- package/lib/cjs/entry/dependenciesAny.generated.js +999 -999
- package/lib/cjs/entry/dependenciesNumber.generated.js +581 -581
- package/lib/cjs/entry/impureFunctionsAny.generated.js +314 -313
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +223 -222
- package/lib/cjs/entry/mainAny.js +8 -8
- package/lib/cjs/entry/mainNumber.js +8 -8
- package/lib/cjs/entry/pureFunctionsAny.generated.js +1100 -1100
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +375 -375
- package/lib/cjs/entry/typeChecks.js +12 -12
- package/lib/cjs/expression/Parser.js +1 -1
- package/lib/cjs/expression/function/parser.js +4 -4
- package/lib/cjs/expression/operators.js +1 -1
- package/lib/cjs/factoriesAny.js +660 -660
- package/lib/cjs/factoriesNumber.js +268 -237
- package/lib/cjs/function/probability/gamma.js +28 -30
- package/lib/cjs/function/string/format.js +5 -2
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/plain/bignumber/arithmetic.js +2 -2
- package/lib/cjs/plain/number/arithmetic.js +10 -10
- package/lib/cjs/plain/number/constants.js +1 -1
- package/lib/cjs/plain/number/logical.js +1 -1
- package/lib/cjs/plain/number/probability.js +2 -1
- package/lib/cjs/plain/number/trigonometry.js +1 -1
- package/lib/cjs/plain/number/utils.js +1 -1
- package/lib/cjs/type/unit/physicalConstants.js +1 -1
- package/lib/cjs/utils/array.js +14 -14
- package/lib/cjs/utils/bignumber/bitwise.js +1 -1
- package/lib/cjs/utils/customs.js +5 -5
- package/lib/cjs/utils/factory.js +3 -3
- package/lib/cjs/utils/function.js +1 -1
- package/lib/cjs/utils/is.js +23 -23
- package/lib/cjs/utils/latex.js +2 -1
- package/lib/cjs/utils/map.js +3 -3
- package/lib/cjs/utils/noop.js +1 -1
- package/lib/cjs/utils/number.js +10 -6
- package/lib/cjs/utils/object.js +8 -8
- package/lib/cjs/utils/snapshot.js +1 -1
- package/lib/cjs/utils/string.js +2 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/function/import.js +2 -1
- package/lib/esm/entry/dependenciesAny.generated.js +270 -270
- package/lib/esm/entry/dependenciesNumber.generated.js +163 -163
- package/lib/esm/entry/impureFunctionsAny.generated.js +301 -301
- package/lib/esm/entry/impureFunctionsNumber.generated.js +211 -211
- package/lib/esm/entry/pureFunctionsAny.generated.js +816 -816
- package/lib/esm/entry/pureFunctionsNumber.generated.js +234 -234
- package/lib/esm/expression/Parser.js +1 -1
- package/lib/esm/expression/function/parser.js +4 -4
- package/lib/esm/function/probability/gamma.js +28 -30
- package/lib/esm/function/string/format.js +5 -2
- package/lib/esm/version.js +1 -1
- package/package.json +16 -16
- package/types/index.d.ts +273 -69
@@ -37,7 +37,7 @@ export var createParserClass = /* #__PURE__ */factory(name, dependencies, _ref =
|
|
37
37
|
* // define variables and functions
|
38
38
|
* parser.evaluate('x = 7 / 2') // 3.5
|
39
39
|
* parser.evaluate('x + 3') // 6.5
|
40
|
-
* parser.evaluate('
|
40
|
+
* parser.evaluate('f(x, y) = x^y') // f(x, y)
|
41
41
|
* parser.evaluate('f(2, 3)') // 8
|
42
42
|
*
|
43
43
|
* // get and set variables and functions
|
@@ -25,10 +25,10 @@ export var createParser = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
25
25
|
* const d = parser.evaluate('cos(45 deg)') // 0.7071067811865476
|
26
26
|
*
|
27
27
|
* // define variables and functions
|
28
|
-
* parser.evaluate('x = 7 / 2')
|
29
|
-
* parser.evaluate('x + 3')
|
30
|
-
* parser.evaluate('
|
31
|
-
* parser.evaluate('f(2, 3)')
|
28
|
+
* parser.evaluate('x = 7 / 2') // 3.5
|
29
|
+
* parser.evaluate('x + 3') // 6.5
|
30
|
+
* parser.evaluate('f(x, y) = x^y') // f(x, y)
|
31
|
+
* parser.evaluate('f(2, 3)') // 8
|
32
32
|
*
|
33
33
|
* // get and set variables and functions
|
34
34
|
* const x = parser.get('x') // 7
|
@@ -41,44 +41,42 @@ export var createGamma = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
41
41
|
Complex: function Complex(n) {
|
42
42
|
if (n.im === 0) {
|
43
43
|
return this(n.re);
|
44
|
-
}
|
44
|
+
} // Lanczos approximation doesn't work well with real part lower than 0.5
|
45
|
+
// So reflection formula is required
|
46
|
+
|
47
|
+
|
48
|
+
if (n.re < 0.5) {
|
49
|
+
// Euler's reflection formula
|
50
|
+
// gamma(1-z) * gamma(z) = PI / sin(PI * z)
|
51
|
+
// real part of Z should not be integer [sin(PI) == 0 -> 1/0 - undefined]
|
52
|
+
// thanks to imperfect sin implementation sin(PI * n) != 0
|
53
|
+
// we can safely use it anyway
|
54
|
+
var _t = new _Complex(1 - n.re, -n.im);
|
55
|
+
|
56
|
+
var r = new _Complex(Math.PI * n.re, Math.PI * n.im);
|
57
|
+
return new _Complex(Math.PI).div(r.sin()).div(this(_t));
|
58
|
+
} // Lanczos approximation
|
59
|
+
// z -= 1
|
60
|
+
|
45
61
|
|
46
|
-
n = new _Complex(n.re - 1, n.im);
|
47
|
-
|
62
|
+
n = new _Complex(n.re - 1, n.im); // x = gammaPval[0]
|
63
|
+
|
64
|
+
var x = new _Complex(gammaP[0], 0); // for (i, gammaPval) in enumerate(gammaP):
|
48
65
|
|
49
66
|
for (var i = 1; i < gammaP.length; ++i) {
|
50
|
-
|
67
|
+
// x += gammaPval / (z + i)
|
68
|
+
var gammaPval = new _Complex(gammaP[i], 0);
|
69
|
+
x = x.add(gammaPval.div(n.add(i)));
|
70
|
+
} // t = z + gammaG + 0.5
|
51
71
|
|
52
|
-
var den = real * real + n.im * n.im;
|
53
72
|
|
54
|
-
|
55
|
-
x.re += gammaP[i] * real / den;
|
56
|
-
x.im += -(gammaP[i] * n.im) / den;
|
57
|
-
} else {
|
58
|
-
x.re = gammaP[i] < 0 ? -Infinity : Infinity;
|
59
|
-
}
|
60
|
-
}
|
73
|
+
var t = new _Complex(n.re + gammaG + 0.5, n.im); // y = sqrt(2 * pi) * t ** (z + 0.5) * exp(-t) * x
|
61
74
|
|
62
|
-
var t = new _Complex(n.re + gammaG + 0.5, n.im);
|
63
75
|
var twoPiSqrt = Math.sqrt(2 * Math.PI);
|
64
|
-
n.
|
65
|
-
var
|
66
|
-
|
67
|
-
if (result.im === 0) {
|
68
|
-
// sqrt(2*PI)*result
|
69
|
-
result.re *= twoPiSqrt;
|
70
|
-
} else if (result.re === 0) {
|
71
|
-
result.im *= twoPiSqrt;
|
72
|
-
} else {
|
73
|
-
result.re *= twoPiSqrt;
|
74
|
-
result.im *= twoPiSqrt;
|
75
|
-
}
|
76
|
-
|
77
|
-
var r = Math.exp(-t.re); // exp(-t)
|
76
|
+
var tpow = t.pow(n.add(0.5));
|
77
|
+
var expt = t.neg().exp(); // y = [x] * [sqrt(2 * pi)] * [t ** (z + 0.5)] * [exp(-t)]
|
78
78
|
|
79
|
-
|
80
|
-
t.im = r * Math.sin(-t.im);
|
81
|
-
return multiplyScalar(multiplyScalar(result, t), x);
|
79
|
+
return x.mul(twoPiSqrt).mul(tpow).mul(expt);
|
82
80
|
},
|
83
81
|
BigNumber: function BigNumber(n) {
|
84
82
|
if (n.isInteger()) {
|
@@ -52,8 +52,11 @@ export var createFormat = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
52
52
|
* For example format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'.
|
53
53
|
* Default value is undefined.
|
54
54
|
* - `precision: number`
|
55
|
-
*
|
56
|
-
*
|
55
|
+
* Limit the number of digits of the formatted value.
|
56
|
+
* For regular numbers, must be a number between 0 and 16.
|
57
|
+
* For bignumbers, the maximum depends on the configured precision,
|
58
|
+
* see function `config()`.
|
59
|
+
* In case of notations 'exponential', 'engineering', and 'auto', `precision`
|
57
60
|
* defines the total number of significant digits returned.
|
58
61
|
* In case of notation 'fixed', `precision` defines the number of
|
59
62
|
* significant digits after the decimal point.
|
package/lib/esm/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export var version = '
|
1
|
+
export var version = '10.0.1'; // Note: This file is automatically generated when building math.js.
|
2
2
|
// Changes made in this file will be overwritten.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mathjs",
|
3
|
-
"version": "
|
3
|
+
"version": "10.0.1",
|
4
4
|
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
|
5
5
|
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
|
6
6
|
"homepage": "https://mathjs.org",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"unit"
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
|
-
"@babel/runtime": "^7.
|
28
|
+
"@babel/runtime": "^7.16.0",
|
29
29
|
"complex.js": "^2.0.15",
|
30
30
|
"decimal.js": "^10.3.1",
|
31
31
|
"escape-latex": "^1.2.0",
|
@@ -36,28 +36,28 @@
|
|
36
36
|
"typed-function": "^2.0.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@babel/core": "7.
|
40
|
-
"@babel/plugin-transform-object-assign": "7.
|
41
|
-
"@babel/plugin-transform-runtime": "7.
|
42
|
-
"@babel/preset-env": "7.
|
43
|
-
"@babel/register": "7.
|
44
|
-
"babel-loader": "8.2.
|
39
|
+
"@babel/core": "7.16.0",
|
40
|
+
"@babel/plugin-transform-object-assign": "7.16.0",
|
41
|
+
"@babel/plugin-transform-runtime": "7.16.0",
|
42
|
+
"@babel/preset-env": "7.16.0",
|
43
|
+
"@babel/register": "7.16.0",
|
44
|
+
"babel-loader": "8.2.3",
|
45
45
|
"benchmark": "2.1.4",
|
46
46
|
"codecov": "3.8.3",
|
47
|
-
"core-js": "3.
|
47
|
+
"core-js": "3.19.1",
|
48
48
|
"del": "6.0.0",
|
49
|
-
"dtslint": "4.
|
49
|
+
"dtslint": "4.2.0",
|
50
50
|
"expr-eval": "2.0.2",
|
51
51
|
"fancy-log": "1.3.3",
|
52
|
-
"glob": "7.
|
52
|
+
"glob": "7.2.0",
|
53
53
|
"gulp": "4.0.2",
|
54
54
|
"gulp-babel": "8.0.0",
|
55
55
|
"handlebars": "4.7.7",
|
56
56
|
"istanbul": "0.4.5",
|
57
|
-
"jsep": "1.0
|
58
|
-
"karma": "6.3.
|
57
|
+
"jsep": "1.2.0",
|
58
|
+
"karma": "6.3.7",
|
59
59
|
"karma-browserstack-launcher": "1.6.0",
|
60
|
-
"karma-firefox-launcher": "2.1.
|
60
|
+
"karma-firefox-launcher": "2.1.2",
|
61
61
|
"karma-mocha": "2.0.1",
|
62
62
|
"karma-mocha-reporter": "2.2.5",
|
63
63
|
"karma-webpack": "4.0.2",
|
@@ -72,9 +72,9 @@
|
|
72
72
|
"numericjs": "1.2.6",
|
73
73
|
"nyc": "15.1.0",
|
74
74
|
"pad-right": "0.2.2",
|
75
|
-
"standard": "16.0.
|
75
|
+
"standard": "16.0.4",
|
76
76
|
"sylvester": "0.0.21",
|
77
|
-
"typescript": "4.4.
|
77
|
+
"typescript": "4.4.4",
|
78
78
|
"webpack": "4.46.0",
|
79
79
|
"zeros": "1.0.0"
|
80
80
|
},
|