nerdamer 1.1.13 → 2.0.0-rc.2

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 (387) hide show
  1. package/BREAKING_CHANGES.md +244 -5
  2. package/LICENSE.md +184 -0
  3. package/README.md +232 -318
  4. package/dist/bundle.js +2 -0
  5. package/dist/bundle.js.LICENSE.txt +7 -0
  6. package/dist/parser.js +2 -0
  7. package/dist/parser.js.LICENSE.txt +7 -0
  8. package/docs-data/parser-functions.json +2248 -0
  9. package/index.d.ts +10 -426
  10. package/output/algebra/adapters.d.ts +3 -0
  11. package/output/algebra/adapters.js +11 -0
  12. package/output/algebra/algorithms/arith.d.ts +84 -0
  13. package/output/algebra/algorithms/arith.js +324 -0
  14. package/output/algebra/algorithms/groebnerBase.d.ts +161 -0
  15. package/output/algebra/algorithms/groebnerBase.js +929 -0
  16. package/output/algebra/dispatch.d.ts +1 -0
  17. package/output/algebra/dispatch.js +25 -0
  18. package/output/algebra/factor/factor.d.ts +77 -0
  19. package/output/algebra/factor/factor.js +245 -0
  20. package/output/algebra/gcd/gcd.d.ts +30 -0
  21. package/output/algebra/gcd/gcd.js +95 -0
  22. package/output/algebra/groebner.d.ts +21 -0
  23. package/output/algebra/groebner.js +36 -0
  24. package/output/algebra/partfrac.d.ts +19 -0
  25. package/output/algebra/partfrac.js +365 -0
  26. package/output/algebra/polynomial/ModularSparsePolynomial.d.ts +131 -0
  27. package/output/algebra/polynomial/ModularSparsePolynomial.js +378 -0
  28. package/output/algebra/polynomial/ModularSparsePolynomialFactor.d.ts +40 -0
  29. package/output/algebra/polynomial/ModularSparsePolynomialFactor.js +661 -0
  30. package/output/algebra/polynomial/SparsePolynomialFactor.d.ts +64 -0
  31. package/output/algebra/polynomial/SparsePolynomialFactor.js +492 -0
  32. package/output/algebra/polynomial/SparsePolynomialGcd.d.ts +29 -0
  33. package/output/algebra/polynomial/SparsePolynomialGcd.js +259 -0
  34. package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.d.ts +82 -0
  35. package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.js +604 -0
  36. package/output/algebra/polynomial/modularGcd.d.ts +40 -0
  37. package/output/algebra/polynomial/modularGcd.js +365 -0
  38. package/output/algebra/polynomialize.d.ts +20 -0
  39. package/output/algebra/polynomialize.js +26 -0
  40. package/output/algebra/simplify/complexsimp.d.ts +7 -0
  41. package/output/algebra/simplify/complexsimp.js +24 -0
  42. package/output/algebra/simplify/factorCommon.d.ts +13 -0
  43. package/output/algebra/simplify/factorCommon.js +136 -0
  44. package/output/algebra/simplify/funcsimp.d.ts +26 -0
  45. package/output/algebra/simplify/funcsimp.js +633 -0
  46. package/output/algebra/simplify/invtrigrewrite.d.ts +10 -0
  47. package/output/algebra/simplify/invtrigrewrite.js +96 -0
  48. package/output/algebra/simplify/ratsimp.d.ts +21 -0
  49. package/output/algebra/simplify/ratsimp.js +140 -0
  50. package/output/algebra/simplify/simplify.d.ts +25 -0
  51. package/output/algebra/simplify/simplify.js +237 -0
  52. package/output/algebra/simplify/trigreduce.d.ts +38 -0
  53. package/output/algebra/simplify/trigreduce.js +424 -0
  54. package/output/algebra/simplify/trigrewrite.d.ts +17 -0
  55. package/output/algebra/simplify/trigrewrite.js +156 -0
  56. package/output/algebra/simplify/trigsimp.d.ts +11 -0
  57. package/output/algebra/simplify/trigsimp.js +369 -0
  58. package/output/algebra/simplify/utils.d.ts +32 -0
  59. package/output/algebra/simplify/utils.js +56 -0
  60. package/output/algebra/utils.d.ts +32 -0
  61. package/output/algebra/utils.js +48 -0
  62. package/output/api/advanced.d.ts +8 -0
  63. package/output/api/advanced.js +18 -0
  64. package/output/api/algebra.d.ts +17 -0
  65. package/output/api/algebra.js +35 -0
  66. package/output/api/assumptions.d.ts +4 -0
  67. package/output/api/assumptions.js +11 -0
  68. package/output/api/calculus.d.ts +10 -0
  69. package/output/api/calculus.js +22 -0
  70. package/output/api/core.d.ts +17 -0
  71. package/output/api/core.js +41 -0
  72. package/output/api/debug.d.ts +16 -0
  73. package/output/api/debug.js +23 -0
  74. package/output/api/languages/deu.d.ts +3 -0
  75. package/output/api/languages/deu.js +266 -0
  76. package/output/api/languages/fra.d.ts +3 -0
  77. package/output/api/languages/fra.js +266 -0
  78. package/output/api/languages/ita.d.ts +3 -0
  79. package/output/api/languages/ita.js +266 -0
  80. package/output/api/languages/nld.d.ts +3 -0
  81. package/output/api/languages/nld.js +266 -0
  82. package/output/api/languages/por.d.ts +3 -0
  83. package/output/api/languages/por.js +266 -0
  84. package/output/api/languages/spa.d.ts +3 -0
  85. package/output/api/languages/spa.js +266 -0
  86. package/output/api/parser.d.ts +93 -0
  87. package/output/api/parser.js +18 -0
  88. package/output/api/solve.d.ts +10 -0
  89. package/output/api/solve.js +17 -0
  90. package/output/api/structures.d.ts +10 -0
  91. package/output/api/structures.js +23 -0
  92. package/output/calculus/adapters.d.ts +8 -0
  93. package/output/calculus/adapters.js +41 -0
  94. package/output/calculus/derivative/diff.d.ts +30 -0
  95. package/output/calculus/derivative/diff.js +241 -0
  96. package/output/calculus/dispatch.d.ts +1 -0
  97. package/output/calculus/dispatch.js +25 -0
  98. package/output/calculus/fresnel.d.ts +16 -0
  99. package/output/calculus/fresnel.js +39 -0
  100. package/output/calculus/integrate/byParts.d.ts +18 -0
  101. package/output/calculus/integrate/byParts.js +339 -0
  102. package/output/calculus/integrate/bySubstitution.d.ts +135 -0
  103. package/output/calculus/integrate/bySubstitution.js +411 -0
  104. package/output/calculus/integrate/integrate.d.ts +38 -0
  105. package/output/calculus/integrate/integrate.js +652 -0
  106. package/output/calculus/integrate/integrationTable.d.ts +2 -0
  107. package/output/calculus/integrate/integrationTable.js +914 -0
  108. package/output/calculus/integrate/utils.d.ts +28 -0
  109. package/output/calculus/integrate/utils.js +96 -0
  110. package/output/calculus/laplace/ilaplace.d.ts +31 -0
  111. package/output/calculus/laplace/ilaplace.js +192 -0
  112. package/output/calculus/laplace/ilaplaceTable.d.ts +2 -0
  113. package/output/calculus/laplace/ilaplaceTable.js +200 -0
  114. package/output/calculus/laplace/laplace.d.ts +22 -0
  115. package/output/calculus/laplace/laplace.js +109 -0
  116. package/output/calculus/laplace/laplaceTable.d.ts +2 -0
  117. package/output/calculus/laplace/laplaceTable.js +187 -0
  118. package/output/calculus/limit/limit.d.ts +35 -0
  119. package/output/calculus/limit/limit.js +1183 -0
  120. package/output/calculus/limit/limitsTable.d.ts +2 -0
  121. package/output/calculus/limit/limitsTable.js +7 -0
  122. package/output/core/Settings.d.ts +32 -0
  123. package/output/core/Settings.js +68 -0
  124. package/output/core/classes/assumption/Assumption.d.ts +218 -0
  125. package/output/core/classes/assumption/Assumption.js +609 -0
  126. package/output/core/classes/assumption/assertiveFunctions.d.ts +6 -0
  127. package/output/core/classes/assumption/assertiveFunctions.js +64 -0
  128. package/output/core/classes/assumption/assume.d.ts +90 -0
  129. package/output/core/classes/assumption/assume.js +145 -0
  130. package/output/core/classes/assumption/dispatch.d.ts +1 -0
  131. package/output/core/classes/assumption/dispatch.js +11 -0
  132. package/output/core/classes/collection/Collection.d.ts +107 -0
  133. package/output/core/classes/collection/Collection.js +240 -0
  134. package/output/core/classes/complex/Complex.d.ts +109 -0
  135. package/output/core/classes/complex/Complex.js +153 -0
  136. package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
  137. package/output/core/classes/decimalSet/DecimalSet.js +454 -0
  138. package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
  139. package/output/core/classes/dictionary/Dictionary.js +216 -0
  140. package/output/core/classes/equation/Equation.d.ts +256 -0
  141. package/output/core/classes/equation/Equation.js +350 -0
  142. package/output/core/classes/expression/CoeffObject.d.ts +100 -0
  143. package/output/core/classes/expression/CoeffObject.js +197 -0
  144. package/output/core/classes/expression/Expression.d.ts +1691 -0
  145. package/output/core/classes/expression/Expression.js +2381 -0
  146. package/output/core/classes/expression/analysis.d.ts +25 -0
  147. package/output/core/classes/expression/analysis.js +218 -0
  148. package/output/core/classes/expression/collect.d.ts +9 -0
  149. package/output/core/classes/expression/collect.js +49 -0
  150. package/output/core/classes/expression/format.d.ts +54 -0
  151. package/output/core/classes/expression/format.js +340 -0
  152. package/output/core/classes/expression/products.d.ts +23 -0
  153. package/output/core/classes/expression/products.js +115 -0
  154. package/output/core/classes/expression/shortcuts.d.ts +35 -0
  155. package/output/core/classes/expression/shortcuts.js +129 -0
  156. package/output/core/classes/expression/traversal.d.ts +31 -0
  157. package/output/core/classes/expression/traversal.js +216 -0
  158. package/output/core/classes/expression/trig.d.ts +25 -0
  159. package/output/core/classes/expression/trig.js +40 -0
  160. package/output/core/classes/expression/utils.d.ts +61 -0
  161. package/output/core/classes/expression/utils.js +235 -0
  162. package/output/core/classes/lookupTable/LookupTable.d.ts +12 -0
  163. package/output/core/classes/lookupTable/LookupTable.js +55 -0
  164. package/output/core/classes/matrix/Matrix.d.ts +227 -0
  165. package/output/core/classes/matrix/Matrix.js +901 -0
  166. package/output/core/classes/matrix/Sylvester.d.ts +11 -0
  167. package/output/core/classes/matrix/Sylvester.js +54 -0
  168. package/output/core/classes/matrix/dispatch.d.ts +1 -0
  169. package/output/core/classes/matrix/dispatch.js +19 -0
  170. package/output/core/classes/matrix/functions.d.ts +28 -0
  171. package/output/core/classes/matrix/functions.js +57 -0
  172. package/output/core/classes/matrix/utils.d.ts +9 -0
  173. package/output/core/classes/matrix/utils.js +22 -0
  174. package/output/core/classes/parser/Parser.d.ts +493 -0
  175. package/output/core/classes/parser/Parser.js +1863 -0
  176. package/output/core/classes/parser/Token.d.ts +58 -0
  177. package/output/core/classes/parser/Token.js +137 -0
  178. package/output/core/classes/parser/constants.d.ts +162 -0
  179. package/output/core/classes/parser/constants.js +229 -0
  180. package/output/core/classes/parser/controlFlowSignals.d.ts +38 -0
  181. package/output/core/classes/parser/controlFlowSignals.js +60 -0
  182. package/output/core/classes/parser/helpers.d.ts +21 -0
  183. package/output/core/classes/parser/helpers.js +42 -0
  184. package/output/core/classes/parser/operations/add.d.ts +15 -0
  185. package/output/core/classes/parser/operations/add.js +236 -0
  186. package/output/core/classes/parser/operations/comma.d.ts +7 -0
  187. package/output/core/classes/parser/operations/comma.js +11 -0
  188. package/output/core/classes/parser/operations/compare.d.ts +21 -0
  189. package/output/core/classes/parser/operations/compare.js +474 -0
  190. package/output/core/classes/parser/operations/divide.d.ts +2 -0
  191. package/output/core/classes/parser/operations/divide.js +72 -0
  192. package/output/core/classes/parser/operations/functions.d.ts +46 -0
  193. package/output/core/classes/parser/operations/functions.js +438 -0
  194. package/output/core/classes/parser/operations/multiply.d.ts +11 -0
  195. package/output/core/classes/parser/operations/multiply.js +328 -0
  196. package/output/core/classes/parser/operations/power.d.ts +48 -0
  197. package/output/core/classes/parser/operations/power.js +673 -0
  198. package/output/core/classes/parser/operations/subtract.d.ts +3 -0
  199. package/output/core/classes/parser/operations/subtract.js +36 -0
  200. package/output/core/classes/parser/preprocess.d.ts +7 -0
  201. package/output/core/classes/parser/preprocess.js +246 -0
  202. package/output/core/classes/parser/scripting/controlFlow.d.ts +23 -0
  203. package/output/core/classes/parser/scripting/controlFlow.js +279 -0
  204. package/output/core/classes/parser/scripting/deferred.d.ts +4 -0
  205. package/output/core/classes/parser/scripting/deferred.js +65 -0
  206. package/output/core/classes/parser/scripting/dispatch.d.ts +1 -0
  207. package/output/core/classes/parser/scripting/dispatch.js +62 -0
  208. package/output/core/classes/parser/scripting/evaluate.d.ts +23 -0
  209. package/output/core/classes/parser/scripting/evaluate.js +128 -0
  210. package/output/core/classes/parser/scripting/functions.d.ts +14 -0
  211. package/output/core/classes/parser/scripting/functions.js +59 -0
  212. package/output/core/classes/parser/scripting/scope.d.ts +8 -0
  213. package/output/core/classes/parser/scripting/scope.js +132 -0
  214. package/output/core/classes/parser/types.d.ts +130 -0
  215. package/output/core/classes/parser/types.js +2 -0
  216. package/output/core/classes/parser/wrappers/IndexedReference.d.ts +31 -0
  217. package/output/core/classes/parser/wrappers/IndexedReference.js +68 -0
  218. package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +24 -0
  219. package/output/core/classes/parser/wrappers/KeyValuePair.js +51 -0
  220. package/output/core/classes/polynomial/Polynomial.d.ts +504 -0
  221. package/output/core/classes/polynomial/Polynomial.js +1195 -0
  222. package/output/core/classes/polynomial/SparsePolynomial.d.ts +221 -0
  223. package/output/core/classes/polynomial/SparsePolynomial.js +824 -0
  224. package/output/core/classes/polynomial/SparsePolynomialAdapter.d.ts +56 -0
  225. package/output/core/classes/polynomial/SparsePolynomialAdapter.js +241 -0
  226. package/output/core/classes/polynomial/Term.d.ts +222 -0
  227. package/output/core/classes/polynomial/Term.js +430 -0
  228. package/output/core/classes/polynomial/adapters.d.ts +18 -0
  229. package/output/core/classes/polynomial/adapters.js +33 -0
  230. package/output/core/classes/polynomial/dispatch.d.ts +1 -0
  231. package/output/core/classes/polynomial/dispatch.js +14 -0
  232. package/output/core/classes/polynomial/functions.d.ts +77 -0
  233. package/output/core/classes/polynomial/functions.js +189 -0
  234. package/output/core/classes/polynomial/utils.d.ts +62 -0
  235. package/output/core/classes/polynomial/utils.js +207 -0
  236. package/output/core/classes/rational/Rational.d.ts +501 -0
  237. package/output/core/classes/rational/Rational.js +829 -0
  238. package/output/core/classes/seq/SEQ.d.ts +13 -0
  239. package/output/core/classes/seq/SEQ.js +137 -0
  240. package/output/core/classes/valuesSet/ValuesSet.d.ts +187 -0
  241. package/output/core/classes/valuesSet/ValuesSet.js +399 -0
  242. package/output/core/classes/vector/Vector.d.ts +222 -0
  243. package/output/core/classes/vector/Vector.js +501 -0
  244. package/output/core/classes/vector/dispatch.d.ts +1 -0
  245. package/output/core/classes/vector/dispatch.js +11 -0
  246. package/output/core/classes/vector/functions.d.ts +28 -0
  247. package/output/core/classes/vector/functions.js +47 -0
  248. package/output/core/common/classes/MathematicalAggregate.d.ts +53 -0
  249. package/output/core/common/classes/MathematicalAggregate.js +149 -0
  250. package/output/core/common/classes/Scope.d.ts +62 -0
  251. package/output/core/common/classes/Scope.js +122 -0
  252. package/output/core/common/classes/StructuredEntity.d.ts +55 -0
  253. package/output/core/common/classes/StructuredEntity.js +151 -0
  254. package/output/core/common/common.d.ts +62 -0
  255. package/output/core/common/common.js +74 -0
  256. package/output/core/common/functions/functions.d.ts +14 -0
  257. package/output/core/common/functions/functions.js +33 -0
  258. package/output/core/common/functions/structuredEntityUtils.d.ts +27 -0
  259. package/output/core/common/functions/structuredEntityUtils.js +40 -0
  260. package/output/core/converters/BaseConverter.d.ts +97 -0
  261. package/output/core/converters/BaseConverter.js +405 -0
  262. package/output/core/converters/Converter.d.ts +111 -0
  263. package/output/core/converters/Converter.js +806 -0
  264. package/output/core/converters/Pattern.d.ts +71 -0
  265. package/output/core/converters/Pattern.js +302 -0
  266. package/output/core/dispatch.d.ts +52 -0
  267. package/output/core/dispatch.js +26 -0
  268. package/output/core/errors.d.ts +316 -0
  269. package/output/core/errors.js +349 -0
  270. package/output/core/fullFunctions.d.ts +7 -0
  271. package/output/core/fullFunctions.js +31 -0
  272. package/output/core/functions/bigint/bigint.d.ts +133 -0
  273. package/output/core/functions/bigint/bigint.js +444 -0
  274. package/output/core/functions/bigint/primeFactor.d.ts +51 -0
  275. package/output/core/functions/bigint/primeFactor.js +267 -0
  276. package/output/core/functions/bigint/primes.d.ts +1 -0
  277. package/output/core/functions/bigint/primes.js +11 -0
  278. package/output/core/functions/build/definitions.d.ts +12 -0
  279. package/output/core/functions/build/definitions.js +139 -0
  280. package/output/core/functions/build/index.d.ts +32 -0
  281. package/output/core/functions/build/index.js +136 -0
  282. package/output/core/functions/complex.d.ts +90 -0
  283. package/output/core/functions/complex.dispatch.d.ts +1 -0
  284. package/output/core/functions/complex.dispatch.js +16 -0
  285. package/output/core/functions/complex.js +482 -0
  286. package/output/core/functions/decimal.d.ts +24 -0
  287. package/output/core/functions/decimal.js +665 -0
  288. package/output/core/functions/expand/expand.d.ts +42 -0
  289. package/output/core/functions/expand/expand.js +376 -0
  290. package/output/core/functions/fresnelNumeric.d.ts +12 -0
  291. package/output/core/functions/fresnelNumeric.js +123 -0
  292. package/output/core/functions/numeric.d.ts +140 -0
  293. package/output/core/functions/numeric.js +790 -0
  294. package/output/core/functions/rationalNormalization.d.ts +11 -0
  295. package/output/core/functions/rationalNormalization.js +117 -0
  296. package/output/core/functions/setFunction.d.ts +19 -0
  297. package/output/core/functions/setFunction.js +75 -0
  298. package/output/core/functions/string.d.ts +26 -0
  299. package/output/core/functions/string.js +102 -0
  300. package/output/core/functions/subst.d.ts +90 -0
  301. package/output/core/functions/subst.js +506 -0
  302. package/output/core/functions/utils.d.ts +24 -0
  303. package/output/core/functions/utils.js +51 -0
  304. package/output/core/parserFunctions.d.ts +7 -0
  305. package/output/core/parserFunctions.js +25 -0
  306. package/output/core/types.d.ts +48 -0
  307. package/output/core/types.js +2 -0
  308. package/output/index.d.ts +359 -0
  309. package/output/index.js +739 -0
  310. package/output/math/defint/defint.d.ts +18 -0
  311. package/output/math/defint/defint.js +60 -0
  312. package/output/math/defint/defintDecimal.d.ts +37 -0
  313. package/output/math/defint/defintDecimal.js +321 -0
  314. package/output/math/defint/defintNative.d.ts +57 -0
  315. package/output/math/defint/defintNative.js +281 -0
  316. package/output/math/dispatch.d.ts +1 -0
  317. package/output/math/dispatch.js +101 -0
  318. package/output/math/geometry.d.ts +12 -0
  319. package/output/math/geometry.js +55 -0
  320. package/output/math/math.d.ts +695 -0
  321. package/output/math/math.js +1955 -0
  322. package/output/math/trig.d.ts +518 -0
  323. package/output/math/trig.js +1444 -0
  324. package/output/math/trunc.d.ts +19 -0
  325. package/output/math/trunc.js +36 -0
  326. package/output/math/utils.d.ts +66 -0
  327. package/output/math/utils.js +219 -0
  328. package/output/solve/classes/DecimalMatrix.d.ts +17 -0
  329. package/output/solve/classes/DecimalMatrix.js +86 -0
  330. package/output/solve/classes/FunctionSolver.d.ts +135 -0
  331. package/output/solve/classes/FunctionSolver.js +433 -0
  332. package/output/solve/classes/MultivariateSolver.d.ts +84 -0
  333. package/output/solve/classes/MultivariateSolver.js +240 -0
  334. package/output/solve/classes/PolynomialSolver.d.ts +104 -0
  335. package/output/solve/classes/PolynomialSolver.js +492 -0
  336. package/output/solve/classes/SolutionSet.d.ts +172 -0
  337. package/output/solve/classes/SolutionSet.js +434 -0
  338. package/output/solve/classes/Solver.d.ts +17 -0
  339. package/output/solve/classes/Solver.js +132 -0
  340. package/output/solve/classes/SymbolicSolver.d.ts +74 -0
  341. package/output/solve/classes/SymbolicSolver.js +601 -0
  342. package/output/solve/dispatch.d.ts +1 -0
  343. package/output/solve/dispatch.js +13 -0
  344. package/output/solve/linsolve.d.ts +53 -0
  345. package/output/solve/linsolve.js +233 -0
  346. package/output/solve/solve.d.ts +44 -0
  347. package/output/solve/solve.js +368 -0
  348. package/output/solve/solveSystem.d.ts +31 -0
  349. package/output/solve/solveSystem.js +266 -0
  350. package/output/solve/utils.d.ts +10 -0
  351. package/output/solve/utils.js +58 -0
  352. package/output/utils/array.d.ts +42 -0
  353. package/output/utils/array.js +98 -0
  354. package/output/utils/debug.d.ts +131 -0
  355. package/output/utils/debug.js +296 -0
  356. package/output/utils/decimal.d.ts +3 -0
  357. package/output/utils/decimal.js +16 -0
  358. package/output/utils/numeric.d.ts +14 -0
  359. package/output/utils/numeric.js +51 -0
  360. package/output/utils/object.d.ts +26 -0
  361. package/output/utils/object.js +56 -0
  362. package/package.json +178 -57
  363. package/.travis.yml +0 -3
  364. package/Algebra.js +0 -4568
  365. package/CODE_OF_CONDUCT.md +0 -46
  366. package/CONTRIBUTING.md +0 -14
  367. package/Calculus.js +0 -2675
  368. package/Extra.js +0 -622
  369. package/Solve.js +0 -1783
  370. package/all.js +0 -16
  371. package/all.min.js +0 -1
  372. package/gulpfile.js +0 -16
  373. package/index.html +0 -158
  374. package/license.txt +0 -19
  375. package/nerdamer.core.js +0 -12510
  376. package/spec/LaTeX.spec.js +0 -302
  377. package/spec/TeXConvert.spec.js +0 -8
  378. package/spec/algebra.spec.js +0 -287
  379. package/spec/basic_parser.spec.js +0 -134
  380. package/spec/build.spec.js +0 -131
  381. package/spec/calculus.spec.js +0 -183
  382. package/spec/core.spec.js +0 -2970
  383. package/spec/extra.spec.js +0 -54
  384. package/spec/solve.spec.js +0 -126
  385. package/spec/support/jasmine.json +0 -11
  386. package/spec/support/utils.js +0 -42
  387. package/spec/text.spec.js +0 -132
@@ -0,0 +1,430 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Term = void 0;
4
+ const common_1 = require("../../common/common");
5
+ const bigint_1 = require("../../functions/bigint/bigint");
6
+ const numeric_1 = require("../../functions/numeric");
7
+ const utils_1 = require("../../functions/utils");
8
+ const Expression_1 = require("../expression/Expression");
9
+ const constants_1 = require("../parser/constants");
10
+ /**
11
+ * Represents one coefficient-monomial term in a {@link Polynomial}.
12
+ *
13
+ * @remarks
14
+ * A term stores an `Expression` coefficient, a mutable variable-to-power record, and
15
+ * a sorted copy of the supplied variable names. The coefficient and a power object
16
+ * supplied to the constructor are retained by reference; {@link Term.copy} creates
17
+ * independent copies of both.
18
+ *
19
+ * Multidegree, total power, expression, and value text are computed lazily and cached.
20
+ * Arithmetic methods return new terms and refresh their derived degree fields. Direct
21
+ * mutation of {@link Term.coeff}, {@link Term.powers}, or the setter overload of
22
+ * {@link Term.deg} does not invalidate every cached field, so callers should prefer a
23
+ * copied/reconstructed term when cached values may already have been read.
24
+ */
25
+ class Term {
26
+ /** Mutable symbolic coefficient. */
27
+ coeff;
28
+ /** Runtime tag used by Nerdamer's term type guard. */
29
+ dataType = constants_1.TERM;
30
+ /** Lazily cached expression representation. */
31
+ expression;
32
+ /** Number of variables whose power is positive. */
33
+ length;
34
+ /** Lazily cached multidegree in {@link variables} order. */
35
+ multidegArray;
36
+ /** Mutable powers keyed by variable name. */
37
+ powers;
38
+ /** Lazily cached sum of all stored powers. */
39
+ totalPower;
40
+ /** Lazily cached unit-coefficient monomial text. */
41
+ valueString;
42
+ /** Sorted variable names used for multidegree and rendering order. */
43
+ variables;
44
+ /**
45
+ * Creates a term from a coefficient and monomial powers.
46
+ *
47
+ * @param coeff - Expression coefficient or parser text. Existing expressions are retained.
48
+ * @param powers - Power record or comma-separated degrees aligned with `variables`.
49
+ * An object power record is retained by reference.
50
+ * @param variables - Variable order to interpret string powers. The term stores a sorted copy.
51
+ */
52
+ constructor(coeff, powers, variables) {
53
+ if (typeof powers === 'string') {
54
+ this.powers = {};
55
+ powers.split(',').forEach((x, i) => {
56
+ this.powers[variables[i]] = Number(x);
57
+ });
58
+ }
59
+ else {
60
+ this.powers = powers;
61
+ }
62
+ this.coeff = typeof coeff === 'string' ? Expression_1.Expression.create(coeff) : coeff;
63
+ this.length = this.getLength();
64
+ // Terms use a stable sorted variable order independent of later changes to the caller's array.
65
+ this.variables = [...variables].sort();
66
+ }
67
+ /**
68
+ * Checks if the given object is a Term
69
+ *
70
+ * @param obj - Value to test.
71
+ * @returns Whether `obj` carries Nerdamer's term discriminator.
72
+ */
73
+ static isTerm(obj) {
74
+ return (0, common_1.isNerdamerNativeType)(obj, constants_1.TERM);
75
+ }
76
+ /**
77
+ * Gets the total number of non-unit variables in the term
78
+ *
79
+ * @returns The number of variables with positive powers.
80
+ */
81
+ getLength() {
82
+ let length = 0;
83
+ for (const x in this.powers) {
84
+ if (this.powers[x] > 0) {
85
+ length++;
86
+ }
87
+ }
88
+ return length;
89
+ }
90
+ /** Recalculates degree-derived caches after term arithmetic and returns this term. */
91
+ update() {
92
+ this.updateMultiDegArray();
93
+ this.updateTotalPower();
94
+ this.length = this.getLength();
95
+ return this;
96
+ }
97
+ /**
98
+ * Forces the multidegree array to be recalculated
99
+ *
100
+ * @returns The refreshed internal multidegree array.
101
+ */
102
+ updateMultiDegArray() {
103
+ const retval = this.multideg(this.variables);
104
+ this.multidegArray = retval;
105
+ return retval;
106
+ }
107
+ /**
108
+ * Forces the total power to be recalculated
109
+ *
110
+ * @returns The refreshed total degree.
111
+ */
112
+ updateTotalPower() {
113
+ let retval = 0;
114
+ for (const x in this.powers) {
115
+ retval += this.deg(x);
116
+ }
117
+ this.totalPower = retval;
118
+ return retval;
119
+ }
120
+ /**
121
+ * Tests whether two terms have the same unit-coefficient monomial.
122
+ *
123
+ * @param t - Term to compare.
124
+ * @returns Whether their rendered variable-and-power components match.
125
+ */
126
+ canAddOrSubtract(t) {
127
+ return this.getValueString() === t.getValueString();
128
+ }
129
+ /**
130
+ * Creates an independently mutable copy of this term.
131
+ *
132
+ * @returns A term with copied coefficient, powers, and variable array. Lazy caches are rebuilt on demand.
133
+ */
134
+ copy() {
135
+ return new Term(this.coeff.copy(), { ...this.powers }, this.variables);
136
+ }
137
+ deg(v, value) {
138
+ if (value !== undefined) {
139
+ this.powers[v] = value;
140
+ return this;
141
+ }
142
+ return this.powers[v] || 0;
143
+ }
144
+ /**
145
+ * Differentiates this term with respect to one variable.
146
+ *
147
+ * @param variable - Differentiation variable.
148
+ * @param n - Non-negative derivative order.
149
+ * @returns A new differentiated term, or a zero term when `n` exceeds the power.
150
+ */
151
+ diff(variable, n = 1) {
152
+ const p = this.deg(variable);
153
+ let retval;
154
+ if (n > p) {
155
+ retval = new Term('0', '0', []);
156
+ }
157
+ else {
158
+ retval = this.copy();
159
+ retval.powers[variable] = p - n;
160
+ const d = n - 1;
161
+ const r = (0, bigint_1.productInRange)(p - d, p);
162
+ retval.coeff = retval.coeff.times(BigInt(r));
163
+ }
164
+ return retval;
165
+ }
166
+ /**
167
+ * Subtracts another term's multidegree from this term's multidegree.
168
+ *
169
+ * @param term - Term whose degree tuple is subtracted.
170
+ * @returns A new component-wise difference array in this term's variable order.
171
+ */
172
+ difference(term) {
173
+ const a = this.getMultidegArray();
174
+ const b = term.getMultidegArray();
175
+ const diff = [];
176
+ for (let i = 0; i < a.length; i++) {
177
+ diff[i] = a[i] - b[i];
178
+ }
179
+ return diff;
180
+ }
181
+ /**
182
+ * Divides this term by the provided term
183
+ *
184
+ * @param t - Divisor term.
185
+ * @returns A new quotient term; negative powers are permitted by this low-level operation.
186
+ */
187
+ div(t) {
188
+ const retval = this.copy();
189
+ retval.coeff = retval.coeff.div(t.coeff);
190
+ for (const v in t.powers) {
191
+ if (!retval.variables.includes(v)) {
192
+ retval.variables.push(v);
193
+ }
194
+ retval.deg(v, retval.deg(v) - t.deg(v));
195
+ }
196
+ return retval.update();
197
+ }
198
+ /**
199
+ * Checks if one term can divide another.
200
+ *
201
+ * @param t - Candidate dividend term.
202
+ * @returns Whether every power in this term is no greater than the corresponding power in `t`.
203
+ */
204
+ divides(t) {
205
+ // If it's a number, then it divides so easy check and done
206
+ if (this.getTotalPower() === 0) {
207
+ return true;
208
+ }
209
+ // Divides essentially loops through the dividend and ensures that each power is >= to the divisor for each variable
210
+ for (const x in this.powers) {
211
+ if (this.deg(x) > t.deg(x)) {
212
+ return false;
213
+ }
214
+ }
215
+ return true;
216
+ }
217
+ /**
218
+ * Checks for equality with another Term
219
+ *
220
+ * @param t - Term to compare.
221
+ * @returns Whether coefficient and monomial quotient equal one.
222
+ */
223
+ eq(t) {
224
+ return this.div(t).eqNumber(1);
225
+ }
226
+ /**
227
+ * Tests whether this is a constant term equal to a number.
228
+ *
229
+ * @param n - Numeric value to compare with the coefficient.
230
+ */
231
+ eqNumber(n) {
232
+ return (0, numeric_1.sum)(...Object.values(this.powers)) === 0 && this.coeff.eq(n);
233
+ }
234
+ /**
235
+ * Returns a lazily constructed expression for this term.
236
+ *
237
+ * @returns The cached internal expression reference.
238
+ */
239
+ getExpression() {
240
+ if (this.expression === undefined) {
241
+ let expression = this.coeff.copy();
242
+ for (const variable of this.variables) {
243
+ const power = this.deg(variable);
244
+ if (power !== 0) {
245
+ expression = expression.times(Expression_1.Expression.Variable(variable).pow(power));
246
+ }
247
+ }
248
+ this.expression = expression;
249
+ }
250
+ return this.expression;
251
+ }
252
+ /**
253
+ * Returns this term's multidegree in its stored variable order.
254
+ *
255
+ * @returns The cached internal degree array.
256
+ */
257
+ getMultidegArray() {
258
+ let retval = this.multidegArray;
259
+ if (retval === undefined) {
260
+ retval = this.updateMultiDegArray();
261
+ }
262
+ return retval;
263
+ }
264
+ /**
265
+ * Returns the sum of powers in this term.
266
+ *
267
+ * @returns The cached total degree.
268
+ */
269
+ getTotalPower() {
270
+ let retval = this.totalPower;
271
+ if (retval === undefined) {
272
+ retval = this.updateTotalPower();
273
+ }
274
+ return retval;
275
+ }
276
+ /**
277
+ * Formats the monomial with a unit coefficient.
278
+ *
279
+ * @param useVariables - Optional variable order used for this rendering.
280
+ * @returns Parser text such as `x^2*y`, or `1` for a constant term.
281
+ */
282
+ getValueString(useVariables) {
283
+ // If the user variables have been specified then force regeneration of the string.
284
+ if (this.valueString === undefined || useVariables !== undefined) {
285
+ if (this.getTotalPower() === 0) {
286
+ this.valueString = '1';
287
+ }
288
+ else {
289
+ const vars = useVariables || [...this.variables].sort();
290
+ const vArray = [];
291
+ for (const v of vars) {
292
+ const p = this.deg(v);
293
+ const pv = p === 1 ? '' : Expression_1.Expression.POW_OPR + p;
294
+ if (p !== 0) {
295
+ vArray.push(`${v}${pv}`);
296
+ }
297
+ }
298
+ this.valueString = vArray.join('*');
299
+ }
300
+ }
301
+ return this.valueString;
302
+ }
303
+ /**
304
+ * Tests whether every stored variable power is zero.
305
+ *
306
+ * @returns Whether the term is constant, independent of its coefficient value.
307
+ */
308
+ isConstant() {
309
+ for (const p in this.powers) {
310
+ if (this.powers[p] !== 0) {
311
+ return false;
312
+ }
313
+ }
314
+ return true;
315
+ }
316
+ /**
317
+ * Tests whether the coefficient is zero.
318
+ *
319
+ * @returns Whether the term's symbolic coefficient is zero.
320
+ */
321
+ isZero() {
322
+ return this.coeff.isZero();
323
+ }
324
+ /**
325
+ * Calculates the LCM of two terms with numeric coefficients
326
+ * TODO: Extend to non-numeric coefficients
327
+ *
328
+ * @param t - Other monomial term.
329
+ * @param withCoeff - Include the exact numeric coefficient LCM instead of using one.
330
+ * @returns A new term containing maximum powers for the union of variables.
331
+ */
332
+ LCM(t, withCoeff = false) {
333
+ const variables = (0, utils_1.arrayAddUnique)([...this.variables], t.variables);
334
+ const powers = {};
335
+ // Calculate the max power between this and t.
336
+ for (const v of variables) {
337
+ powers[v] = Math.max(this.deg(v), t.deg(v));
338
+ }
339
+ const coeff = withCoeff
340
+ ? Expression_1.Expression.fromRational(this.coeff.getMultiplier().LCM(t.coeff.getMultiplier()))
341
+ : '1';
342
+ return new Term(coeff, powers, variables);
343
+ }
344
+ /**
345
+ * Returns the variable name with the greatest stored power.
346
+ */
347
+ max() {
348
+ return Object.keys(this.powers).reduce((a, b) => (this.powers[a] > this.powers[b] ? a : b));
349
+ }
350
+ /**
351
+ * Returns the variable name with the least stored power.
352
+ */
353
+ min() {
354
+ return Object.keys(this.powers).reduce((a, b) => (this.powers[a] < this.powers[b] ? a : b));
355
+ }
356
+ /**
357
+ * Calculates the multidegree array
358
+ *
359
+ * @param variables - Variable order for the result.
360
+ * @returns A new power array, using zero for missing variables.
361
+ */
362
+ multideg(variables) {
363
+ const arr = [];
364
+ for (const v of variables) {
365
+ arr.push(this.deg(v));
366
+ }
367
+ return arr;
368
+ }
369
+ /**
370
+ * Gets the text representation of the monomial
371
+ *
372
+ * @param useVariables - Optional variable rendering order.
373
+ * @returns Canonical parser text for the coefficient and monomial.
374
+ */
375
+ text(useVariables) {
376
+ let c = this.coeff.text();
377
+ // Wrap sums in brackets
378
+ if (this.coeff.isSum()) {
379
+ c = `(${c})`;
380
+ }
381
+ let retval;
382
+ // Zero times anything is zero so nothing left to do
383
+ if (c === '0') {
384
+ retval = c;
385
+ }
386
+ else {
387
+ let v = this.getValueString(useVariables);
388
+ // Remove the safety '1';
389
+ if (v === '1') {
390
+ v = '';
391
+ }
392
+ // Add multiplication sign
393
+ if (v) {
394
+ if (c === '1') {
395
+ c = '';
396
+ }
397
+ else if (c === '-1') {
398
+ c = '-';
399
+ }
400
+ else {
401
+ c += '*';
402
+ }
403
+ }
404
+ retval = `${c}${v}`;
405
+ }
406
+ return retval;
407
+ }
408
+ /**
409
+ * Multiplies this term with the given term
410
+ *
411
+ * @param x - Multiplier term.
412
+ * @returns A new term with multiplied coefficients and added powers.
413
+ */
414
+ times(x) {
415
+ const retval = this.copy();
416
+ retval.coeff = retval.coeff.times(x.coeff);
417
+ for (const v in x.powers) {
418
+ if (!retval.variables.includes(v)) {
419
+ retval.variables.push(v);
420
+ }
421
+ retval.deg(v, retval.deg(v) + x.deg(v));
422
+ }
423
+ return retval.update();
424
+ }
425
+ /** Returns the same parser text as {@link Term.text}. */
426
+ toString() {
427
+ return this.text();
428
+ }
429
+ }
430
+ exports.Term = Term;
@@ -0,0 +1,18 @@
1
+ import { Polynomial } from './Polynomial';
2
+ import type { ExpressionInput } from '../../types';
3
+ /**
4
+ * Extracts the Z Polynomial from Q.
5
+ * Given a polynomial with rational coefficients, returns:
6
+ * - zPoly: the polynomial scaled to have integer coefficients (primitive part)
7
+ * - content: the GCD of the integer coefficients after clearing denominators
8
+ * - denominator: the common denominator used to clear fractions
9
+ *
10
+ * The relationship is: original = (content / denominator) * zPoly
11
+ *
12
+ * @param x
13
+ */
14
+ export declare function expressionToZPoly(x: ExpressionInput): {
15
+ zPoly: Polynomial;
16
+ content: Polynomial;
17
+ denominator: Polynomial;
18
+ };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expressionToZPoly = expressionToZPoly;
4
+ const Expression_1 = require("../expression/Expression");
5
+ const Polynomial_1 = require("./Polynomial");
6
+ const SparsePolynomialAdapter_1 = require("./SparsePolynomialAdapter");
7
+ /**
8
+ * Extracts the Z Polynomial from Q.
9
+ * Given a polynomial with rational coefficients, returns:
10
+ * - zPoly: the polynomial scaled to have integer coefficients (primitive part)
11
+ * - content: the GCD of the integer coefficients after clearing denominators
12
+ * - denominator: the common denominator used to clear fractions
13
+ *
14
+ * The relationship is: original = (content / denominator) * zPoly
15
+ *
16
+ * @param x
17
+ */
18
+ function expressionToZPoly(x) {
19
+ const expression = Expression_1.Expression.create(x);
20
+ const variables = expression.variables().sort();
21
+ const converted = (0, SparsePolynomialAdapter_1.expressionToIntegerSparsePolynomial)(expression, variables);
22
+ const coefficientContent = converted.polynomial.isZero()
23
+ ? 1n
24
+ : converted.polynomial.content();
25
+ const primitive = coefficientContent === 1n
26
+ ? converted.polynomial
27
+ : converted.polynomial.divideByScalarExact(coefficientContent);
28
+ return {
29
+ zPoly: new Polynomial_1.Polynomial((0, SparsePolynomialAdapter_1.sparsePolynomialToExpression)(primitive, variables), [...variables], 'lex'),
30
+ content: new Polynomial_1.Polynomial(Expression_1.Expression.Number(coefficientContent)),
31
+ denominator: new Polynomial_1.Polynomial(Expression_1.Expression.Number(converted.denominator)),
32
+ };
33
+ }
@@ -0,0 +1 @@
1
+ export declare function loadPolynomialFunctions(): void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadPolynomialFunctions = loadPolynomialFunctions;
4
+ const dispatch_1 = require("../../dispatch");
5
+ const functions_1 = require("./functions");
6
+ function loadPolynomialFunctions() {
7
+ Object.assign(dispatch_1.mathFunctionRegistry, {
8
+ deg: (0, dispatch_1.systemFunction)({ fn: functions_1.deg, minArgs: 1, maxArgs: 2, distElWise: true }),
9
+ content: (0, dispatch_1.systemFunction)({ fn: functions_1.content, minArgs: 1, maxArgs: 1, distElWise: true }),
10
+ coeffs: (0, dispatch_1.systemFunction)({ fn: functions_1.coeffs, minArgs: 1, maxArgs: 2, distElWise: false }),
11
+ div: (0, dispatch_1.systemFunction)({ fn: functions_1.div, minArgs: 2, maxArgs: 2, distElWise: false }),
12
+ divide: (0, dispatch_1.systemFunction)({ fn: functions_1.divide, minArgs: 2, maxArgs: 2, distElWise: false }),
13
+ });
14
+ }
@@ -0,0 +1,77 @@
1
+ import { Expression } from '../expression/Expression';
2
+ import { Vector } from '../vector/Vector';
3
+ import { Polynomial } from './Polynomial';
4
+ import type { ExpressionInput } from '../../types';
5
+ /**
6
+ * Returns the degree of a polynomial expression.
7
+ *
8
+ * @remarks
9
+ * With no variable, `deg(p)` returns the total degree: the largest sum of powers in any
10
+ * term. With a variable, `deg(p, x)` returns the largest power of `x`, treating the other
11
+ * variables as coefficients. If the input cannot be converted to a polynomial, the call
12
+ * remains symbolic instead of throwing.
13
+ *
14
+ * @param x - Expression-like input or polynomial to inspect.
15
+ * @param variable - Optional variable whose degree should be returned.
16
+ * @returns A numeric expression for polynomial input, otherwise an unevaluated `deg(...)` call.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * deg('x^2*y^3+x').text(); // "5"
21
+ * deg('x^2*y^3+x', 'x').text(); // "2"
22
+ * deg('x^2*y^3+x', 'y').text(); // "3"
23
+ * ```
24
+ */
25
+ export declare function deg(x: ExpressionInput | Polynomial, variable?: ExpressionInput): Expression;
26
+ /**
27
+ * Returns the exact numeric content of polynomial expression input.
28
+ *
29
+ * @remarks
30
+ * Content means the greatest common divisor of the polynomial's numeric coefficients.
31
+ * For example, the content of `6*x^2+15*x*y-3*y` is `3`. This function does not choose
32
+ * a main variable or compute a polynomial-valued GCD of symbolic coefficient expressions.
33
+ * If expression conversion fails, the operation remains symbolic as `content(input)`.
34
+ *
35
+ * @param x - Expression-like input or polynomial to inspect.
36
+ * @returns A numeric expression for converted input, otherwise an unevaluated symbolic
37
+ * `content` call.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * content('6*x^2+15*x-3').text(); // "3"
42
+ * ```
43
+ */
44
+ export declare function content(x: ExpressionInput | Polynomial): Expression;
45
+ /**
46
+ * Returns polynomial coefficients as a dense Vector ordered by ascending power.
47
+ *
48
+ * When no variable is supplied, the first variable in the expression is used, matching
49
+ * the legacy parser helper. A constant expression therefore has the single coefficient
50
+ * at power zero.
51
+ */
52
+ export declare function coeffs(x: ExpressionInput, variable?: ExpressionInput): Vector;
53
+ /**
54
+ * Returns the quotient and remainder of polynomial division.
55
+ *
56
+ * @remarks
57
+ * This is the parser-facing compatibility behavior historically exposed as `div(a,b)`.
58
+ * It delegates to the existing polynomial division implementation. When more than one
59
+ * variable is present, Nerdamer treats the input as a multivariable polynomial rather than
60
+ * silently choosing one variable and treating the others as coefficients. If either input
61
+ * is not polynomial-like, the legacy fallback is preserved as `[0, dividend]`. Once both
62
+ * inputs are polynomial, failures from the division engine are allowed to propagate.
63
+ */
64
+ export declare function div(dividend: ExpressionInput, divisor: ExpressionInput): Vector;
65
+ /**
66
+ * Divides two expressions using polynomial quotient/remainder reconstruction when possible.
67
+ *
68
+ * @remarks
69
+ * This restores the parser-facing compatibility behavior historically exposed as
70
+ * `divide(a,b)`: a successful polynomial division is returned as
71
+ * `quotient + remainder/divisor`, so the result is a reusable symbolic expression. When
72
+ * more than one variable is present, Nerdamer treats the input as a multivariable polynomial
73
+ * rather than silently choosing a main variable. Inputs outside the polynomial domain fall
74
+ * back to ordinary symbolic division. Once both inputs are polynomial, failures from the
75
+ * division engine are allowed to propagate.
76
+ */
77
+ export declare function divide(dividend: ExpressionInput, divisor: ExpressionInput): Expression;