mathjs 15.0.0 → 15.1.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.
Files changed (175) hide show
  1. package/HISTORY.md +34 -6
  2. package/NOTICE +1 -1
  3. package/README.md +7 -7
  4. package/bin/cli.js +1 -1
  5. package/lib/browser/math.js +1 -1
  6. package/lib/browser/math.js.LICENSE.txt +3 -3
  7. package/lib/browser/math.js.map +1 -1
  8. package/lib/cjs/core/function/import.js +7 -0
  9. package/lib/cjs/core/function/typed.js +1 -1
  10. package/lib/cjs/entry/dependenciesAny/dependenciesBernoulli.generated.js +25 -0
  11. package/lib/cjs/entry/dependenciesAny/dependenciesConstantNode.generated.js +2 -0
  12. package/lib/cjs/entry/dependenciesAny/dependenciesEqual.generated.js +0 -2
  13. package/lib/cjs/entry/dependenciesAny/dependenciesIsBounded.generated.js +17 -0
  14. package/lib/cjs/entry/dependenciesAny/dependenciesIsFinite.generated.js +21 -0
  15. package/lib/cjs/entry/dependenciesAny/dependenciesIsInteger.generated.js +2 -0
  16. package/lib/cjs/entry/dependenciesAny/dependenciesSimplifyConstant.generated.js +2 -0
  17. package/lib/cjs/entry/dependenciesAny/dependenciesUnitClass.generated.js +0 -2
  18. package/lib/cjs/entry/dependenciesAny/dependenciesZeta.generated.js +2 -0
  19. package/lib/cjs/entry/dependenciesAny.generated.js +21 -0
  20. package/lib/cjs/entry/dependenciesNumber/dependenciesBernoulli.generated.js +21 -0
  21. package/lib/cjs/entry/dependenciesNumber/dependenciesConstantNode.generated.js +2 -0
  22. package/lib/cjs/entry/dependenciesNumber/dependenciesIsBounded.generated.js +17 -0
  23. package/lib/cjs/entry/dependenciesNumber/dependenciesIsFinite.generated.js +21 -0
  24. package/lib/cjs/entry/dependenciesNumber/dependenciesSimplifyConstant.generated.js +2 -0
  25. package/lib/cjs/entry/dependenciesNumber/dependenciesZeta.generated.js +2 -0
  26. package/lib/cjs/entry/dependenciesNumber.generated.js +21 -0
  27. package/lib/cjs/entry/impureFunctionsAny.generated.js +217 -212
  28. package/lib/cjs/entry/impureFunctionsNumber.generated.js +82 -77
  29. package/lib/cjs/entry/pureFunctionsAny.generated.js +668 -652
  30. package/lib/cjs/entry/pureFunctionsNumber.generated.js +155 -140
  31. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +6 -0
  32. package/lib/cjs/expression/embeddedDocs/function/combinatorics/stirlingS2.js +2 -2
  33. package/lib/cjs/expression/embeddedDocs/function/probability/bernoulli.js +14 -0
  34. package/lib/cjs/expression/embeddedDocs/function/utils/isBounded.js +14 -0
  35. package/lib/cjs/expression/embeddedDocs/function/utils/isFinite.js +14 -0
  36. package/lib/cjs/expression/embeddedDocs/function/utils/isNaN.js +1 -1
  37. package/lib/cjs/expression/embeddedDocs/function/utils/isNumeric.js +1 -1
  38. package/lib/cjs/expression/node/AccessorNode.js +36 -7
  39. package/lib/cjs/expression/node/ConstantNode.js +4 -4
  40. package/lib/cjs/expression/node/FunctionNode.js +20 -5
  41. package/lib/cjs/expression/parse.js +62 -14
  42. package/lib/cjs/factoriesAny.js +21 -0
  43. package/lib/cjs/factoriesNumber.js +23 -2
  44. package/lib/cjs/function/algebra/polynomialRoot.js +4 -0
  45. package/lib/cjs/function/algebra/simplifyConstant.js +3 -2
  46. package/lib/cjs/function/arithmetic/add.js +8 -1
  47. package/lib/cjs/function/arithmetic/cbrt.js +7 -6
  48. package/lib/cjs/function/arithmetic/ceil.js +10 -2
  49. package/lib/cjs/function/arithmetic/exp.js +7 -5
  50. package/lib/cjs/function/arithmetic/expm1.js +6 -5
  51. package/lib/cjs/function/arithmetic/fix.js +10 -2
  52. package/lib/cjs/function/arithmetic/floor.js +10 -2
  53. package/lib/cjs/function/arithmetic/log.js +13 -0
  54. package/lib/cjs/function/arithmetic/mod.js +8 -2
  55. package/lib/cjs/function/arithmetic/nthRoot.js +9 -3
  56. package/lib/cjs/function/arithmetic/nthRoots.js +12 -11
  57. package/lib/cjs/function/matrix/map.js +6 -0
  58. package/lib/cjs/function/probability/bernoulli.js +108 -0
  59. package/lib/cjs/function/relational/compare.js +6 -0
  60. package/lib/cjs/function/relational/compareNatural.js +8 -2
  61. package/lib/cjs/function/relational/deepEqual.js +8 -3
  62. package/lib/cjs/function/relational/equal.js +17 -5
  63. package/lib/cjs/function/relational/unequal.js +14 -2
  64. package/lib/cjs/function/set/setDistinct.js +2 -1
  65. package/lib/cjs/function/special/zeta.js +3 -2
  66. package/lib/cjs/function/string/format.js +9 -0
  67. package/lib/cjs/function/utils/isBounded.js +54 -0
  68. package/lib/cjs/function/utils/isFinite.js +57 -0
  69. package/lib/cjs/function/utils/isInteger.js +7 -15
  70. package/lib/cjs/function/utils/isNaN.js +1 -1
  71. package/lib/cjs/function/utils/isNumeric.js +1 -1
  72. package/lib/cjs/function/utils/numeric.js +6 -0
  73. package/lib/cjs/header.js +3 -3
  74. package/lib/cjs/json/replacer.js +1 -1
  75. package/lib/cjs/plain/number/probability.js +2 -2
  76. package/lib/cjs/plain/number/trigonometry.js +1 -1
  77. package/lib/cjs/type/bigint.js +5 -0
  78. package/lib/cjs/type/boolean.js +6 -0
  79. package/lib/cjs/type/complex/function/complex.js +6 -0
  80. package/lib/cjs/type/fraction/function/fraction.js +9 -1
  81. package/lib/cjs/type/matrix/SparseMatrix.js +24 -4
  82. package/lib/cjs/type/matrix/function/index.js +8 -0
  83. package/lib/cjs/type/matrix/function/matrix.js +6 -0
  84. package/lib/cjs/type/matrix/function/sparse.js +4 -0
  85. package/lib/cjs/type/string.js +4 -0
  86. package/lib/cjs/type/unit/Unit.js +12 -8
  87. package/lib/cjs/type/unit/function/unit.js +8 -0
  88. package/lib/cjs/utils/number.js +7 -7
  89. package/lib/cjs/utils/optimizeCallback.js +13 -1
  90. package/lib/cjs/version.js +1 -1
  91. package/lib/esm/core/function/import.js +7 -0
  92. package/lib/esm/core/function/typed.js +1 -1
  93. package/lib/esm/entry/dependenciesAny/dependenciesBernoulli.generated.js +18 -0
  94. package/lib/esm/entry/dependenciesAny/dependenciesConstantNode.generated.js +2 -0
  95. package/lib/esm/entry/dependenciesAny/dependenciesEqual.generated.js +0 -2
  96. package/lib/esm/entry/dependenciesAny/dependenciesIsBounded.generated.js +10 -0
  97. package/lib/esm/entry/dependenciesAny/dependenciesIsFinite.generated.js +14 -0
  98. package/lib/esm/entry/dependenciesAny/dependenciesIsInteger.generated.js +2 -0
  99. package/lib/esm/entry/dependenciesAny/dependenciesSimplifyConstant.generated.js +2 -0
  100. package/lib/esm/entry/dependenciesAny/dependenciesUnitClass.generated.js +0 -2
  101. package/lib/esm/entry/dependenciesAny/dependenciesZeta.generated.js +2 -0
  102. package/lib/esm/entry/dependenciesAny.generated.js +3 -0
  103. package/lib/esm/entry/dependenciesNumber/dependenciesBernoulli.generated.js +14 -0
  104. package/lib/esm/entry/dependenciesNumber/dependenciesConstantNode.generated.js +2 -0
  105. package/lib/esm/entry/dependenciesNumber/dependenciesIsBounded.generated.js +10 -0
  106. package/lib/esm/entry/dependenciesNumber/dependenciesIsFinite.generated.js +14 -0
  107. package/lib/esm/entry/dependenciesNumber/dependenciesSimplifyConstant.generated.js +2 -0
  108. package/lib/esm/entry/dependenciesNumber/dependenciesZeta.generated.js +2 -0
  109. package/lib/esm/entry/dependenciesNumber.generated.js +3 -0
  110. package/lib/esm/entry/impureFunctionsAny.generated.js +219 -214
  111. package/lib/esm/entry/impureFunctionsNumber.generated.js +84 -79
  112. package/lib/esm/entry/pureFunctionsAny.generated.js +665 -649
  113. package/lib/esm/entry/pureFunctionsNumber.generated.js +154 -139
  114. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +6 -0
  115. package/lib/esm/expression/embeddedDocs/function/combinatorics/stirlingS2.js +2 -2
  116. package/lib/esm/expression/embeddedDocs/function/probability/bernoulli.js +8 -0
  117. package/lib/esm/expression/embeddedDocs/function/utils/isBounded.js +8 -0
  118. package/lib/esm/expression/embeddedDocs/function/utils/isFinite.js +8 -0
  119. package/lib/esm/expression/embeddedDocs/function/utils/isNaN.js +1 -1
  120. package/lib/esm/expression/embeddedDocs/function/utils/isNumeric.js +1 -1
  121. package/lib/esm/expression/node/AccessorNode.js +36 -7
  122. package/lib/esm/expression/node/ConstantNode.js +4 -4
  123. package/lib/esm/expression/node/FunctionNode.js +20 -5
  124. package/lib/esm/expression/parse.js +62 -14
  125. package/lib/esm/factoriesAny.js +3 -0
  126. package/lib/esm/factoriesNumber.js +3 -0
  127. package/lib/esm/function/algebra/polynomialRoot.js +4 -0
  128. package/lib/esm/function/algebra/simplifyConstant.js +3 -2
  129. package/lib/esm/function/arithmetic/add.js +8 -1
  130. package/lib/esm/function/arithmetic/cbrt.js +7 -6
  131. package/lib/esm/function/arithmetic/ceil.js +10 -2
  132. package/lib/esm/function/arithmetic/exp.js +7 -5
  133. package/lib/esm/function/arithmetic/expm1.js +6 -5
  134. package/lib/esm/function/arithmetic/fix.js +10 -2
  135. package/lib/esm/function/arithmetic/floor.js +10 -2
  136. package/lib/esm/function/arithmetic/log.js +13 -0
  137. package/lib/esm/function/arithmetic/mod.js +8 -2
  138. package/lib/esm/function/arithmetic/nthRoot.js +9 -3
  139. package/lib/esm/function/arithmetic/nthRoots.js +12 -11
  140. package/lib/esm/function/matrix/map.js +6 -0
  141. package/lib/esm/function/probability/bernoulli.js +102 -0
  142. package/lib/esm/function/relational/compare.js +6 -0
  143. package/lib/esm/function/relational/compareNatural.js +8 -2
  144. package/lib/esm/function/relational/deepEqual.js +8 -3
  145. package/lib/esm/function/relational/equal.js +17 -5
  146. package/lib/esm/function/relational/unequal.js +14 -2
  147. package/lib/esm/function/set/setDistinct.js +2 -1
  148. package/lib/esm/function/special/zeta.js +3 -2
  149. package/lib/esm/function/string/format.js +9 -0
  150. package/lib/esm/function/utils/isBounded.js +48 -0
  151. package/lib/esm/function/utils/isFinite.js +51 -0
  152. package/lib/esm/function/utils/isInteger.js +7 -15
  153. package/lib/esm/function/utils/isNaN.js +1 -1
  154. package/lib/esm/function/utils/isNumeric.js +1 -1
  155. package/lib/esm/function/utils/numeric.js +6 -0
  156. package/lib/esm/header.js +1 -1
  157. package/lib/esm/json/replacer.js +1 -1
  158. package/lib/esm/plain/number/probability.js +2 -2
  159. package/lib/esm/plain/number/trigonometry.js +1 -1
  160. package/lib/esm/type/bigint.js +5 -0
  161. package/lib/esm/type/boolean.js +6 -0
  162. package/lib/esm/type/complex/function/complex.js +6 -0
  163. package/lib/esm/type/fraction/function/fraction.js +9 -1
  164. package/lib/esm/type/matrix/SparseMatrix.js +24 -4
  165. package/lib/esm/type/matrix/function/index.js +8 -0
  166. package/lib/esm/type/matrix/function/matrix.js +6 -0
  167. package/lib/esm/type/matrix/function/sparse.js +4 -0
  168. package/lib/esm/type/string.js +4 -0
  169. package/lib/esm/type/unit/Unit.js +12 -8
  170. package/lib/esm/type/unit/function/unit.js +8 -0
  171. package/lib/esm/utils/number.js +7 -7
  172. package/lib/esm/utils/optimizeCallback.js +13 -1
  173. package/lib/esm/version.js +1 -1
  174. package/package.json +15 -15
  175. package/types/index.d.ts +580 -237
package/HISTORY.md CHANGED
@@ -1,22 +1,50 @@
1
1
  # History
2
2
 
3
- # 2205-10-10, 15.0.0
3
+ # 2026-02-10, 15.1.1
4
+
5
+ - Fix: #3631 Handle bigints in `compareNatural` (#3632). Thanks @Dheemanth07.
6
+ - Fix: #3578 interpret empty true-expr of conditional as error (#3581).
7
+ Thanks @gwhitney.
8
+ - Fix: #3597 added nullish type definitions (#3601). Thanks @Ayo1984.
9
+ - Docs: Correct several arithmetic and relational documentation examples
10
+ and add History (#3630). Thanks @Anadian.
11
+ - Docs: fix #3565, update Matrix documentation (#3591). Thanks @orelbn.
12
+ - Docs: #3341 add per-function HISTORY sections (#3606). Thanks @gwhitney.
13
+ - Docs: describe that `setDistinct` sorts the elements (see #3602).
14
+
15
+ # 2025-11-05, 15.1.0
16
+
17
+ - Feat: implement functions `isFinite` and `isBounded` (#3554, #3553).
18
+ Thanks @gwhitney.
19
+ - Feat: add function `bernoulli` to calculate Bernoulli numbers (#3551).
20
+ Thanks @gwhitney.
21
+ - Feat: support for optional chaining `object?.key` (#3547).
22
+ Thanks @NilsDietrich.
23
+ - Fix: #3580, #3586, #3587 issues with the optional chaining operator: disallow
24
+ double dot `?..`, allow optional function calls, throw errors on invalid uses
25
+ of `?.` (#3585). Thanks @AnslemHack.
26
+ - Fix: #3579 conditional parsed as optional chaining (#3584).
27
+ - Fix: #3564 Avoid error throws when mapping/filtering empty arrays/matrices.
28
+ (#3567). Thanks @richardt-cla.
29
+ - Fix: #3574 respect tolerances in function `isInteger` (#3575).
30
+ Thanks @gwhitney.
31
+ - Fix: #3562 serializing units missing an internal property (#3572).
32
+
33
+ # 2025-10-10, 15.0.0
4
34
 
5
35
  !!! BE CAREFUL: BREAKING CHANGES !!!
6
36
 
7
37
  - Feat: #3349 Decouple precedence of unary percentage operator and binary
8
38
  modulus operator (that both use symbol `%`), and raise the former (#3432).
9
39
  Thanks @kiprobinsonknack.
10
- - Feat: #1753 enhance Kronecker product to handle arbitrary dimension (#3461).
11
- Thanks @gwhitney.
40
+ - Feat: #1753 enhance Kronecker product to handle arbitrary dimension (#3461,
41
+ #3455). Thanks @gwhitney and @Delaney.
12
42
  - Feat: #2344 matrix subset according to the type of input (#3485).
13
43
  Thanks @dvd101x.
14
- - Fix: #1753 Correct dimensionality of Kronecker product on vectors (and
15
- extend to arbitrary dimension) (#3455). Thanks @Delaney.
16
44
  - Fix: #3501 parse `%` as unary only when not followed by a term (#3505).
17
45
  Thanks @gwhitney.
18
46
  - Fix: #3421 require a space or delimiter after hex, bin, and oct values (#3463).
19
- - Fix: #3529 Change function `size` to always return an `Array` (3535).
47
+ - Fix: #3529 Change function `size` to always return an `Array` (#3535).
20
48
  - Fix: #3530 throw an error when trying to flatten a `SparseMatrix` (#3536).
21
49
 
22
50
  # 2025-10-10, 14.9.1
package/NOTICE CHANGED
@@ -1,7 +1,7 @@
1
1
  math.js
2
2
  https://github.com/josdejong/mathjs
3
3
 
4
- Copyright (C) 2013-2025 Jos de Jong <wjosdejong@gmail.com>
4
+ Copyright (C) 2013-2026 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/2025.svg)](https://github.com/josdejong/mathjs/graphs/commit-activity)
10
+ [![Maintenance](https://img.shields.io/maintenance/yes/2026.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)
@@ -133,10 +133,10 @@ At the lowest level, mathjs has immutable factory functions which create immutab
133
133
  A common case is to implement a new function. This involves the following steps:
134
134
 
135
135
  - Implement the function in the right category, for example `./src/function/arithmetic/myNewFunction.js`, where you can replace `arithmetic` with the proper category, and `myNewFunction` with the name of the new function. Add the new function to the index files `./src/factoriesAny.js` and possibly `./src/factoriesNumber.js`.
136
- - Write documentation on the function in the source code comment of `myNewFunction.js`. This documentation is used to auto generate documentation on the website.
136
+ - Write documentation on the function in the source code comment of `myNewFunction.js`. This documentation is used to auto generate documentation on the website. It should include a History section with one line, indicating the upcoming version number in which the function will be created.
137
137
  - Write embedded documentation for the new function in `./src/expression/embeddedDocs/function/arithmetic/myNewFunction.js`. Add the new documentation to the index file `./src/expression/embeddedDocs/embeddedDocs.js`.
138
138
  - Write unit tests for the function in `./test/unit-tests/function/arithmetic/myNewFunction.test.js`.
139
- - Write the necessary TypeScript definitions for the new function in `./types/index.d.ts`, and write tests for it in `./test/typescript-tests/testTypes.ts`. This is described in [./types/EXPLANATION.md](./types/EXPLANATION.md).
139
+ - Write the necessary TypeScript definitions for the new function in `./types/index.d.ts`, and write tests for it in `./test/typescript-tests/testTypes.ts`. This is described in [./types/EXPLANATION.md](./types/EXPLANATION.md) -- make sure to read that page, as Typescript definitions must be added in _multiple_ places in the code.
140
140
  - Ensure the code style is ok by running `npm run lint` (run `npm run format` to fix the code style automatically).
141
141
 
142
142
 
@@ -191,18 +191,18 @@ To see the coverage results, open the generated report in your browser:
191
191
 
192
192
  ### Continuous integration testing
193
193
 
194
- Continuous integration tests are run on [Github Actions](https://github.com/josdejong/mathjs/actions) and [LambdaTest](https://www.lambdatest.com) every time a commit is pushed to github. Github Actions runs the tests for different versions of node.js, and LambdaTest runs the tests on all major browsers.
194
+ Continuous integration tests are run on [GitHub Actions](https://github.com/josdejong/mathjs/actions) and [TestMu AI](https://www.testmu.ai) (formerly LambdaTest) every time a commit is pushed to GitHub. GitHub Actions runs the tests for different versions of node.js, and TestMu AI runs the tests on all major browsers.
195
195
 
196
- [![LambdaTest](https://raw.github.com/josdejong/mathjs/master/misc/lambdatest.svg)](https://www.lambdatest.com)
196
+ [![TestMu AI](https://raw.github.com/josdejong/mathjs/develop/misc/testmu-ai.svg)](https://www.testmu.ai)
197
197
 
198
- Thanks, GitHub Actions and LambdaTest for the generous free hosting of this open source project!
198
+ Thanks, GitHub Actions and TestMu AI for the generous free hosting of this open source project!
199
199
 
200
200
  ## License
201
201
 
202
202
  mathjs is published under the Apache 2.0 license:
203
203
 
204
204
  ```
205
- Copyright (C) 2013-2025 Jos de Jong <wjosdejong@gmail.com>
205
+ Copyright (C) 2013-2026 Jos de Jong <wjosdejong@gmail.com>
206
206
 
207
207
  Licensed under the Apache License, Version 2.0 (the "License");
208
208
  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-2025 Jos de Jong <wjosdejong@gmail.com>
33
+ * Copyright (C) 2013-2026 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