mathjs 10.0.0 → 10.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +37 -0
- package/NOTICE +1 -1
- package/README.md +10 -2
- package/bin/cli.js +1 -1
- package/docs/expressions/syntax.md +1 -1
- package/docs/reference/constants.md +1 -1
- package/docs/reference/functions/invmod.md +41 -0
- package/docs/reference/functions/simplify.md +8 -5
- package/docs/reference/functions.md +1 -0
- package/examples/expressions.js +1 -1
- package/lib/browser/math.js +7 -7
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesIntersect.generated.js +6 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesInvmod.generated.js +41 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesRationalize.generated.js +15 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplify.generated.js +15 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +8 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesRationalize.generated.js +15 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplify.generated.js +15 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +11 -0
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +10 -0
- package/lib/cjs/entry/pureFunctionsAny.generated.js +16 -2
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +6 -1
- package/lib/cjs/expression/embeddedDocs/function/arithmetic/invmod.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/matrix/forEach.js +1 -1
- package/lib/cjs/factoriesAny.js +8 -0
- package/lib/cjs/function/algebra/rationalize.js +18 -4
- package/lib/cjs/function/algebra/simplify/simplifyConstant.js +223 -29
- package/lib/cjs/function/algebra/simplify/simplifyCore.js +34 -6
- package/lib/cjs/function/algebra/simplify.js +103 -30
- package/lib/cjs/function/arithmetic/invmod.js +73 -0
- package/lib/cjs/function/arithmetic/round.js +2 -2
- package/lib/cjs/function/geometry/intersect.js +12 -13
- package/lib/cjs/function/probability/gamma.js +28 -30
- package/lib/cjs/header.js +3 -3
- package/lib/cjs/type/matrix/SparseMatrix.js +19 -15
- package/lib/cjs/type/unit/Unit.js +2 -2
- package/lib/cjs/utils/number.js +1 -1
- package/lib/cjs/utils/snapshot.js +2 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesIntersect.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesInvmod.generated.js +24 -0
- package/lib/esm/entry/dependenciesAny/dependenciesRationalize.generated.js +10 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplify.generated.js +10 -0
- package/lib/esm/entry/dependenciesAny.generated.js +1 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesRationalize.generated.js +10 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplify.generated.js +10 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +12 -1
- package/lib/esm/entry/impureFunctionsNumber.generated.js +10 -0
- package/lib/esm/entry/pureFunctionsAny.generated.js +14 -1
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +4 -1
- package/lib/esm/expression/embeddedDocs/function/arithmetic/invmod.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/matrix/forEach.js +1 -1
- package/lib/esm/factoriesAny.js +1 -0
- package/lib/esm/function/algebra/rationalize.js +18 -4
- package/lib/esm/function/algebra/simplify/simplifyConstant.js +197 -29
- package/lib/esm/function/algebra/simplify/simplifyCore.js +35 -7
- package/lib/esm/function/algebra/simplify.js +103 -30
- package/lib/esm/function/arithmetic/invmod.js +57 -0
- package/lib/esm/function/arithmetic/round.js +2 -2
- package/lib/esm/function/geometry/intersect.js +12 -12
- package/lib/esm/function/probability/gamma.js +28 -30
- package/lib/esm/header.js +1 -1
- package/lib/esm/type/matrix/SparseMatrix.js +19 -15
- package/lib/esm/type/unit/Unit.js +2 -2
- package/lib/esm/utils/number.js +1 -1
- package/lib/esm/utils/snapshot.js +2 -2
- package/lib/esm/version.js +1 -1
- package/package.json +15 -14
- package/types/index.d.ts +4 -4
package/HISTORY.md
CHANGED
@@ -1,5 +1,42 @@
|
|
1
1
|
# History
|
2
2
|
|
3
|
+
# 2022-02-02, version 10.1.1
|
4
|
+
|
5
|
+
- Improvements and fixes in function `simplify`, thanks @gwhitney:
|
6
|
+
- Fix #2393: regression bug in `simplify('2-(x+1)')`.
|
7
|
+
- Ad option `consoleDebug` to `simplify` to see what is going on.
|
8
|
+
- Fix TypeScript definition of `ConfigOptions`, which was missing option
|
9
|
+
`predictable`.
|
10
|
+
|
11
|
+
|
12
|
+
# 2022-01-15, version 10.1.0
|
13
|
+
|
14
|
+
- Implemented function `invmod`, see #2368, #1744. Thanks @thetazero.
|
15
|
+
- Improvements and fixes in function `simplify`, thanks @gwhitney:
|
16
|
+
- Fix #1179, #1290: improve collection of non-constant like terms (#2384).
|
17
|
+
- Fix #2152: do not transform strings into numbers (#2372).
|
18
|
+
- Fix #1913: implement support for array and object simplification (#2382).
|
19
|
+
- Fix #2379: add embedded documentation for function `print`.
|
20
|
+
- Remove broken example from the embedded documentation of function `forEach`.
|
21
|
+
|
22
|
+
|
23
|
+
# 2021-12-29, version 10.0.2
|
24
|
+
|
25
|
+
- Fix #2156: simplify expressions like `-1 / (-x)` to `1/x`. Thanks @ony3000.
|
26
|
+
- Fix #2363: remove a redundant part of the regex to split a number.
|
27
|
+
- Fix #2291: add support for fractions in function `intersect`.
|
28
|
+
Thanks @thetazero.
|
29
|
+
- Fix #2358: bug in `SparseMatrix` when replacing a subset of a matrix with
|
30
|
+
a non-consecutive index. Thanks @Al-0.
|
31
|
+
|
32
|
+
|
33
|
+
# 2021-12-22, version 10.0.1
|
34
|
+
|
35
|
+
- Fix #1681: function `gamma` giving inaccurate complex results in some cases.
|
36
|
+
Thanks @kmdrGroch.
|
37
|
+
- Fixed a typo in an example, see #2366. Thanks @blackwindforce.
|
38
|
+
|
39
|
+
|
3
40
|
# 2021-11-03, version 10.0.0
|
4
41
|
|
5
42
|
!!! BE CAREFUL: BREAKING CHANGES IN THE TYPESCRIPT DEFINITIONS !!!
|
package/NOTICE
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
math.js
|
2
2
|
https://github.com/josdejong/mathjs
|
3
3
|
|
4
|
-
Copyright (C) 2013-
|
4
|
+
Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
|
5
5
|
|
6
6
|
Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
@@ -7,7 +7,7 @@ Math.js is an extensive math library for JavaScript and Node.js. It features a f
|
|
7
7
|
[![Version](https://img.shields.io/npm/v/mathjs.svg)](https://www.npmjs.com/package/mathjs)
|
8
8
|
[![Downloads](https://img.shields.io/npm/dm/mathjs.svg)](https://www.npmjs.com/package/mathjs)
|
9
9
|
[![Build Status](https://github.com/josdejong/mathjs/workflows/Node.js%20CI/badge.svg)](https://github.com/josdejong/mathjs/actions)
|
10
|
-
[![Maintenance](https://img.shields.io/maintenance/yes/
|
10
|
+
[![Maintenance](https://img.shields.io/maintenance/yes/2022.svg)](https://github.com/josdejong/mathjs/graphs/commit-activity)
|
11
11
|
[![License](https://img.shields.io/github/license/josdejong/mathjs.svg)](https://github.com/josdejong/mathjs/blob/master/LICENSE)
|
12
12
|
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjosdejong%2Fmathjs.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjosdejong%2Fmathjs?ref=badge_shield)
|
13
13
|
[![Codecov](https://codecov.io/gh/josdejong/mathjs/branch/develop/graph/badge.svg)](https://codecov.io/gh/josdejong/mathjs)
|
@@ -155,6 +155,14 @@ To run the tests remotely on BrowserStack, first set the environment variables `
|
|
155
155
|
|
156
156
|
npm run test:browserstack
|
157
157
|
|
158
|
+
You can separately run the code linter, though it is also executed with `npm test`:
|
159
|
+
|
160
|
+
npm run lint
|
161
|
+
|
162
|
+
To automatically fix linting issue, run:
|
163
|
+
|
164
|
+
npm run format
|
165
|
+
|
158
166
|
To test code coverage of the tests:
|
159
167
|
|
160
168
|
npm run coverage
|
@@ -174,7 +182,7 @@ Thanks Github Actions and BrowserStack for the generous free hosting of this ope
|
|
174
182
|
|
175
183
|
## License
|
176
184
|
|
177
|
-
Copyright (C) 2013-
|
185
|
+
Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
|
178
186
|
|
179
187
|
Licensed under the Apache License, Version 2.0 (the "License");
|
180
188
|
you may not use this file except in compliance with the License.
|
package/bin/cli.js
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
* cat script.txt | mathjs > results.txt Run input stream, output to file
|
31
31
|
*
|
32
32
|
* @license
|
33
|
-
* Copyright (C) 2013-
|
33
|
+
* Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
|
34
34
|
*
|
35
35
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
36
36
|
* use this file except in compliance with the License. You may obtain a copy
|
@@ -547,7 +547,7 @@ parser.evaluate('c[end - 1 : -1 : 2]') // Matrix, [8, 7, 6]
|
|
547
547
|
## Objects
|
548
548
|
|
549
549
|
Objects in math.js work the same as in languages like JavaScript and Python.
|
550
|
-
An object is enclosed by
|
550
|
+
An object is enclosed by curly brackets `{`, `}`, and contains a set of
|
551
551
|
comma separated key/value pairs. Keys and values are separated by a colon `:`.
|
552
552
|
Keys can be a symbol like `prop` or a string like `"prop"`.
|
553
553
|
|
@@ -5,7 +5,7 @@ Math.js contains the following constants.
|
|
5
5
|
Constant | Description | Value
|
6
6
|
--------------- | ----------- | -----
|
7
7
|
`e`, `E` | Euler's number, the base of the natural logarithm. | 2.718281828459045
|
8
|
-
`i` | Imaginary unit, defined as i*i
|
8
|
+
`i` | Imaginary unit, defined as `i * i = -1`. A complex number is described as `a + b * i`, where a is the real part, and b is the imaginary part. | `sqrt(-1)`
|
9
9
|
`Infinity` | Infinity, a number which is larger than the maximum number that can be handled by a floating point number. | `Infinity`
|
10
10
|
`LN2` | Returns the natural logarithm of 2. | `0.6931471805599453`
|
11
11
|
`LN10` | Returns the natural logarithm of 10. | `2.302585092994046`
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
2
|
+
|
3
|
+
# Function invmod
|
4
|
+
|
5
|
+
Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation `ax ≣ 1 (mod b)`
|
6
|
+
See https://en.wikipedia.org/wiki/Modular_multiplicative_inverse.
|
7
|
+
|
8
|
+
|
9
|
+
## Syntax
|
10
|
+
|
11
|
+
```js
|
12
|
+
math.invmod(a, b)
|
13
|
+
```
|
14
|
+
|
15
|
+
### Parameters
|
16
|
+
|
17
|
+
Parameter | Type | Description
|
18
|
+
--------- | ---- | -----------
|
19
|
+
`a` | number | BigNumber | An integer number
|
20
|
+
`b` | number | BigNumber | An integer number
|
21
|
+
|
22
|
+
### Returns
|
23
|
+
|
24
|
+
Type | Description
|
25
|
+
---- | -----------
|
26
|
+
number | BigNumber | Returns an integer number where `invmod(a,b)*a ≣ 1 (mod b)`
|
27
|
+
|
28
|
+
|
29
|
+
## Examples
|
30
|
+
|
31
|
+
```js
|
32
|
+
math.invmod(8, 12) // returns NaN
|
33
|
+
math.invmod(7, 13) // return 2
|
34
|
+
math.invmod(15151, 15122) // returns 10429
|
35
|
+
```
|
36
|
+
|
37
|
+
|
38
|
+
## See also
|
39
|
+
|
40
|
+
[gcd](gcd.md),
|
41
|
+
[xgcd](xgcd.md)
|
@@ -37,11 +37,14 @@ For more details on the theory, see:
|
|
37
37
|
- [Symbolic computation - Simplification (Wikipedia)](https://en.wikipedia.org/wiki/Symbolic_computation#Simplification)
|
38
38
|
|
39
39
|
An optional `options` argument can be passed as last argument of `simplify`.
|
40
|
-
|
41
|
-
- `
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
Currently available options (defaults in parentheses):
|
41
|
+
- `consoleDebug` (false): whether to write the expression being simplified
|
42
|
+
and any changes to it, along with the rule responsible, to console
|
43
|
+
- `exactFractions` (true): whether to try to convert all constants to
|
44
|
+
exact rational numbers.
|
45
|
+
- `fractionsLimit` (10000): when `exactFractions` is true, constants will
|
46
|
+
be expressed as fractions only when both numerator and denominator
|
47
|
+
are smaller than `fractionsLimit`.
|
45
48
|
|
46
49
|
|
47
50
|
## Syntax
|
@@ -44,6 +44,7 @@ Function | Description
|
|
44
44
|
[math.floor(x)](functions/floor.md) | Round a value towards minus infinity.
|
45
45
|
[math.gcd(a, b)](functions/gcd.md) | Calculate the greatest common divisor for two or more values or arrays.
|
46
46
|
[math.hypot(a, b, ...)](functions/hypot.md) | Calculate the hypotenusa of a list with values.
|
47
|
+
[math.invmod(a, b)](functions/invmod.md) | Calculate the (modular) multiplicative inverse of a modulo b.
|
47
48
|
[math.lcm(a, b)](functions/lcm.md) | Calculate the least common multiple for two or more values or arrays.
|
48
49
|
[math.log(x [, base])](functions/log.md) | Calculate the logarithm of a value.
|
49
50
|
[math.log10(x)](functions/log10.md) | Calculate the 10-base logarithm of a value.
|
package/examples/expressions.js
CHANGED