mathjs 10.1.1 → 10.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (325) hide show
  1. package/HISTORY.md +17 -0
  2. package/docs/expressions/algebra.md +27 -0
  3. package/docs/reference/functions/abs.md +6 -0
  4. package/docs/reference/functions/acos.md +6 -0
  5. package/docs/reference/functions/acosh.md +6 -0
  6. package/docs/reference/functions/acot.md +6 -0
  7. package/docs/reference/functions/acoth.md +6 -0
  8. package/docs/reference/functions/acsc.md +6 -0
  9. package/docs/reference/functions/acsch.md +6 -0
  10. package/docs/reference/functions/add.md +6 -0
  11. package/docs/reference/functions/and.md +6 -0
  12. package/docs/reference/functions/apply.md +6 -0
  13. package/docs/reference/functions/arg.md +6 -0
  14. package/docs/reference/functions/asec.md +6 -0
  15. package/docs/reference/functions/asech.md +6 -0
  16. package/docs/reference/functions/asin.md +6 -0
  17. package/docs/reference/functions/asinh.md +6 -0
  18. package/docs/reference/functions/atan.md +6 -0
  19. package/docs/reference/functions/atan2.md +6 -0
  20. package/docs/reference/functions/atanh.md +6 -0
  21. package/docs/reference/functions/bellNumbers.md +6 -0
  22. package/docs/reference/functions/bin.md +6 -0
  23. package/docs/reference/functions/bitAnd.md +6 -0
  24. package/docs/reference/functions/bitNot.md +6 -0
  25. package/docs/reference/functions/bitOr.md +6 -0
  26. package/docs/reference/functions/bitXor.md +6 -0
  27. package/docs/reference/functions/catalan.md +6 -0
  28. package/docs/reference/functions/cbrt.md +6 -0
  29. package/docs/reference/functions/ceil.md +6 -0
  30. package/docs/reference/functions/clone.md +6 -0
  31. package/docs/reference/functions/column.md +6 -0
  32. package/docs/reference/functions/combinations.md +6 -0
  33. package/docs/reference/functions/combinationsWithRep.md +6 -0
  34. package/docs/reference/functions/compare.md +6 -0
  35. package/docs/reference/functions/compareNatural.md +6 -0
  36. package/docs/reference/functions/compareText.md +6 -0
  37. package/docs/reference/functions/compile.md +6 -0
  38. package/docs/reference/functions/composition.md +6 -0
  39. package/docs/reference/functions/concat.md +6 -0
  40. package/docs/reference/functions/conj.md +6 -0
  41. package/docs/reference/functions/cos.md +6 -0
  42. package/docs/reference/functions/cosh.md +6 -0
  43. package/docs/reference/functions/cot.md +6 -0
  44. package/docs/reference/functions/coth.md +6 -0
  45. package/docs/reference/functions/count.md +6 -0
  46. package/docs/reference/functions/cross.md +6 -0
  47. package/docs/reference/functions/csc.md +6 -0
  48. package/docs/reference/functions/csch.md +6 -0
  49. package/docs/reference/functions/ctranspose.md +6 -0
  50. package/docs/reference/functions/cube.md +6 -0
  51. package/docs/reference/functions/deepEqual.md +6 -0
  52. package/docs/reference/functions/derivative.md +6 -0
  53. package/docs/reference/functions/det.md +6 -0
  54. package/docs/reference/functions/diag.md +6 -0
  55. package/docs/reference/functions/diff.md +6 -0
  56. package/docs/reference/functions/distance.md +6 -0
  57. package/docs/reference/functions/divide.md +6 -0
  58. package/docs/reference/functions/dot.md +6 -0
  59. package/docs/reference/functions/dotDivide.md +6 -0
  60. package/docs/reference/functions/dotMultiply.md +6 -0
  61. package/docs/reference/functions/dotPow.md +6 -0
  62. package/docs/reference/functions/eigs.md +6 -0
  63. package/docs/reference/functions/equal.md +6 -0
  64. package/docs/reference/functions/equalText.md +6 -0
  65. package/docs/reference/functions/erf.md +6 -0
  66. package/docs/reference/functions/evaluate.md +6 -0
  67. package/docs/reference/functions/exp.md +6 -0
  68. package/docs/reference/functions/expm.md +6 -0
  69. package/docs/reference/functions/expm1.md +6 -0
  70. package/docs/reference/functions/factorial.md +6 -0
  71. package/docs/reference/functions/filter.md +6 -0
  72. package/docs/reference/functions/fix.md +6 -0
  73. package/docs/reference/functions/flatten.md +6 -0
  74. package/docs/reference/functions/floor.md +6 -0
  75. package/docs/reference/functions/forEach.md +6 -0
  76. package/docs/reference/functions/format.md +6 -0
  77. package/docs/reference/functions/gamma.md +6 -0
  78. package/docs/reference/functions/gcd.md +6 -0
  79. package/docs/reference/functions/getMatrixDataType.md +6 -0
  80. package/docs/reference/functions/hasNumericValue.md +6 -0
  81. package/docs/reference/functions/help.md +6 -0
  82. package/docs/reference/functions/hex.md +6 -0
  83. package/docs/reference/functions/hypot.md +6 -0
  84. package/docs/reference/functions/identity.md +6 -0
  85. package/docs/reference/functions/im.md +6 -0
  86. package/docs/reference/functions/intersect.md +6 -0
  87. package/docs/reference/functions/inv.md +6 -0
  88. package/docs/reference/functions/invmod.md +6 -0
  89. package/docs/reference/functions/isInteger.md +6 -0
  90. package/docs/reference/functions/isNaN.md +6 -0
  91. package/docs/reference/functions/isNegative.md +6 -0
  92. package/docs/reference/functions/isNumeric.md +6 -0
  93. package/docs/reference/functions/isPositive.md +6 -0
  94. package/docs/reference/functions/isPrime.md +6 -0
  95. package/docs/reference/functions/isZero.md +6 -0
  96. package/docs/reference/functions/kldivergence.md +6 -0
  97. package/docs/reference/functions/kron.md +6 -0
  98. package/docs/reference/functions/larger.md +6 -0
  99. package/docs/reference/functions/largerEq.md +6 -0
  100. package/docs/reference/functions/lcm.md +6 -0
  101. package/docs/reference/functions/leafCount.md +52 -0
  102. package/docs/reference/functions/leftShift.md +6 -0
  103. package/docs/reference/functions/log.md +6 -0
  104. package/docs/reference/functions/log10.md +6 -0
  105. package/docs/reference/functions/log1p.md +6 -0
  106. package/docs/reference/functions/log2.md +6 -0
  107. package/docs/reference/functions/lsolve.md +6 -0
  108. package/docs/reference/functions/lsolveAll.md +6 -0
  109. package/docs/reference/functions/lup.md +6 -0
  110. package/docs/reference/functions/lusolve.md +6 -0
  111. package/docs/reference/functions/mad.md +6 -0
  112. package/docs/reference/functions/map.md +6 -0
  113. package/docs/reference/functions/matrixFromColumns.md +6 -0
  114. package/docs/reference/functions/matrixFromFunction.md +6 -0
  115. package/docs/reference/functions/matrixFromRows.md +6 -0
  116. package/docs/reference/functions/max.md +6 -0
  117. package/docs/reference/functions/mean.md +6 -0
  118. package/docs/reference/functions/median.md +6 -0
  119. package/docs/reference/functions/min.md +6 -0
  120. package/docs/reference/functions/mod.md +6 -0
  121. package/docs/reference/functions/mode.md +6 -0
  122. package/docs/reference/functions/multinomial.md +6 -0
  123. package/docs/reference/functions/multiply.md +6 -0
  124. package/docs/reference/functions/norm.md +6 -0
  125. package/docs/reference/functions/not.md +6 -0
  126. package/docs/reference/functions/nthRoot.md +6 -0
  127. package/docs/reference/functions/nthRoots.md +6 -0
  128. package/docs/reference/functions/numeric.md +6 -0
  129. package/docs/reference/functions/oct.md +6 -0
  130. package/docs/reference/functions/ones.md +6 -0
  131. package/docs/reference/functions/or.md +6 -0
  132. package/docs/reference/functions/parser.md +6 -0
  133. package/docs/reference/functions/partitionSelect.md +6 -0
  134. package/docs/reference/functions/permutations.md +6 -0
  135. package/docs/reference/functions/pickRandom.md +6 -0
  136. package/docs/reference/functions/pow.md +6 -0
  137. package/docs/reference/functions/print.md +6 -0
  138. package/docs/reference/functions/prod.md +6 -0
  139. package/docs/reference/functions/qr.md +6 -0
  140. package/docs/reference/functions/quantileSeq.md +6 -0
  141. package/docs/reference/functions/random.md +6 -0
  142. package/docs/reference/functions/randomInt.md +6 -0
  143. package/docs/reference/functions/range.md +6 -0
  144. package/docs/reference/functions/rationalize.md +7 -1
  145. package/docs/reference/functions/re.md +6 -0
  146. package/docs/reference/functions/reshape.md +7 -0
  147. package/docs/reference/functions/resize.md +6 -0
  148. package/docs/reference/functions/resolve.md +46 -0
  149. package/docs/reference/functions/rightArithShift.md +6 -0
  150. package/docs/reference/functions/rightLogShift.md +6 -0
  151. package/docs/reference/functions/rotate.md +6 -0
  152. package/docs/reference/functions/rotationMatrix.md +6 -0
  153. package/docs/reference/functions/round.md +6 -0
  154. package/docs/reference/functions/row.md +6 -0
  155. package/docs/reference/functions/sec.md +6 -0
  156. package/docs/reference/functions/sech.md +6 -0
  157. package/docs/reference/functions/setCartesian.md +6 -0
  158. package/docs/reference/functions/setDifference.md +6 -0
  159. package/docs/reference/functions/setDistinct.md +6 -0
  160. package/docs/reference/functions/setIntersect.md +6 -0
  161. package/docs/reference/functions/setIsSubset.md +6 -0
  162. package/docs/reference/functions/setMultiplicity.md +6 -0
  163. package/docs/reference/functions/setPowerset.md +6 -0
  164. package/docs/reference/functions/setSize.md +6 -0
  165. package/docs/reference/functions/setSymDifference.md +6 -0
  166. package/docs/reference/functions/setUnion.md +6 -0
  167. package/docs/reference/functions/sign.md +6 -0
  168. package/docs/reference/functions/simplify.md +43 -6
  169. package/docs/reference/functions/simplifyCore.md +50 -0
  170. package/docs/reference/functions/sin.md +6 -0
  171. package/docs/reference/functions/sinh.md +6 -0
  172. package/docs/reference/functions/size.md +6 -0
  173. package/docs/reference/functions/slu.md +6 -0
  174. package/docs/reference/functions/smaller.md +6 -0
  175. package/docs/reference/functions/smallerEq.md +6 -0
  176. package/docs/reference/functions/sort.md +6 -0
  177. package/docs/reference/functions/sqrt.md +6 -0
  178. package/docs/reference/functions/sqrtm.md +6 -0
  179. package/docs/reference/functions/square.md +6 -0
  180. package/docs/reference/functions/squeeze.md +6 -0
  181. package/docs/reference/functions/std.md +6 -0
  182. package/docs/reference/functions/stirlingS2.md +6 -0
  183. package/docs/reference/functions/subset.md +6 -0
  184. package/docs/reference/functions/subtract.md +6 -0
  185. package/docs/reference/functions/sum.md +6 -0
  186. package/docs/reference/functions/tan.md +6 -0
  187. package/docs/reference/functions/tanh.md +6 -0
  188. package/docs/reference/functions/to.md +6 -0
  189. package/docs/reference/functions/trace.md +6 -0
  190. package/docs/reference/functions/transpose.md +6 -0
  191. package/docs/reference/functions/typeOf.md +6 -0
  192. package/docs/reference/functions/unaryMinus.md +6 -0
  193. package/docs/reference/functions/unaryPlus.md +6 -0
  194. package/docs/reference/functions/unequal.md +6 -0
  195. package/docs/reference/functions/usolve.md +6 -0
  196. package/docs/reference/functions/usolveAll.md +6 -0
  197. package/docs/reference/functions/variance.md +6 -0
  198. package/docs/reference/functions/xgcd.md +6 -0
  199. package/docs/reference/functions/xor.md +6 -0
  200. package/docs/reference/functions/zeros.md +6 -0
  201. package/docs/reference/functions.md +3 -0
  202. package/lib/browser/math.js +6 -6
  203. package/lib/browser/math.js.map +1 -1
  204. package/lib/cjs/core/create.js +4 -4
  205. package/lib/cjs/core/function/import.js +3 -3
  206. package/lib/cjs/core/function/typed.js +2 -2
  207. package/lib/cjs/defaultInstance.js +3 -3
  208. package/lib/cjs/entry/allFactoriesAny.js +1 -1
  209. package/lib/cjs/entry/allFactoriesNumber.js +1 -1
  210. package/lib/cjs/entry/configReadonly.js +1 -1
  211. package/lib/cjs/entry/dependenciesAny/dependenciesLeafCount.generated.js +23 -0
  212. package/lib/cjs/entry/dependenciesAny/dependenciesRationalize.generated.js +3 -0
  213. package/lib/cjs/entry/dependenciesAny/dependenciesResolve.generated.js +32 -0
  214. package/lib/cjs/entry/dependenciesAny/dependenciesSimplify.generated.js +6 -0
  215. package/lib/cjs/entry/dependenciesAny/dependenciesSimplifyCore.generated.js +65 -0
  216. package/lib/cjs/entry/dependenciesAny.generated.js +24 -0
  217. package/lib/cjs/entry/dependenciesNumber/dependenciesRationalize.generated.js +3 -0
  218. package/lib/cjs/entry/dependenciesNumber/dependenciesResolve.generated.js +32 -0
  219. package/lib/cjs/entry/dependenciesNumber/dependenciesSimplify.generated.js +6 -0
  220. package/lib/cjs/entry/dependenciesNumber/dependenciesSimplifyCore.generated.js +65 -0
  221. package/lib/cjs/entry/dependenciesNumber.generated.js +16 -0
  222. package/lib/cjs/entry/impureFunctionsAny.generated.js +67 -29
  223. package/lib/cjs/entry/impureFunctionsNumber.generated.js +96 -64
  224. package/lib/cjs/entry/pureFunctionsAny.generated.js +53 -55
  225. package/lib/cjs/entry/pureFunctionsNumber.generated.js +46 -48
  226. package/lib/cjs/expression/Help.js +4 -0
  227. package/lib/cjs/expression/Parser.js +1 -1
  228. package/lib/cjs/expression/embeddedDocs/core/typed.js +1 -1
  229. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +14 -5
  230. package/lib/cjs/expression/embeddedDocs/function/algebra/leafCount.js +15 -0
  231. package/lib/cjs/expression/embeddedDocs/function/algebra/resolve.js +16 -0
  232. package/lib/cjs/expression/embeddedDocs/function/algebra/simplify.js +1 -1
  233. package/lib/cjs/expression/embeddedDocs/function/algebra/simplifyCore.js +15 -0
  234. package/lib/cjs/expression/node/FunctionNode.js +7 -7
  235. package/lib/cjs/expression/node/IndexNode.js +1 -1
  236. package/lib/cjs/expression/node/Node.js +3 -3
  237. package/lib/cjs/expression/node/ObjectNode.js +1 -1
  238. package/lib/cjs/expression/node/utils/access.js +1 -1
  239. package/lib/cjs/expression/node/utils/assign.js +1 -1
  240. package/lib/cjs/expression/parse.js +13 -13
  241. package/lib/cjs/factoriesAny.js +24 -0
  242. package/lib/cjs/factoriesNumber.js +16 -0
  243. package/lib/cjs/function/algebra/decomposition/qr.js +1 -1
  244. package/lib/cjs/function/algebra/leafCount.js +66 -0
  245. package/lib/cjs/function/algebra/rationalize.js +24 -41
  246. package/lib/cjs/function/algebra/resolve.js +106 -0
  247. package/lib/cjs/function/algebra/simplify/simplifyConstant.js +5 -5
  248. package/lib/cjs/function/algebra/simplify/util.js +171 -33
  249. package/lib/cjs/function/algebra/simplify.js +554 -207
  250. package/lib/cjs/function/algebra/{simplify/simplifyCore.js → simplifyCore.js} +67 -43
  251. package/lib/cjs/function/algebra/solver/lsolveAll.js +2 -2
  252. package/lib/cjs/function/algebra/solver/usolveAll.js +2 -2
  253. package/lib/cjs/function/arithmetic/ceil.js +3 -3
  254. package/lib/cjs/function/arithmetic/floor.js +3 -3
  255. package/lib/cjs/function/arithmetic/invmod.js +1 -1
  256. package/lib/cjs/function/arithmetic/norm.js +1 -1
  257. package/lib/cjs/function/arithmetic/round.js +1 -1
  258. package/lib/cjs/function/matrix/eigs/complexEigs.js +5 -5
  259. package/lib/cjs/function/matrix/matrixFromColumns.js +1 -1
  260. package/lib/cjs/function/matrix/matrixFromRows.js +1 -1
  261. package/lib/cjs/function/probability/util/seededRNG.js +2 -2
  262. package/lib/cjs/function/relational/compareNatural.js +6 -6
  263. package/lib/cjs/header.js +2 -2
  264. package/lib/cjs/plain/bignumber/index.js +1 -1
  265. package/lib/cjs/plain/number/combinations.js +18 -6
  266. package/lib/cjs/type/bignumber/BigNumber.js +2 -2
  267. package/lib/cjs/type/bignumber/function/bignumber.js +1 -1
  268. package/lib/cjs/type/boolean.js +2 -2
  269. package/lib/cjs/type/complex/Complex.js +14 -14
  270. package/lib/cjs/type/complex/function/complex.js +1 -1
  271. package/lib/cjs/type/fraction/Fraction.js +6 -6
  272. package/lib/cjs/type/fraction/function/fraction.js +1 -1
  273. package/lib/cjs/type/matrix/DenseMatrix.js +5 -5
  274. package/lib/cjs/type/matrix/SparseMatrix.js +2 -2
  275. package/lib/cjs/type/number.js +1 -1
  276. package/lib/cjs/type/string.js +2 -2
  277. package/lib/cjs/type/unit/Unit.js +8 -8
  278. package/lib/cjs/utils/customs.js +2 -2
  279. package/lib/cjs/utils/emitter.js +1 -1
  280. package/lib/cjs/utils/function.js +2 -2
  281. package/lib/cjs/utils/is.js +6 -6
  282. package/lib/cjs/utils/latex.js +3 -3
  283. package/lib/cjs/utils/lruQueue.js +1 -1
  284. package/lib/cjs/utils/map.js +3 -3
  285. package/lib/cjs/utils/object.js +2 -2
  286. package/lib/cjs/utils/snapshot.js +7 -7
  287. package/lib/cjs/utils/string.js +2 -2
  288. package/lib/cjs/version.js +1 -1
  289. package/lib/esm/entry/dependenciesAny/dependenciesLeafCount.generated.js +12 -0
  290. package/lib/esm/entry/dependenciesAny/dependenciesRationalize.generated.js +2 -0
  291. package/lib/esm/entry/dependenciesAny/dependenciesResolve.generated.js +18 -0
  292. package/lib/esm/entry/dependenciesAny/dependenciesSimplify.generated.js +4 -0
  293. package/lib/esm/entry/dependenciesAny/dependenciesSimplifyCore.generated.js +40 -0
  294. package/lib/esm/entry/dependenciesAny.generated.js +3 -0
  295. package/lib/esm/entry/dependenciesNumber/dependenciesRationalize.generated.js +2 -0
  296. package/lib/esm/entry/dependenciesNumber/dependenciesResolve.generated.js +18 -0
  297. package/lib/esm/entry/dependenciesNumber/dependenciesSimplify.generated.js +4 -0
  298. package/lib/esm/entry/dependenciesNumber/dependenciesSimplifyCore.generated.js +40 -0
  299. package/lib/esm/entry/dependenciesNumber.generated.js +2 -0
  300. package/lib/esm/entry/impureFunctionsAny.generated.js +57 -22
  301. package/lib/esm/entry/impureFunctionsNumber.generated.js +83 -53
  302. package/lib/esm/entry/pureFunctionsAny.generated.js +42 -42
  303. package/lib/esm/entry/pureFunctionsNumber.generated.js +32 -32
  304. package/lib/esm/expression/Help.js +4 -0
  305. package/lib/esm/expression/embeddedDocs/core/typed.js +1 -1
  306. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +6 -0
  307. package/lib/esm/expression/embeddedDocs/function/algebra/leafCount.js +8 -0
  308. package/lib/esm/expression/embeddedDocs/function/algebra/resolve.js +9 -0
  309. package/lib/esm/expression/embeddedDocs/function/algebra/simplify.js +1 -1
  310. package/lib/esm/expression/embeddedDocs/function/algebra/simplifyCore.js +8 -0
  311. package/lib/esm/factoriesAny.js +3 -0
  312. package/lib/esm/factoriesNumber.js +2 -0
  313. package/lib/esm/function/algebra/leafCount.js +59 -0
  314. package/lib/esm/function/algebra/rationalize.js +24 -40
  315. package/lib/esm/function/algebra/resolve.js +95 -0
  316. package/lib/esm/function/algebra/simplify/simplifyConstant.js +3 -3
  317. package/lib/esm/function/algebra/simplify/util.js +170 -34
  318. package/lib/esm/function/algebra/simplify.js +549 -202
  319. package/lib/esm/function/algebra/{simplify/simplifyCore.js → simplifyCore.js} +60 -44
  320. package/lib/esm/plain/number/combinations.js +18 -6
  321. package/lib/esm/version.js +1 -1
  322. package/package.json +15 -10
  323. package/types/index.d.ts +44 -2
  324. package/lib/cjs/function/algebra/simplify/resolve.js +0 -76
  325. package/lib/esm/function/algebra/simplify/resolve.js +0 -67
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createSimplifyCore = void 0;
7
7
 
8
- var _is = require("../../../utils/is.js");
8
+ var _is = require("../../utils/is.js");
9
9
 
10
- var _factory = require("../../../utils/factory.js");
10
+ var _util = require("./simplify/util.js");
11
+
12
+ var _factory = require("../../utils/factory.js");
11
13
 
12
14
  var name = 'simplifyCore';
13
- var dependencies = ['equal', 'isZero', 'add', 'subtract', 'multiply', 'divide', 'pow', 'AccessorNode', 'ArrayNode', 'ConstantNode', 'FunctionNode', 'IndexNode', 'ObjectNode', 'OperatorNode', 'ParenthesisNode'];
15
+ var dependencies = ['equal', 'isZero', 'add', 'subtract', 'multiply', 'divide', 'pow', 'AccessorNode', 'ArrayNode', 'ConstantNode', 'FunctionNode', 'IndexNode', 'ObjectNode', 'OperatorNode', 'ParenthesisNode', 'SymbolNode'];
14
16
  var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
15
17
  var equal = _ref.equal,
16
18
  isZero = _ref.isZero,
@@ -26,15 +28,18 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
26
28
  IndexNode = _ref.IndexNode,
27
29
  ObjectNode = _ref.ObjectNode,
28
30
  OperatorNode = _ref.OperatorNode,
29
- ParenthesisNode = _ref.ParenthesisNode;
31
+ ParenthesisNode = _ref.ParenthesisNode,
32
+ SymbolNode = _ref.SymbolNode;
30
33
  var node0 = new ConstantNode(0);
31
34
  var node1 = new ConstantNode(1);
32
35
 
33
- function mapSimplifyCore(nodeArray) {
34
- return nodeArray.map(simplifyCore).map(function (arg) {
35
- return (0, _is.isParenthesisNode)(arg) ? arg.content : arg;
36
- });
37
- }
36
+ var _createUtil = (0, _util.createUtil)({
37
+ FunctionNode: FunctionNode,
38
+ OperatorNode: OperatorNode,
39
+ SymbolNode: SymbolNode
40
+ }),
41
+ hasProperty = _createUtil.hasProperty,
42
+ isCommutative = _createUtil.isCommutative;
38
43
  /**
39
44
  * simplifyCore() performs single pass simplification suitable for
40
45
  * applications requiring ultimate performance. In contrast, simplify()
@@ -43,31 +48,54 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
43
48
  *
44
49
  * Syntax:
45
50
  *
46
- * simplify.simplifyCore(expr)
51
+ * simplifyCore(expr)
47
52
  *
48
53
  * Examples:
49
54
  *
50
55
  * const f = math.parse('2 * 1 * x ^ (2 - 1)')
51
- * math.simplify.simpifyCore(f) // Node {2 * x}
52
- * math.simplify('2 * 1 * x ^ (2 - 1)', [math.simplify.simpifyCore]) // Node {2 * x}
56
+ * math.simpifyCore(f) // Node {2 * x}
57
+ * math.simplify('2 * 1 * x ^ (2 - 1)', [math.simplifyCore]) // Node {2 * x}
53
58
  *
54
59
  * See also:
55
60
  *
56
- * derivative
61
+ * simplify, resolve, derivative
57
62
  *
58
63
  * @param {Node} node
59
64
  * The expression to be simplified
65
+ * @param {Object} options
66
+ * Simplification options, as per simplify()
67
+ * @return {Node} Returns expression with basic simplifications applied
60
68
  */
61
69
 
62
70
 
63
- function simplifyCore(node) {
64
- if ((0, _is.isOperatorNode)(node) && node.isUnary()) {
65
- var a0 = simplifyCore(node.args[0]);
71
+ function simplifyCore(node, options) {
72
+ var context = options ? options.context : undefined;
66
73
 
67
- if (node.op === '+') {
68
- // unary plus
69
- return a0;
74
+ if (hasProperty(node, 'trivial', context)) {
75
+ // This node does nothing if it has only one argument, so if so,
76
+ // return that argument simplified
77
+ if ((0, _is.isFunctionNode)(node) && node.args.length === 1) {
78
+ return simplifyCore(node.args[0], options);
79
+ } // For other node types, we try the generic methods
80
+
81
+
82
+ var simpChild = false;
83
+ var childCount = 0;
84
+ node.forEach(function (c) {
85
+ ++childCount;
86
+
87
+ if (childCount === 1) {
88
+ simpChild = simplifyCore(c, options);
89
+ }
90
+ });
91
+
92
+ if (childCount === 1) {
93
+ return simpChild;
70
94
  }
95
+ }
96
+
97
+ if ((0, _is.isOperatorNode)(node) && node.isUnary()) {
98
+ var a0 = simplifyCore(node.args[0], options);
71
99
 
72
100
  if (node.op === '-') {
73
101
  // unary minus
@@ -82,9 +110,9 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
82
110
  return new OperatorNode(node.op, node.fn, [a0]);
83
111
  }
84
112
  } else if ((0, _is.isOperatorNode)(node) && node.isBinary()) {
85
- var _a = simplifyCore(node.args[0]);
113
+ var _a = simplifyCore(node.args[0], options);
86
114
 
87
- var a1 = simplifyCore(node.args[1]);
115
+ var a1 = simplifyCore(node.args[1], options);
88
116
 
89
117
  if (node.op === '+') {
90
118
  if ((0, _is.isConstantNode)(_a)) {
@@ -120,7 +148,7 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
120
148
  }
121
149
 
122
150
  if ((0, _is.isOperatorNode)(a1) && a1.isUnary() && a1.op === '-') {
123
- return simplifyCore(new OperatorNode('+', 'add', [_a, a1.args[0]]));
151
+ return simplifyCore(new OperatorNode('+', 'add', [_a, a1.args[0]]), options);
124
152
  }
125
153
 
126
154
  return new OperatorNode(node.op, node.fn, [_a, a1]);
@@ -141,7 +169,7 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
141
169
  return node0;
142
170
  } else if (equal(a1.value, 1)) {
143
171
  return _a;
144
- } else if ((0, _is.isOperatorNode)(_a) && _a.isBinary() && _a.op === node.op) {
172
+ } else if ((0, _is.isOperatorNode)(_a) && _a.isBinary() && _a.op === node.op && isCommutative(node, context)) {
145
173
  var a00 = _a.args[0];
146
174
 
147
175
  if ((0, _is.isConstantNode)(a00)) {
@@ -150,7 +178,11 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
150
178
  }
151
179
  }
152
180
 
153
- return new OperatorNode(node.op, node.fn, [a1, _a], node.implicit); // constants on left
181
+ if (isCommutative(node, context)) {
182
+ return new OperatorNode(node.op, node.fn, [a1, _a], node.implicit); // constants on left
183
+ } else {
184
+ return new OperatorNode(node.op, node.fn, [_a, a1], node.implicit);
185
+ }
154
186
  }
155
187
 
156
188
  return new OperatorNode(node.op, node.fn, [_a, a1], node.implicit);
@@ -186,33 +218,25 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
186
218
 
187
219
  return new OperatorNode(node.op, node.fn, [_a, a1]);
188
220
  }
189
- } else if ((0, _is.isParenthesisNode)(node)) {
190
- var c = simplifyCore(node.content);
191
-
192
- if ((0, _is.isParenthesisNode)(c) || (0, _is.isSymbolNode)(c) || (0, _is.isConstantNode)(c)) {
193
- return c;
194
- }
195
-
196
- return new ParenthesisNode(c);
197
221
  } else if ((0, _is.isFunctionNode)(node)) {
198
- return new FunctionNode(simplifyCore(node.fn), mapSimplifyCore(node.args));
222
+ return new FunctionNode(simplifyCore(node.fn), node.args.map(function (n) {
223
+ return simplifyCore(n, options);
224
+ }));
199
225
  } else if ((0, _is.isArrayNode)(node)) {
200
- return new ArrayNode(mapSimplifyCore(node.items));
226
+ return new ArrayNode(node.items.map(function (n) {
227
+ return simplifyCore(n, options);
228
+ }));
201
229
  } else if ((0, _is.isAccessorNode)(node)) {
202
- var obj = mapSimplifyCore(node.object);
203
-
204
- if ((0, _is.isParenthesisNode)(obj)) {
205
- obj = obj.content;
206
- }
207
-
208
- return new AccessorNode(obj, simplifyCore(node.index));
230
+ return new AccessorNode(simplifyCore(node.object, options), simplifyCore(node.index, options));
209
231
  } else if ((0, _is.isIndexNode)(node)) {
210
- return new IndexNode(mapSimplifyCore(node.dimensions));
232
+ return new IndexNode(node.dimensions.map(function (n) {
233
+ return simplifyCore(n, options);
234
+ }));
211
235
  } else if ((0, _is.isObjectNode)(node)) {
212
236
  var newProps = {};
213
237
 
214
238
  for (var prop in node.properties) {
215
- newProps[prop] = simplifyCore(node.properties[prop]);
239
+ newProps[prop] = simplifyCore(node.properties[prop], options);
216
240
  }
217
241
 
218
242
  return new ObjectNode(newProps);
@@ -107,7 +107,7 @@ var createLsolveAll = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
107
107
  }
108
108
  } else if (k === 0) {
109
109
  // singular row, RHS is zero
110
- var bNew = (0, _toConsumableArray2["default"])(b);
110
+ var bNew = (0, _toConsumableArray2.default)(b);
111
111
  bNew[i] = 1;
112
112
 
113
113
  for (var _j = i + 1; _j < columns; _j++) {
@@ -187,7 +187,7 @@ var createLsolveAll = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
187
187
  }
188
188
  } else if (k === 0) {
189
189
  // singular row, RHS is zero
190
- var bNew = (0, _toConsumableArray2["default"])(b);
190
+ var bNew = (0, _toConsumableArray2.default)(b);
191
191
  bNew[i] = 1;
192
192
 
193
193
  for (var _j3 = 0, _lastIndex2 = iIndices.length; _j3 < _lastIndex2; _j3++) {
@@ -107,7 +107,7 @@ var createUsolveAll = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
107
107
  }
108
108
  } else if (k === 0) {
109
109
  // singular row, RHS is zero
110
- var bNew = (0, _toConsumableArray2["default"])(b);
110
+ var bNew = (0, _toConsumableArray2.default)(b);
111
111
  bNew[i] = 1;
112
112
 
113
113
  for (var _j = i - 1; _j >= 0; _j--) {
@@ -187,7 +187,7 @@ var createUsolveAll = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
187
187
  }
188
188
  } else if (k === 0) {
189
189
  // singular row, RHS is zero
190
- var bNew = (0, _toConsumableArray2["default"])(b);
190
+ var bNew = (0, _toConsumableArray2.default)(b);
191
191
  bNew[i] = 1; // loop upper triangular
192
192
 
193
193
  for (var _j3 = 0, _lastIndex2 = iIndices.length; _j3 < _lastIndex2; _j3++) {
@@ -91,7 +91,7 @@ var createCeil = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
91
91
  return round(x, n);
92
92
  } else {
93
93
  var _$split = "".concat(x, "e").split('e'),
94
- _$split2 = (0, _slicedToArray2["default"])(_$split, 2),
94
+ _$split2 = (0, _slicedToArray2.default)(_$split, 2),
95
95
  number = _$split2[0],
96
96
  exponent = _$split2[1];
97
97
 
@@ -99,7 +99,7 @@ var createCeil = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
99
99
 
100
100
  var _$split3 = "".concat(result, "e").split('e');
101
101
 
102
- var _$split4 = (0, _slicedToArray2["default"])(_$split3, 2);
102
+ var _$split4 = (0, _slicedToArray2.default)(_$split3, 2);
103
103
 
104
104
  number = _$split4[0];
105
105
  exponent = _$split4[1];
@@ -123,7 +123,7 @@ var createCeil = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
123
123
  if ((0, _nearlyEqual.nearlyEqual)(x, round(x, n), config.epsilon)) {
124
124
  return round(x, n);
125
125
  } else {
126
- return x.toDecimalPlaces(n.toNumber(), _decimal["default"].ROUND_CEIL);
126
+ return x.toDecimalPlaces(n.toNumber(), _decimal.default.ROUND_CEIL);
127
127
  }
128
128
  },
129
129
  Fraction: function Fraction(x) {
@@ -88,7 +88,7 @@ var createFloor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
88
88
  return round(x, n);
89
89
  } else {
90
90
  var _$split = "".concat(x, "e").split('e'),
91
- _$split2 = (0, _slicedToArray2["default"])(_$split, 2),
91
+ _$split2 = (0, _slicedToArray2.default)(_$split, 2),
92
92
  number = _$split2[0],
93
93
  exponent = _$split2[1];
94
94
 
@@ -96,7 +96,7 @@ var createFloor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
96
96
 
97
97
  var _$split3 = "".concat(result, "e").split('e');
98
98
 
99
- var _$split4 = (0, _slicedToArray2["default"])(_$split3, 2);
99
+ var _$split4 = (0, _slicedToArray2.default)(_$split3, 2);
100
100
 
101
101
  number = _$split4[0];
102
102
  exponent = _$split4[1];
@@ -120,7 +120,7 @@ var createFloor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
120
120
  if ((0, _nearlyEqual.nearlyEqual)(x, round(x, n), config.epsilon)) {
121
121
  return round(x, n);
122
122
  } else {
123
- return x.toDecimalPlaces(n.toNumber(), _decimal["default"].ROUND_FLOOR);
123
+ return x.toDecimalPlaces(n.toNumber(), _decimal.default.ROUND_FLOOR);
124
124
  }
125
125
  },
126
126
  Fraction: function Fraction(x) {
@@ -60,7 +60,7 @@ var createInvmod = /* #__PURE__ */(0, _factory.factory)(name, dependencies, func
60
60
  res = res.valueOf();
61
61
 
62
62
  var _res = res,
63
- _res2 = (0, _slicedToArray2["default"])(_res, 2),
63
+ _res2 = (0, _slicedToArray2.default)(_res, 2),
64
64
  gcd = _res2[0],
65
65
  inv = _res2[1];
66
66
 
@@ -71,7 +71,7 @@ var createNorm = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
71
71
  // norm(x) = abs(x)
72
72
  return x.abs();
73
73
  },
74
- "boolean": function boolean(x) {
74
+ boolean: function boolean(x) {
75
75
  // norm(x) = abs(x)
76
76
  return Math.abs(x);
77
77
  },
@@ -25,7 +25,7 @@ var _index = require("../../plain/number/index.js");
25
25
 
26
26
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
27
 
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
28
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
29
 
30
30
  var NO_INT = 'Number of decimals in function round must be an integer';
31
31
  var name = 'round';
@@ -11,7 +11,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
11
11
 
12
12
  var _object = require("../../../utils/object.js");
13
13
 
14
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
14
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
15
15
 
16
16
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
17
 
@@ -80,7 +80,7 @@ function createComplexEigs(_ref) {
80
80
 
81
81
  if (findVectors) {
82
82
  vectors = findEigenvectors(arr, N, C, values, prec, type);
83
- vectors = matrixFromColumns.apply(void 0, (0, _toConsumableArray2["default"])(vectors));
83
+ vectors = matrixFromColumns.apply(void 0, (0, _toConsumableArray2.default)(vectors));
84
84
  }
85
85
 
86
86
  return {
@@ -360,7 +360,7 @@ function createComplexEigs(_ref) {
360
360
  } else if (n === 2 || smaller(abs(arr[n - 2][n - 3]), prec)) {
361
361
  lastConvergenceBefore = 0;
362
362
  var ll = eigenvalues2x2(arr[n - 2][n - 2], arr[n - 2][n - 1], arr[n - 1][n - 2], arr[n - 1][n - 1]);
363
- lambdas.push.apply(lambdas, (0, _toConsumableArray2["default"])(ll)); // keep track of transformations
363
+ lambdas.push.apply(lambdas, (0, _toConsumableArray2.default)(ll)); // keep track of transformations
364
364
 
365
365
  if (findVectors) {
366
366
  Sdiag.unshift(jordanBase2x2(arr[n - 2][n - 2], arr[n - 2][n - 1], arr[n - 1][n - 2], arr[n - 1][n - 1], ll[0], ll[1], prec, type));
@@ -488,7 +488,7 @@ function createComplexEigs(_ref) {
488
488
  solutions.push(approxVec);
489
489
  }
490
490
 
491
- vectors.push.apply(vectors, (0, _toConsumableArray2["default"])(solutions.map(function (v) {
491
+ vectors.push.apply(vectors, (0, _toConsumableArray2.default)(solutions.map(function (v) {
492
492
  return flatten(v);
493
493
  })));
494
494
  }
@@ -568,7 +568,7 @@ function createComplexEigs(_ref) {
568
568
  for (var i = 0; i < arr.length; i++) {
569
569
  var _arr$i;
570
570
 
571
- (_arr$i = arr[i]).push.apply(_arr$i, (0, _toConsumableArray2["default"])(Array(N - arr[i].length).fill(0)));
571
+ (_arr$i = arr[i]).push.apply(_arr$i, (0, _toConsumableArray2.default)(Array(N - arr[i].length).fill(0)));
572
572
  } // add rows
573
573
 
574
574
 
@@ -7,7 +7,7 @@ exports.createMatrixFromColumns = void 0;
7
7
 
8
8
  var _factory = require("../../utils/factory.js");
9
9
 
10
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
10
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
11
11
 
12
12
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
13
 
@@ -7,7 +7,7 @@ exports.createMatrixFromRows = void 0;
7
7
 
8
8
  var _factory = require("../../utils/factory.js");
9
9
 
10
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
10
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
11
11
 
12
12
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
13
 
@@ -9,13 +9,13 @@ exports.createRng = createRng;
9
9
 
10
10
  var _seedrandom = _interopRequireDefault(require("seedrandom"));
11
11
 
12
- var singletonRandom = /* #__PURE__ */(0, _seedrandom["default"])(Date.now());
12
+ var singletonRandom = /* #__PURE__ */(0, _seedrandom.default)(Date.now());
13
13
 
14
14
  function createRng(randomSeed) {
15
15
  var random; // create a new random generator with given seed
16
16
 
17
17
  function setSeed(seed) {
18
- random = seed === null ? singletonRandom : (0, _seedrandom["default"])(String(seed));
18
+ random = seed === null ? singletonRandom : (0, _seedrandom.default)(String(seed));
19
19
  } // initialize a seeded pseudo random number generator with config's random seed
20
20
 
21
21
 
@@ -101,7 +101,7 @@ var createCompareNatural = /* #__PURE__ */(0, _factory.factory)(name, dependenci
101
101
  // c can be number, BigNumber, or Fraction
102
102
  return c > 0 ? 1 : -1; // return a number
103
103
  } else {
104
- return (0, _javascriptNaturalSort["default"])(typeX, typeY);
104
+ return (0, _javascriptNaturalSort.default)(typeX, typeY);
105
105
  }
106
106
  } // matrix types
107
107
 
@@ -112,13 +112,13 @@ var createCompareNatural = /* #__PURE__ */(0, _factory.factory)(name, dependenci
112
112
  if (c !== 0) {
113
113
  return c;
114
114
  } else {
115
- return (0, _javascriptNaturalSort["default"])(typeX, typeY);
115
+ return (0, _javascriptNaturalSort.default)(typeX, typeY);
116
116
  }
117
117
  } // in case of different types, order by name of type, i.e. 'BigNumber' < 'Complex'
118
118
 
119
119
 
120
120
  if (typeX !== typeY) {
121
- return (0, _javascriptNaturalSort["default"])(typeX, typeY);
121
+ return (0, _javascriptNaturalSort.default)(typeX, typeY);
122
122
  }
123
123
 
124
124
  if (typeX === 'Complex') {
@@ -139,7 +139,7 @@ var createCompareNatural = /* #__PURE__ */(0, _factory.factory)(name, dependenci
139
139
  }
140
140
 
141
141
  if (typeX === 'string') {
142
- return (0, _javascriptNaturalSort["default"])(x, y);
142
+ return (0, _javascriptNaturalSort.default)(x, y);
143
143
  }
144
144
 
145
145
  if (typeX === 'Object') {
@@ -252,8 +252,8 @@ var createCompareNatural = /* #__PURE__ */(0, _factory.factory)(name, dependenci
252
252
  var keysX = Object.keys(x);
253
253
  var keysY = Object.keys(y); // compare keys
254
254
 
255
- keysX.sort(_javascriptNaturalSort["default"]);
256
- keysY.sort(_javascriptNaturalSort["default"]);
255
+ keysX.sort(_javascriptNaturalSort.default);
256
+ keysY.sort(_javascriptNaturalSort.default);
257
257
  var c = compareArrays(compareNatural, keysX, keysY);
258
258
 
259
259
  if (c !== 0) {
package/lib/cjs/header.js CHANGED
@@ -6,8 +6,8 @@
6
6
  * It features real and complex numbers, units, matrices, a large set of
7
7
  * mathematical functions, and a flexible expression parser.
8
8
  *
9
- * @version 10.1.1
10
- * @date 2022-02-02
9
+ * @version 10.2.0
10
+ * @date 2022-03-01
11
11
  *
12
12
  * @license
13
13
  * Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
@@ -27,7 +27,7 @@ Object.keys(_arithmetic).forEach(function (key) {
27
27
  });
28
28
 
29
29
  // TODO: this is ugly. Instead, be able to pass your own isBigNumber function to typed?
30
- var BigNumber = _decimal["default"].clone();
30
+ var BigNumber = _decimal.default.clone();
31
31
 
32
32
  BigNumber.prototype.isBigNumber = true;
33
33
 
@@ -23,15 +23,27 @@ function combinationsNumber(n, k) {
23
23
  }
24
24
 
25
25
  var nMinusk = n - k;
26
- var prodrange;
26
+ var answer = 1;
27
+ var firstnumerator = k < nMinusk ? nMinusk + 1 : k + 1;
28
+ var nextdivisor = 2;
29
+ var lastdivisor = k < nMinusk ? k : nMinusk; // balance multiplications and divisions to try to keep intermediate values
30
+ // in exact-integer range as long as possible
27
31
 
28
- if (k < nMinusk) {
29
- prodrange = (0, _product.product)(nMinusk + 1, n);
30
- return prodrange / (0, _product.product)(1, k);
32
+ for (var nextnumerator = firstnumerator; nextnumerator <= n; ++nextnumerator) {
33
+ answer *= nextnumerator;
34
+
35
+ while (nextdivisor <= lastdivisor && answer % nextdivisor === 0) {
36
+ answer /= nextdivisor;
37
+ ++nextdivisor;
38
+ }
39
+ } // for big n, k, floating point may have caused weirdness in remainder
40
+
41
+
42
+ if (nextdivisor <= lastdivisor) {
43
+ answer /= (0, _product.product)(nextdivisor, lastdivisor);
31
44
  }
32
45
 
33
- prodrange = (0, _product.product)(k + 1, n);
34
- return prodrange / (0, _product.product)(1, nMinusk);
46
+ return answer;
35
47
  }
36
48
 
37
49
  combinationsNumber.signature = 'number, number';
@@ -17,9 +17,9 @@ var createBigNumberClass = /* #__PURE__ */(0, _factory.factory)(name, dependenci
17
17
  var on = _ref.on,
18
18
  config = _ref.config;
19
19
 
20
- var BigNumber = _decimal["default"].clone({
20
+ var BigNumber = _decimal.default.clone({
21
21
  precision: config.precision,
22
- modulo: _decimal["default"].EUCLID
22
+ modulo: _decimal.default.EUCLID
23
23
  });
24
24
 
25
25
  BigNumber.prototype = Object.create(BigNumber.prototype);
@@ -79,7 +79,7 @@ var createBignumber = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
79
79
  Fraction: function Fraction(x) {
80
80
  return new BigNumber(x.n).div(x.d).times(x.s);
81
81
  },
82
- "null": function _null(x) {
82
+ null: function _null(x) {
83
83
  return new BigNumber(0);
84
84
  },
85
85
  'Array | Matrix': function ArrayMatrix(x) {
@@ -45,13 +45,13 @@ var createBoolean = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fun
45
45
  '': function _() {
46
46
  return false;
47
47
  },
48
- "boolean": function boolean(x) {
48
+ boolean: function boolean(x) {
49
49
  return x;
50
50
  },
51
51
  number: function number(x) {
52
52
  return !!x;
53
53
  },
54
- "null": function _null(x) {
54
+ null: function _null(x) {
55
55
  return false;
56
56
  },
57
57
  BigNumber: function BigNumber(x) {