mathjs 10.1.1 → 10.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (369) hide show
  1. package/HISTORY.md +43 -0
  2. package/docs/expressions/algebra.md +27 -0
  3. package/docs/expressions/syntax.md +31 -2
  4. package/docs/reference/functions/abs.md +6 -0
  5. package/docs/reference/functions/acos.md +6 -0
  6. package/docs/reference/functions/acosh.md +6 -0
  7. package/docs/reference/functions/acot.md +6 -0
  8. package/docs/reference/functions/acoth.md +6 -0
  9. package/docs/reference/functions/acsc.md +6 -0
  10. package/docs/reference/functions/acsch.md +6 -0
  11. package/docs/reference/functions/add.md +6 -0
  12. package/docs/reference/functions/and.md +6 -0
  13. package/docs/reference/functions/apply.md +6 -0
  14. package/docs/reference/functions/arg.md +6 -0
  15. package/docs/reference/functions/asec.md +6 -0
  16. package/docs/reference/functions/asech.md +6 -0
  17. package/docs/reference/functions/asin.md +6 -0
  18. package/docs/reference/functions/asinh.md +6 -0
  19. package/docs/reference/functions/atan.md +6 -0
  20. package/docs/reference/functions/atan2.md +6 -0
  21. package/docs/reference/functions/atanh.md +6 -0
  22. package/docs/reference/functions/bellNumbers.md +6 -0
  23. package/docs/reference/functions/bin.md +6 -0
  24. package/docs/reference/functions/bitAnd.md +6 -0
  25. package/docs/reference/functions/bitNot.md +6 -0
  26. package/docs/reference/functions/bitOr.md +6 -0
  27. package/docs/reference/functions/bitXor.md +6 -0
  28. package/docs/reference/functions/catalan.md +6 -0
  29. package/docs/reference/functions/cbrt.md +6 -0
  30. package/docs/reference/functions/ceil.md +6 -0
  31. package/docs/reference/functions/clone.md +6 -0
  32. package/docs/reference/functions/column.md +6 -0
  33. package/docs/reference/functions/combinations.md +6 -0
  34. package/docs/reference/functions/combinationsWithRep.md +6 -0
  35. package/docs/reference/functions/compare.md +6 -0
  36. package/docs/reference/functions/compareNatural.md +6 -0
  37. package/docs/reference/functions/compareText.md +6 -0
  38. package/docs/reference/functions/compile.md +6 -0
  39. package/docs/reference/functions/composition.md +6 -0
  40. package/docs/reference/functions/concat.md +6 -0
  41. package/docs/reference/functions/conj.md +6 -0
  42. package/docs/reference/functions/cos.md +6 -0
  43. package/docs/reference/functions/cosh.md +6 -0
  44. package/docs/reference/functions/cot.md +6 -0
  45. package/docs/reference/functions/coth.md +6 -0
  46. package/docs/reference/functions/count.md +6 -0
  47. package/docs/reference/functions/cross.md +6 -0
  48. package/docs/reference/functions/csc.md +6 -0
  49. package/docs/reference/functions/csch.md +6 -0
  50. package/docs/reference/functions/ctranspose.md +6 -0
  51. package/docs/reference/functions/cube.md +6 -0
  52. package/docs/reference/functions/cumsum.md +57 -0
  53. package/docs/reference/functions/deepEqual.md +6 -0
  54. package/docs/reference/functions/derivative.md +6 -0
  55. package/docs/reference/functions/det.md +6 -0
  56. package/docs/reference/functions/diag.md +6 -0
  57. package/docs/reference/functions/diff.md +6 -0
  58. package/docs/reference/functions/distance.md +6 -0
  59. package/docs/reference/functions/divide.md +6 -0
  60. package/docs/reference/functions/dot.md +6 -0
  61. package/docs/reference/functions/dotDivide.md +6 -0
  62. package/docs/reference/functions/dotMultiply.md +6 -0
  63. package/docs/reference/functions/dotPow.md +6 -0
  64. package/docs/reference/functions/eigs.md +6 -0
  65. package/docs/reference/functions/equal.md +6 -0
  66. package/docs/reference/functions/equalText.md +6 -0
  67. package/docs/reference/functions/erf.md +6 -0
  68. package/docs/reference/functions/evaluate.md +6 -0
  69. package/docs/reference/functions/exp.md +6 -0
  70. package/docs/reference/functions/expm.md +6 -0
  71. package/docs/reference/functions/expm1.md +6 -0
  72. package/docs/reference/functions/factorial.md +6 -0
  73. package/docs/reference/functions/filter.md +6 -0
  74. package/docs/reference/functions/fix.md +6 -0
  75. package/docs/reference/functions/flatten.md +6 -0
  76. package/docs/reference/functions/floor.md +6 -0
  77. package/docs/reference/functions/forEach.md +6 -0
  78. package/docs/reference/functions/format.md +7 -1
  79. package/docs/reference/functions/gamma.md +6 -0
  80. package/docs/reference/functions/gcd.md +6 -0
  81. package/docs/reference/functions/getMatrixDataType.md +6 -0
  82. package/docs/reference/functions/hasNumericValue.md +6 -0
  83. package/docs/reference/functions/help.md +6 -0
  84. package/docs/reference/functions/hex.md +6 -0
  85. package/docs/reference/functions/hypot.md +6 -0
  86. package/docs/reference/functions/identity.md +6 -0
  87. package/docs/reference/functions/im.md +6 -0
  88. package/docs/reference/functions/intersect.md +6 -0
  89. package/docs/reference/functions/inv.md +6 -0
  90. package/docs/reference/functions/invmod.md +6 -0
  91. package/docs/reference/functions/isInteger.md +6 -0
  92. package/docs/reference/functions/isNaN.md +6 -0
  93. package/docs/reference/functions/isNegative.md +6 -0
  94. package/docs/reference/functions/isNumeric.md +6 -0
  95. package/docs/reference/functions/isPositive.md +6 -0
  96. package/docs/reference/functions/isPrime.md +6 -0
  97. package/docs/reference/functions/isZero.md +6 -0
  98. package/docs/reference/functions/kldivergence.md +6 -0
  99. package/docs/reference/functions/kron.md +6 -0
  100. package/docs/reference/functions/larger.md +6 -0
  101. package/docs/reference/functions/largerEq.md +6 -0
  102. package/docs/reference/functions/lcm.md +6 -0
  103. package/docs/reference/functions/leafCount.md +52 -0
  104. package/docs/reference/functions/leftShift.md +6 -0
  105. package/docs/reference/functions/log.md +6 -0
  106. package/docs/reference/functions/log10.md +6 -0
  107. package/docs/reference/functions/log1p.md +6 -0
  108. package/docs/reference/functions/log2.md +6 -0
  109. package/docs/reference/functions/lsolve.md +6 -0
  110. package/docs/reference/functions/lsolveAll.md +6 -0
  111. package/docs/reference/functions/lup.md +6 -0
  112. package/docs/reference/functions/lusolve.md +6 -0
  113. package/docs/reference/functions/mad.md +6 -0
  114. package/docs/reference/functions/map.md +28 -5
  115. package/docs/reference/functions/matrixFromColumns.md +6 -0
  116. package/docs/reference/functions/matrixFromFunction.md +6 -0
  117. package/docs/reference/functions/matrixFromRows.md +6 -0
  118. package/docs/reference/functions/max.md +6 -0
  119. package/docs/reference/functions/mean.md +6 -0
  120. package/docs/reference/functions/median.md +6 -0
  121. package/docs/reference/functions/min.md +6 -0
  122. package/docs/reference/functions/mod.md +6 -0
  123. package/docs/reference/functions/mode.md +6 -0
  124. package/docs/reference/functions/multinomial.md +6 -0
  125. package/docs/reference/functions/multiply.md +6 -0
  126. package/docs/reference/functions/norm.md +6 -0
  127. package/docs/reference/functions/not.md +6 -0
  128. package/docs/reference/functions/nthRoot.md +6 -0
  129. package/docs/reference/functions/nthRoots.md +6 -0
  130. package/docs/reference/functions/numeric.md +6 -0
  131. package/docs/reference/functions/oct.md +6 -0
  132. package/docs/reference/functions/ones.md +6 -0
  133. package/docs/reference/functions/or.md +6 -0
  134. package/docs/reference/functions/parser.md +6 -0
  135. package/docs/reference/functions/partitionSelect.md +6 -0
  136. package/docs/reference/functions/permutations.md +6 -0
  137. package/docs/reference/functions/pickRandom.md +6 -0
  138. package/docs/reference/functions/pow.md +6 -0
  139. package/docs/reference/functions/print.md +6 -0
  140. package/docs/reference/functions/prod.md +6 -0
  141. package/docs/reference/functions/qr.md +6 -0
  142. package/docs/reference/functions/quantileSeq.md +6 -0
  143. package/docs/reference/functions/random.md +6 -0
  144. package/docs/reference/functions/randomInt.md +6 -0
  145. package/docs/reference/functions/range.md +6 -0
  146. package/docs/reference/functions/rationalize.md +7 -1
  147. package/docs/reference/functions/re.md +6 -0
  148. package/docs/reference/functions/reshape.md +7 -0
  149. package/docs/reference/functions/resize.md +6 -0
  150. package/docs/reference/functions/resolve.md +46 -0
  151. package/docs/reference/functions/rightArithShift.md +6 -0
  152. package/docs/reference/functions/rightLogShift.md +6 -0
  153. package/docs/reference/functions/rotate.md +6 -0
  154. package/docs/reference/functions/rotationMatrix.md +6 -0
  155. package/docs/reference/functions/round.md +6 -0
  156. package/docs/reference/functions/row.md +6 -0
  157. package/docs/reference/functions/sec.md +6 -0
  158. package/docs/reference/functions/sech.md +6 -0
  159. package/docs/reference/functions/setCartesian.md +6 -0
  160. package/docs/reference/functions/setDifference.md +6 -0
  161. package/docs/reference/functions/setDistinct.md +6 -0
  162. package/docs/reference/functions/setIntersect.md +6 -0
  163. package/docs/reference/functions/setIsSubset.md +6 -0
  164. package/docs/reference/functions/setMultiplicity.md +6 -0
  165. package/docs/reference/functions/setPowerset.md +6 -0
  166. package/docs/reference/functions/setSize.md +6 -0
  167. package/docs/reference/functions/setSymDifference.md +6 -0
  168. package/docs/reference/functions/setUnion.md +6 -0
  169. package/docs/reference/functions/sign.md +6 -0
  170. package/docs/reference/functions/simplify.md +43 -6
  171. package/docs/reference/functions/simplifyCore.md +50 -0
  172. package/docs/reference/functions/sin.md +6 -0
  173. package/docs/reference/functions/sinh.md +6 -0
  174. package/docs/reference/functions/size.md +6 -0
  175. package/docs/reference/functions/slu.md +6 -0
  176. package/docs/reference/functions/smaller.md +6 -0
  177. package/docs/reference/functions/smallerEq.md +6 -0
  178. package/docs/reference/functions/sort.md +6 -0
  179. package/docs/reference/functions/sqrt.md +6 -0
  180. package/docs/reference/functions/sqrtm.md +6 -0
  181. package/docs/reference/functions/square.md +6 -0
  182. package/docs/reference/functions/squeeze.md +6 -0
  183. package/docs/reference/functions/std.md +6 -0
  184. package/docs/reference/functions/stirlingS2.md +6 -0
  185. package/docs/reference/functions/subset.md +16 -2
  186. package/docs/reference/functions/subtract.md +6 -0
  187. package/docs/reference/functions/sum.md +8 -1
  188. package/docs/reference/functions/symbolicEqual.md +62 -0
  189. package/docs/reference/functions/tan.md +6 -0
  190. package/docs/reference/functions/tanh.md +6 -0
  191. package/docs/reference/functions/to.md +6 -0
  192. package/docs/reference/functions/trace.md +6 -0
  193. package/docs/reference/functions/transpose.md +6 -0
  194. package/docs/reference/functions/typeOf.md +6 -0
  195. package/docs/reference/functions/unaryMinus.md +6 -0
  196. package/docs/reference/functions/unaryPlus.md +6 -0
  197. package/docs/reference/functions/unequal.md +6 -0
  198. package/docs/reference/functions/usolve.md +6 -0
  199. package/docs/reference/functions/usolveAll.md +6 -0
  200. package/docs/reference/functions/variance.md +6 -0
  201. package/docs/reference/functions/xgcd.md +6 -0
  202. package/docs/reference/functions/xor.md +6 -0
  203. package/docs/reference/functions/zeros.md +6 -0
  204. package/docs/reference/functions.md +6 -1
  205. package/lib/browser/math.js +6 -6
  206. package/lib/browser/math.js.map +1 -1
  207. package/lib/cjs/core/create.js +4 -4
  208. package/lib/cjs/core/function/import.js +3 -3
  209. package/lib/cjs/core/function/typed.js +2 -2
  210. package/lib/cjs/defaultInstance.js +3 -3
  211. package/lib/cjs/entry/allFactoriesAny.js +1 -1
  212. package/lib/cjs/entry/allFactoriesNumber.js +1 -1
  213. package/lib/cjs/entry/configReadonly.js +1 -1
  214. package/lib/cjs/entry/dependenciesAny/dependenciesCumSum.generated.js +26 -0
  215. package/lib/cjs/entry/dependenciesAny/dependenciesCumSumTransform.generated.js +26 -0
  216. package/lib/cjs/entry/dependenciesAny/dependenciesLeafCount.generated.js +23 -0
  217. package/lib/cjs/entry/dependenciesAny/dependenciesRationalize.generated.js +3 -0
  218. package/lib/cjs/entry/dependenciesAny/dependenciesResolve.generated.js +32 -0
  219. package/lib/cjs/entry/dependenciesAny/dependenciesSimplify.generated.js +6 -0
  220. package/lib/cjs/entry/dependenciesAny/dependenciesSimplifyCore.generated.js +65 -0
  221. package/lib/cjs/entry/dependenciesAny/dependenciesSymbolicEqual.generated.js +29 -0
  222. package/lib/cjs/entry/dependenciesAny.generated.js +48 -0
  223. package/lib/cjs/entry/dependenciesNumber/dependenciesCumSum.generated.js +26 -0
  224. package/lib/cjs/entry/dependenciesNumber/dependenciesCumSumTransform.generated.js +26 -0
  225. package/lib/cjs/entry/dependenciesNumber/dependenciesRationalize.generated.js +3 -0
  226. package/lib/cjs/entry/dependenciesNumber/dependenciesResolve.generated.js +32 -0
  227. package/lib/cjs/entry/dependenciesNumber/dependenciesSimplify.generated.js +6 -0
  228. package/lib/cjs/entry/dependenciesNumber/dependenciesSimplifyCore.generated.js +65 -0
  229. package/lib/cjs/entry/dependenciesNumber.generated.js +32 -0
  230. package/lib/cjs/entry/impureFunctionsAny.generated.js +85 -33
  231. package/lib/cjs/entry/impureFunctionsNumber.generated.js +102 -64
  232. package/lib/cjs/entry/pureFunctionsAny.generated.js +68 -64
  233. package/lib/cjs/entry/pureFunctionsNumber.generated.js +51 -47
  234. package/lib/cjs/expression/Help.js +4 -0
  235. package/lib/cjs/expression/Parser.js +1 -1
  236. package/lib/cjs/expression/embeddedDocs/construction/fraction.js +3 -3
  237. package/lib/cjs/expression/embeddedDocs/core/typed.js +1 -1
  238. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +250 -235
  239. package/lib/cjs/expression/embeddedDocs/function/algebra/leafCount.js +15 -0
  240. package/lib/cjs/expression/embeddedDocs/function/algebra/resolve.js +16 -0
  241. package/lib/cjs/expression/embeddedDocs/function/algebra/simplify.js +1 -1
  242. package/lib/cjs/expression/embeddedDocs/function/algebra/simplifyCore.js +15 -0
  243. package/lib/cjs/expression/embeddedDocs/function/algebra/symbolicEqual.js +15 -0
  244. package/lib/cjs/expression/embeddedDocs/function/matrix/subset.js +2 -2
  245. package/lib/cjs/expression/embeddedDocs/function/statistics/cumsum.js +15 -0
  246. package/lib/cjs/expression/node/FunctionNode.js +80 -61
  247. package/lib/cjs/expression/node/IndexNode.js +1 -1
  248. package/lib/cjs/expression/node/Node.js +3 -3
  249. package/lib/cjs/expression/node/ObjectNode.js +1 -1
  250. package/lib/cjs/expression/node/utils/access.js +1 -1
  251. package/lib/cjs/expression/node/utils/assign.js +1 -1
  252. package/lib/cjs/expression/parse.js +13 -13
  253. package/lib/cjs/expression/transform/cumsum.transform.js +57 -0
  254. package/lib/cjs/expression/transform/sum.transform.js +1 -1
  255. package/lib/cjs/factoriesAny.js +48 -0
  256. package/lib/cjs/factoriesNumber.js +33 -1
  257. package/lib/cjs/function/algebra/decomposition/qr.js +1 -1
  258. package/lib/cjs/function/algebra/leafCount.js +66 -0
  259. package/lib/cjs/function/algebra/rationalize.js +24 -41
  260. package/lib/cjs/function/algebra/resolve.js +106 -0
  261. package/lib/cjs/function/algebra/simplify/simplifyConstant.js +5 -5
  262. package/lib/cjs/function/algebra/simplify/util.js +171 -33
  263. package/lib/cjs/function/algebra/simplify.js +562 -207
  264. package/lib/cjs/function/algebra/{simplify/simplifyCore.js → simplifyCore.js} +68 -44
  265. package/lib/cjs/function/algebra/solver/lsolveAll.js +2 -2
  266. package/lib/cjs/function/algebra/solver/usolveAll.js +2 -2
  267. package/lib/cjs/function/algebra/symbolicEqual.js +88 -0
  268. package/lib/cjs/function/arithmetic/ceil.js +3 -3
  269. package/lib/cjs/function/arithmetic/floor.js +3 -3
  270. package/lib/cjs/function/arithmetic/invmod.js +1 -1
  271. package/lib/cjs/function/arithmetic/norm.js +1 -1
  272. package/lib/cjs/function/arithmetic/round.js +1 -1
  273. package/lib/cjs/function/matrix/eigs/complexEigs.js +13 -11
  274. package/lib/cjs/function/matrix/map.js +53 -15
  275. package/lib/cjs/function/matrix/matrixFromColumns.js +1 -1
  276. package/lib/cjs/function/matrix/matrixFromRows.js +1 -1
  277. package/lib/cjs/function/matrix/subset.js +15 -5
  278. package/lib/cjs/function/probability/util/seededRNG.js +2 -2
  279. package/lib/cjs/function/relational/compareNatural.js +6 -6
  280. package/lib/cjs/function/statistics/cumsum.js +151 -0
  281. package/lib/cjs/function/statistics/sum.js +1 -1
  282. package/lib/cjs/function/string/format.js +1 -1
  283. package/lib/cjs/header.js +2 -2
  284. package/lib/cjs/plain/bignumber/index.js +1 -1
  285. package/lib/cjs/plain/number/combinations.js +18 -6
  286. package/lib/cjs/type/bignumber/BigNumber.js +2 -2
  287. package/lib/cjs/type/bignumber/function/bignumber.js +1 -1
  288. package/lib/cjs/type/boolean.js +2 -2
  289. package/lib/cjs/type/complex/Complex.js +14 -14
  290. package/lib/cjs/type/complex/function/complex.js +1 -1
  291. package/lib/cjs/type/fraction/Fraction.js +6 -6
  292. package/lib/cjs/type/fraction/function/fraction.js +21 -9
  293. package/lib/cjs/type/matrix/DenseMatrix.js +5 -5
  294. package/lib/cjs/type/matrix/SparseMatrix.js +2 -2
  295. package/lib/cjs/type/number.js +1 -1
  296. package/lib/cjs/type/string.js +2 -2
  297. package/lib/cjs/type/unit/Unit.js +8 -8
  298. package/lib/cjs/utils/collection.js +3 -27
  299. package/lib/cjs/utils/customs.js +2 -2
  300. package/lib/cjs/utils/emitter.js +1 -1
  301. package/lib/cjs/utils/function.js +2 -2
  302. package/lib/cjs/utils/is.js +6 -6
  303. package/lib/cjs/utils/latex.js +3 -3
  304. package/lib/cjs/utils/lruQueue.js +1 -1
  305. package/lib/cjs/utils/map.js +3 -3
  306. package/lib/cjs/utils/object.js +2 -2
  307. package/lib/cjs/utils/snapshot.js +7 -7
  308. package/lib/cjs/utils/string.js +2 -2
  309. package/lib/cjs/utils/switch.js +31 -0
  310. package/lib/cjs/version.js +1 -1
  311. package/lib/esm/entry/dependenciesAny/dependenciesCumSum.generated.js +14 -0
  312. package/lib/esm/entry/dependenciesAny/dependenciesCumSumTransform.generated.js +14 -0
  313. package/lib/esm/entry/dependenciesAny/dependenciesLeafCount.generated.js +12 -0
  314. package/lib/esm/entry/dependenciesAny/dependenciesRationalize.generated.js +2 -0
  315. package/lib/esm/entry/dependenciesAny/dependenciesResolve.generated.js +18 -0
  316. package/lib/esm/entry/dependenciesAny/dependenciesSimplify.generated.js +4 -0
  317. package/lib/esm/entry/dependenciesAny/dependenciesSimplifyCore.generated.js +40 -0
  318. package/lib/esm/entry/dependenciesAny/dependenciesSymbolicEqual.generated.js +16 -0
  319. package/lib/esm/entry/dependenciesAny.generated.js +6 -0
  320. package/lib/esm/entry/dependenciesNumber/dependenciesCumSum.generated.js +14 -0
  321. package/lib/esm/entry/dependenciesNumber/dependenciesCumSumTransform.generated.js +14 -0
  322. package/lib/esm/entry/dependenciesNumber/dependenciesRationalize.generated.js +2 -0
  323. package/lib/esm/entry/dependenciesNumber/dependenciesResolve.generated.js +18 -0
  324. package/lib/esm/entry/dependenciesNumber/dependenciesSimplify.generated.js +4 -0
  325. package/lib/esm/entry/dependenciesNumber/dependenciesSimplifyCore.generated.js +40 -0
  326. package/lib/esm/entry/dependenciesNumber.generated.js +4 -0
  327. package/lib/esm/entry/impureFunctionsAny.generated.js +74 -26
  328. package/lib/esm/entry/impureFunctionsNumber.generated.js +89 -53
  329. package/lib/esm/entry/pureFunctionsAny.generated.js +54 -49
  330. package/lib/esm/entry/pureFunctionsNumber.generated.js +36 -31
  331. package/lib/esm/expression/Help.js +4 -0
  332. package/lib/esm/expression/embeddedDocs/construction/fraction.js +3 -3
  333. package/lib/esm/expression/embeddedDocs/core/typed.js +1 -1
  334. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +222 -212
  335. package/lib/esm/expression/embeddedDocs/function/algebra/leafCount.js +8 -0
  336. package/lib/esm/expression/embeddedDocs/function/algebra/resolve.js +9 -0
  337. package/lib/esm/expression/embeddedDocs/function/algebra/simplify.js +1 -1
  338. package/lib/esm/expression/embeddedDocs/function/algebra/simplifyCore.js +8 -0
  339. package/lib/esm/expression/embeddedDocs/function/algebra/symbolicEqual.js +8 -0
  340. package/lib/esm/expression/embeddedDocs/function/matrix/subset.js +2 -2
  341. package/lib/esm/expression/embeddedDocs/function/statistics/cumsum.js +8 -0
  342. package/lib/esm/expression/node/FunctionNode.js +70 -53
  343. package/lib/esm/expression/transform/cumsum.transform.js +48 -0
  344. package/lib/esm/expression/transform/sum.transform.js +1 -1
  345. package/lib/esm/factoriesAny.js +6 -0
  346. package/lib/esm/factoriesNumber.js +4 -0
  347. package/lib/esm/function/algebra/leafCount.js +59 -0
  348. package/lib/esm/function/algebra/rationalize.js +24 -40
  349. package/lib/esm/function/algebra/resolve.js +95 -0
  350. package/lib/esm/function/algebra/simplify/simplifyConstant.js +3 -3
  351. package/lib/esm/function/algebra/simplify/util.js +170 -34
  352. package/lib/esm/function/algebra/simplify.js +557 -202
  353. package/lib/esm/function/algebra/{simplify/simplifyCore.js → simplifyCore.js} +61 -45
  354. package/lib/esm/function/algebra/symbolicEqual.js +80 -0
  355. package/lib/esm/function/matrix/eigs/complexEigs.js +8 -6
  356. package/lib/esm/function/matrix/map.js +53 -15
  357. package/lib/esm/function/matrix/subset.js +15 -5
  358. package/lib/esm/function/statistics/cumsum.js +139 -0
  359. package/lib/esm/function/statistics/sum.js +1 -1
  360. package/lib/esm/function/string/format.js +1 -1
  361. package/lib/esm/plain/number/combinations.js +18 -6
  362. package/lib/esm/type/fraction/function/fraction.js +20 -8
  363. package/lib/esm/utils/collection.js +1 -26
  364. package/lib/esm/utils/switch.js +24 -0
  365. package/lib/esm/version.js +1 -1
  366. package/package.json +15 -10
  367. package/types/index.d.ts +155 -13
  368. package/lib/cjs/function/algebra/simplify/resolve.js +0 -76
  369. package/lib/esm/function/algebra/simplify/resolve.js +0 -67
@@ -25,6 +25,12 @@ Type | Description
25
25
  string | The formatted value
26
26
 
27
27
 
28
+ ### Throws
29
+
30
+ Type | Description
31
+ ---- | -----------
32
+
33
+
28
34
  ## Examples
29
35
 
30
36
  ```js
@@ -33,6 +33,12 @@ Type | Description
33
33
  Array | Matrix | number | A matrix filled with ones
34
34
 
35
35
 
36
+ ### Throws
37
+
38
+ Type | Description
39
+ ---- | -----------
40
+
41
+
36
42
  ## Examples
37
43
 
38
44
  ```js
@@ -26,6 +26,12 @@ Type | Description
26
26
  boolean | Array | Matrix | Returns true when one of the inputs is defined with a nonzero/nonempty value.
27
27
 
28
28
 
29
+ ### Throws
30
+
31
+ Type | Description
32
+ ---- | -----------
33
+
34
+
29
35
  ## Examples
30
36
 
31
37
  ```js
@@ -24,6 +24,12 @@ Type | Description
24
24
  Parser | Parser
25
25
 
26
26
 
27
+ ### Throws
28
+
29
+ Type | Description
30
+ ---- | -----------
31
+
32
+
27
33
  ## Examples
28
34
 
29
35
  ```js
@@ -29,6 +29,12 @@ Type | Description
29
29
  * | Returns the kth lowest value.
30
30
 
31
31
 
32
+ ### Throws
33
+
34
+ Type | Description
35
+ ---- | -----------
36
+
37
+
32
38
  ## Examples
33
39
 
34
40
  ```js
@@ -30,6 +30,12 @@ Type | Description
30
30
  number | BigNumber | The number of permutations
31
31
 
32
32
 
33
+ ### Throws
34
+
35
+ Type | Description
36
+ ---- | -----------
37
+
38
+
33
39
  ## Examples
34
40
 
35
41
  ```js
@@ -32,6 +32,12 @@ Type | Description
32
32
  number | Array | Returns a single random value from array when number is 1 or undefined. Returns an array with the configured number of elements when number is > 1.
33
33
 
34
34
 
35
+ ### Throws
36
+
37
+ Type | Description
38
+ ---- | -----------
39
+
40
+
35
41
  ## Examples
36
42
 
37
43
  ```js
@@ -32,6 +32,12 @@ Type | Description
32
32
  number | BigNumber | Complex | Array | Matrix | The value of `x` to the power `y`
33
33
 
34
34
 
35
+ ### Throws
36
+
37
+ Type | Description
38
+ ---- | -----------
39
+
40
+
35
41
  ## Examples
36
42
 
37
43
  ```js
@@ -28,6 +28,12 @@ Type | Description
28
28
  string | Interpolated string
29
29
 
30
30
 
31
+ ### Throws
32
+
33
+ Type | Description
34
+ ---- | -----------
35
+
36
+
31
37
  ## Examples
32
38
 
33
39
  ```js
@@ -27,6 +27,12 @@ Type | Description
27
27
  * | The product of all values
28
28
 
29
29
 
30
+ ### Throws
31
+
32
+ Type | Description
33
+ ---- | -----------
34
+
35
+
30
36
  ## Examples
31
37
 
32
38
  ```js
@@ -26,6 +26,12 @@ Type | Description
26
26
  {Q: Array | Matrix, R: Array | Matrix} | Q: the orthogonal matrix and R: the upper triangular matrix
27
27
 
28
28
 
29
+ ### Throws
30
+
31
+ Type | Description
32
+ ---- | -----------
33
+
34
+
29
35
  ## Examples
30
36
 
31
37
  ```js
@@ -34,6 +34,12 @@ Type | Description
34
34
  Number, BigNumber, Unit, Array | Quantile(s)
35
35
 
36
36
 
37
+ ### Throws
38
+
39
+ Type | Description
40
+ ---- | -----------
41
+
42
+
37
43
  ## Examples
38
44
 
39
45
  ```js
@@ -32,6 +32,12 @@ Type | Description
32
32
  number | Array | Matrix | A random number
33
33
 
34
34
 
35
+ ### Throws
36
+
37
+ Type | Description
38
+ ---- | -----------
39
+
40
+
35
41
  ## Examples
36
42
 
37
43
  ```js
@@ -32,6 +32,12 @@ Type | Description
32
32
  number | Array | Matrix | A random integer value
33
33
 
34
34
 
35
+ ### Throws
36
+
37
+ Type | Description
38
+ ---- | -----------
39
+
40
+
35
41
  ## Examples
36
42
 
37
43
  ```js
@@ -46,6 +46,12 @@ Type | Description
46
46
  Array | Matrix | range
47
47
 
48
48
 
49
+ ### Throws
50
+
51
+ Type | Description
52
+ ---- | -----------
53
+
54
+
49
55
  ## Examples
50
56
 
51
57
  ```js
@@ -29,7 +29,13 @@ Parameter | Type | Description
29
29
 
30
30
  Type | Description
31
31
  ---- | -----------
32
- Object | Node | The rational polynomial of `expr` or na object {Object} {Expression Node} expression: node simplified expression {Expression Node} numerator: simplified numerator of expression {Expression Node | boolean} denominator: simplified denominator or false (if there is no denominator) {Array} variables: variable names {Array} coefficients: coefficients of numerator sorted by increased exponent {Expression Node} node simplified expression
32
+ Object | Node | The rational polynomial of `expr` or an object `{expression, numerator, denominator, variables, coefficients}`, where `expression` is a `Node` with the node simplified expression, `numerator` is a `Node` with the simplified numerator of expression, `denominator` is a `Node` or `boolean` with the simplified denominator or `false` (if there is no denominator), `variables` is an array with variable names, and `coefficients` is an array with coefficients of numerator sorted by increased exponent {Expression Node} node simplified expression
33
+
34
+
35
+ ### Throws
36
+
37
+ Type | Description
38
+ ---- | -----------
33
39
 
34
40
 
35
41
  ## Examples
@@ -27,6 +27,12 @@ Type | Description
27
27
  number | BigNumber | Array | Matrix | The real part of x
28
28
 
29
29
 
30
+ ### Throws
31
+
32
+ Type | Description
33
+ ---- | -----------
34
+
35
+
30
36
  ## Examples
31
37
 
32
38
  ```js
@@ -25,6 +25,13 @@ Type | Description
25
25
  * | Array | Matrix | A reshaped clone of matrix `x`
26
26
 
27
27
 
28
+ ### Throws
29
+
30
+ Type | Description
31
+ ---- | -----------
32
+ TypeError | If `sizes` does not contain solely integers
33
+ DimensionError | If the product of the new dimension sizes does not equal that of the old ones
34
+
28
35
  ## Examples
29
36
 
30
37
  ```js
@@ -27,6 +27,12 @@ Type | Description
27
27
  * | Array | Matrix | A resized clone of matrix `x`
28
28
 
29
29
 
30
+ ### Throws
31
+
32
+ Type | Description
33
+ ---- | -----------
34
+
35
+
30
36
  ## Examples
31
37
 
32
38
  ```js
@@ -0,0 +1,46 @@
1
+ <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
+
3
+ # Function resolve
4
+
5
+ resolve(expr, scope) replaces variable nodes with their scoped values
6
+
7
+
8
+ ## Syntax
9
+
10
+ ```js
11
+ resolve(expr, scope)
12
+ ```
13
+
14
+ ### Parameters
15
+
16
+ Parameter | Type | Description
17
+ --------- | ---- | -----------
18
+ `node` | Node | The expression tree to be simplified
19
+ `scope` | Object | Scope specifying variables to be resolved
20
+
21
+ ### Returns
22
+
23
+ Type | Description
24
+ ---- | -----------
25
+ Node | Returns `node` with variables recursively substituted.
26
+
27
+
28
+ ### Throws
29
+
30
+ Type | Description
31
+ ---- | -----------
32
+ ReferenceError | If there is a cyclic dependency among the variables in `scope`, resolution is impossible and a ReferenceError is thrown.
33
+
34
+ ## Examples
35
+
36
+ ```js
37
+ math.resolve('x + y', {x:1, y:2}) // Node {1 + 2}
38
+ math.resolve(math.parse('x+y'), {x:1, y:2}) // Node {1 + 2}
39
+ math.simplify('x+y', {x:2, y:'x+x'}).toString() // "6"
40
+ ```
41
+
42
+
43
+ ## See also
44
+
45
+ [simplify](simplify.md),
46
+ [evaluate](evaluate.md)
@@ -27,6 +27,12 @@ Type | Description
27
27
  number &#124; BigNumber &#124; Array &#124; Matrix | `x` sign-filled shifted right `y` times
28
28
 
29
29
 
30
+ ### Throws
31
+
32
+ Type | Description
33
+ ---- | -----------
34
+
35
+
30
36
  ## Examples
31
37
 
32
38
  ```js
@@ -27,6 +27,12 @@ Type | Description
27
27
  number &#124; Array &#124; Matrix | `x` zero-filled shifted right `y` times
28
28
 
29
29
 
30
+ ### Throws
31
+
32
+ Type | Description
33
+ ---- | -----------
34
+
35
+
30
36
  ## Examples
31
37
 
32
38
  ```js
@@ -28,6 +28,12 @@ Type | Description
28
28
  Array &#124; Matrix | Multiplication of the rotation matrix and w
29
29
 
30
30
 
31
+ ### Throws
32
+
33
+ Type | Description
34
+ ---- | -----------
35
+
36
+
31
37
  ## Examples
32
38
 
33
39
  ```js
@@ -30,6 +30,12 @@ Type | Description
30
30
  Array &#124; Matrix | Rotation matrix
31
31
 
32
32
 
33
+ ### Throws
34
+
35
+ Type | Description
36
+ ---- | -----------
37
+
38
+
33
39
  ## Examples
34
40
 
35
41
  ```js
@@ -27,6 +27,12 @@ Type | Description
27
27
  number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix | Rounded value
28
28
 
29
29
 
30
+ ### Throws
31
+
32
+ Type | Description
33
+ ---- | -----------
34
+
35
+
30
36
  ## Examples
31
37
 
32
38
  ```js
@@ -25,6 +25,12 @@ Type | Description
25
25
  Array &#124; Matrix | The retrieved row
26
26
 
27
27
 
28
+ ### Throws
29
+
30
+ Type | Description
31
+ ---- | -----------
32
+
33
+
28
34
  ## Examples
29
35
 
30
36
  ```js
@@ -26,6 +26,12 @@ Type | Description
26
26
  number &#124; Complex &#124; Array &#124; Matrix | Secant of x
27
27
 
28
28
 
29
+ ### Throws
30
+
31
+ Type | Description
32
+ ---- | -----------
33
+
34
+
29
35
  ## Examples
30
36
 
31
37
  ```js
@@ -27,6 +27,12 @@ Type | Description
27
27
  number &#124; Complex &#124; Array &#124; Matrix | Hyperbolic secant of x
28
28
 
29
29
 
30
+ ### Throws
31
+
32
+ Type | Description
33
+ ---- | -----------
34
+
35
+
30
36
  ## Examples
31
37
 
32
38
  ```js
@@ -27,6 +27,12 @@ Type | Description
27
27
  Array &#124; Matrix | The cartesian product of two (multi)sets
28
28
 
29
29
 
30
+ ### Throws
31
+
32
+ Type | Description
33
+ ---- | -----------
34
+
35
+
30
36
  ## Examples
31
37
 
32
38
  ```js
@@ -26,6 +26,12 @@ Type | Description
26
26
  Array &#124; Matrix | The difference of two (multi)sets
27
27
 
28
28
 
29
+ ### Throws
30
+
31
+ Type | Description
32
+ ---- | -----------
33
+
34
+
29
35
  ## Examples
30
36
 
31
37
  ```js
@@ -25,6 +25,12 @@ Type | Description
25
25
  Array &#124; Matrix | A set containing the distinc elements of the multiset
26
26
 
27
27
 
28
+ ### Throws
29
+
30
+ Type | Description
31
+ ---- | -----------
32
+
33
+
28
34
  ## Examples
29
35
 
30
36
  ```js
@@ -26,6 +26,12 @@ Type | Description
26
26
  Array &#124; Matrix | The intersection of two (multi)sets
27
27
 
28
28
 
29
+ ### Throws
30
+
31
+ Type | Description
32
+ ---- | -----------
33
+
34
+
29
35
  ## Examples
30
36
 
31
37
  ```js
@@ -26,6 +26,12 @@ Type | Description
26
26
  boolean | true | false
27
27
 
28
28
 
29
+ ### Throws
30
+
31
+ Type | Description
32
+ ---- | -----------
33
+
34
+
29
35
  ## Examples
30
36
 
31
37
  ```js
@@ -26,6 +26,12 @@ Type | Description
26
26
  number | The number of how many times the multiset contains the element
27
27
 
28
28
 
29
+ ### Throws
30
+
31
+ Type | Description
32
+ ---- | -----------
33
+
34
+
29
35
  ## Examples
30
36
 
31
37
  ```js
@@ -25,6 +25,12 @@ Type | Description
25
25
  Array | The powerset of the (multi)set
26
26
 
27
27
 
28
+ ### Throws
29
+
30
+ Type | Description
31
+ ---- | -----------
32
+
33
+
28
34
  ## Examples
29
35
 
30
36
  ```js
@@ -26,6 +26,12 @@ Type | Description
26
26
  number | The number of elements of the (multi)set
27
27
 
28
28
 
29
+ ### Throws
30
+
31
+ Type | Description
32
+ ---- | -----------
33
+
34
+
29
35
  ## Examples
30
36
 
31
37
  ```js
@@ -26,6 +26,12 @@ Type | Description
26
26
  Array &#124; Matrix | The symmetric difference of two (multi)sets
27
27
 
28
28
 
29
+ ### Throws
30
+
31
+ Type | Description
32
+ ---- | -----------
33
+
34
+
29
35
  ## Examples
30
36
 
31
37
  ```js
@@ -26,6 +26,12 @@ Type | Description
26
26
  Array &#124; Matrix | The union of two (multi)sets
27
27
 
28
28
 
29
+ ### Throws
30
+
31
+ Type | Description
32
+ ---- | -----------
33
+
34
+
29
35
  ## Examples
30
36
 
31
37
  ```js
@@ -30,6 +30,12 @@ Type | Description
30
30
  number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix &#124; Unit | e The sign of `x`
31
31
 
32
32
 
33
+ ### Throws
34
+
35
+ Type | Description
36
+ ---- | -----------
37
+
38
+
33
39
  ## Examples
34
40
 
35
41
  ```js
@@ -31,6 +31,19 @@ interpreted as wildcards:
31
31
  The default list of rules is exposed on the function as `simplify.rules`
32
32
  and can be used as a basis to built a set of custom rules.
33
33
 
34
+ To specify a rule as a string, separate the left and right pattern by '->'
35
+ When specifying a rule as an object, the following keys are meaningful:
36
+ - l - the left pattern
37
+ - r - the right pattern
38
+ - s - in lieu of l and r, the string form that is broken at -> to give them
39
+ - repeat - whether to repeat this rule until the expression stabilizes
40
+ - assuming - gives a context object, as in the 'context' option to
41
+ simplify. Every property in the context object must match the current
42
+ context in order, or else the rule will not be applied.
43
+ - imposeContext - gives a context object, as in the 'context' option to
44
+ simplify. Any settings specified will override the incoming context
45
+ for all matches of this rule.
46
+
34
47
  For more details on the theory, see:
35
48
 
36
49
  - [Strategies for simplifying math expressions (Stackoverflow)](https://stackoverflow.com/questions/7540227/strategies-for-simplifying-math-expressions)
@@ -39,12 +52,28 @@ For more details on the theory, see:
39
52
  An optional `options` argument can be passed as last argument of `simplify`.
40
53
  Currently available options (defaults in parentheses):
41
54
  - `consoleDebug` (false): whether to write the expression being simplified
42
- and any changes to it, along with the rule responsible, to console
55
+ and any changes to it, along with the rule responsible, to console
56
+ - `context` (simplify.defaultContext): an object giving properties of
57
+ each operator, which determine what simplifications are allowed. The
58
+ currently meaningful properties are commutative, associative,
59
+ total (whether the operation is defined for all arguments), and
60
+ trivial (whether the operation applied to a single argument leaves
61
+ that argument unchanged). The default context is very permissive and
62
+ allows almost all simplifications. Only properties differing from
63
+ the default need to be specified; the default context is used as a
64
+ fallback. Additional contexts `simplify.realContext` and
65
+ `simplify.positiveContext` are supplied to cause simplify to perform
66
+ just simplifications guaranteed to preserve all values of the expression
67
+ assuming all variables and subexpressions are real numbers or
68
+ positive real numbers, respectively. (Note that these are in some cases
69
+ more restrictive than the default context; for example, the default
70
+ context will allow `x/x` to simplify to 1, whereas
71
+ `simplify.realContext` will not, as `0/0` is not equal to 1.)
43
72
  - `exactFractions` (true): whether to try to convert all constants to
44
- exact rational numbers.
73
+ exact rational numbers.
45
74
  - `fractionsLimit` (10000): when `exactFractions` is true, constants will
46
- be expressed as fractions only when both numerator and denominator
47
- are smaller than `fractionsLimit`.
75
+ be expressed as fractions only when both numerator and denominator
76
+ are smaller than `fractionsLimit`.
48
77
 
49
78
 
50
79
  ## Syntax
@@ -73,6 +102,12 @@ Type | Description
73
102
  Node | Returns the simplified form of `expr`
74
103
 
75
104
 
105
+ ### Throws
106
+
107
+ Type | Description
108
+ ---- | -----------
109
+
110
+
76
111
  ## Examples
77
112
 
78
113
  ```js
@@ -87,7 +122,9 @@ math.simplify('0.4 * x', {}, {exactFractions: false}) // Node "0.4 * x"
87
122
 
88
123
  ## See also
89
124
 
125
+ [simplifyCore](simplifyCore.md),
90
126
  [derivative](derivative.md),
91
- [parse](parse.md),
92
127
  [evaluate](evaluate.md),
93
- [rationalize](rationalize.md)
128
+ [parse](parse.md),
129
+ [rationalize](rationalize.md),
130
+ [resolve](resolve.md)