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,11 @@
1
+ import { Expression } from '../classes/expression/Expression';
2
+ /**
3
+ * Rewrites exact ratios to a common denominator without invoking algebra-level
4
+ * factoring or simplification.
5
+ *
6
+ * @remarks
7
+ * Core comparison uses this normalization to determine whether an exact symbolic
8
+ * difference is zero. Algebra also reuses the same implementation for rational
9
+ * simplification, keeping the dependency direction from algebra to core.
10
+ */
11
+ export declare function toCommonDenominator(x: Expression): Expression;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toCommonDenominator = toCommonDenominator;
4
+ const Expression_1 = require("../classes/expression/Expression");
5
+ const shortcuts_1 = require("../classes/expression/shortcuts");
6
+ /**
7
+ * Groups additive terms that already share the same symbolic denominator.
8
+ *
9
+ * This is part of core exact normalization rather than the higher-level algebra
10
+ * simplifier because symbolic comparison relies on it for zero/equality checks.
11
+ */
12
+ function groupByDenominator(x) {
13
+ let retval = x;
14
+ if (x.isSum()) {
15
+ let nonRationals = (0, shortcuts_1.zero)();
16
+ const rationals = {};
17
+ x.each(e => {
18
+ const num = e.getNumerator();
19
+ const den = e.getDenominator();
20
+ // Numerator extraction is exact, so restore the term's decimal marker
21
+ // before regrouping it. Otherwise a decimal coefficient silently becomes
22
+ // an exact rational during common-denominator normalization.
23
+ if (e.getMultiplier().asDecimal) {
24
+ num.getMultiplier().asDecimal = true;
25
+ }
26
+ if (den.isOne()) {
27
+ nonRationals = nonRationals.plus(num);
28
+ }
29
+ else {
30
+ const key = den.text();
31
+ rationals[key] = rationals[key] ? rationals[key].plus(num) : num;
32
+ }
33
+ });
34
+ retval = nonRationals;
35
+ for (const denominator in rationals) {
36
+ retval = retval.plus(rationals[denominator].div(Expression_1.Expression.create(denominator)));
37
+ }
38
+ retval = retval.pow(x.getPower()).times(x.getMultiplier());
39
+ }
40
+ return retval;
41
+ }
42
+ /**
43
+ * Rewrites exact ratios to a common denominator without invoking algebra-level
44
+ * factoring or simplification.
45
+ *
46
+ * @remarks
47
+ * Core comparison uses this normalization to determine whether an exact symbolic
48
+ * difference is zero. Algebra also reuses the same implementation for rational
49
+ * simplification, keeping the dependency direction from algebra to core.
50
+ */
51
+ function toCommonDenominator(x) {
52
+ let retval = x;
53
+ if (x.isProduct()) {
54
+ retval = Expression_1.Expression.fromRational(x.getMultiplier());
55
+ x.each(e => {
56
+ e = e.pow(x.getPower());
57
+ if (e.isSum()) {
58
+ retval = retval.times(toCommonDenominator(e));
59
+ }
60
+ else {
61
+ retval = retval.times(e);
62
+ }
63
+ });
64
+ }
65
+ else if (x.isSum()) {
66
+ x = groupByDenominator(x);
67
+ if (!x.isSum()) {
68
+ return x;
69
+ }
70
+ const p = x.getPower().abs();
71
+ const m = x.getMultiplier();
72
+ const terms = x.elementsArray();
73
+ let hasNonTrivialDenominator = false;
74
+ let hasSymbolicDenominator = false;
75
+ for (const e of terms) {
76
+ const den = e.getDenominator();
77
+ if (!den.isOne()) {
78
+ hasNonTrivialDenominator = true;
79
+ if (!den.isNUM()) {
80
+ hasSymbolicDenominator = true;
81
+ }
82
+ }
83
+ }
84
+ if (!hasNonTrivialDenominator) {
85
+ return x;
86
+ }
87
+ if (!hasSymbolicDenominator && !x.isPolynomialLike()) {
88
+ return x;
89
+ }
90
+ let numerator = (0, shortcuts_1.zero)();
91
+ let denominator = (0, shortcuts_1.one)();
92
+ for (const e of terms) {
93
+ const normalizedTerm = toCommonDenominator(e);
94
+ const num = normalizedTerm.getNumerator();
95
+ const den = normalizedTerm.getDenominator();
96
+ // getNumerator() returns the exact rational numerator, so carry the
97
+ // original term's decimal intent onto that numerator before combining
98
+ // fractions. This keeps decimal contagion intact through the rewrite.
99
+ if (e.getMultiplier().asDecimal) {
100
+ num.getMultiplier().asDecimal = true;
101
+ }
102
+ numerator = numerator.times(den).plus(denominator.times(num));
103
+ denominator = denominator.times(den);
104
+ }
105
+ if (x.getPower().sign() === -1) {
106
+ [denominator, numerator] = [numerator, denominator];
107
+ }
108
+ retval = numerator.div(denominator);
109
+ if (!p.isOne()) {
110
+ retval = retval.pow(p);
111
+ }
112
+ if (!m.isOne()) {
113
+ retval = retval.times(Expression_1.Expression.fromRational(m));
114
+ }
115
+ }
116
+ return retval;
117
+ }
@@ -0,0 +1,19 @@
1
+ import type { ExpressionFunction, JsFunction } from '../classes/parser/types';
2
+ import type { RegisteredMathFunction } from '../dispatch';
3
+ interface SetFunctionBaseParams {
4
+ name: string;
5
+ minArgs?: number;
6
+ maxArgs?: number;
7
+ }
8
+ export interface SetJSFunctionParams extends SetFunctionBaseParams {
9
+ type: 'js';
10
+ fn: JsFunction;
11
+ }
12
+ export interface SetSymbolicFunctionParams extends SetFunctionBaseParams {
13
+ type: 'symbolic';
14
+ fn: string | RegisteredMathFunction | ExpressionFunction;
15
+ argsOrder?: string[];
16
+ }
17
+ export type SetFunctionParams = SetJSFunctionParams | SetSymbolicFunctionParams;
18
+ export declare function setFunction(params: SetFunctionParams): void;
19
+ export {};
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setFunction = setFunction;
4
+ const Expression_1 = require("../classes/expression/Expression");
5
+ const functions_1 = require("../classes/parser/scripting/functions");
6
+ const dispatch_1 = require("../dispatch");
7
+ const errors_1 = require("../errors");
8
+ /**
9
+ * This is essentially a wrapper around the user provided JS function. It checks each input
10
+ * to ensure that it can be converted to a number. If all inputs are numbers, then the
11
+ * function is called, otherwise a symbolic function is returned.
12
+ *
13
+ * @param name
14
+ * @param fn
15
+ * @returns
16
+ */
17
+ function jsWrapper(name, fn) {
18
+ return (...expressions) => {
19
+ const args = [];
20
+ for (const e of expressions) {
21
+ if (e.isNUM()) {
22
+ args.push(Number(e.getMultiplier().toDecimal()));
23
+ }
24
+ else {
25
+ return Expression_1.Expression.toFunction(name, expressions);
26
+ }
27
+ }
28
+ return Expression_1.Expression.create(Number(fn(...args)));
29
+ };
30
+ }
31
+ function entry(minArgs, maxArgs, fn, maxPrecision) {
32
+ return {
33
+ minArgs,
34
+ maxArgs,
35
+ fn,
36
+ maxPrecision,
37
+ usage: 'notation',
38
+ level: 'user',
39
+ };
40
+ }
41
+ function setFunction(params) {
42
+ const existing = dispatch_1.mathFunctionRegistry[params.name];
43
+ if (existing?.level === 'system') {
44
+ throw new errors_1.AssignmentError((0, errors_1.message)('restrictedVariableName', { name: params.name }));
45
+ }
46
+ if (params.type === 'js') {
47
+ const name = params.name;
48
+ if (typeof params.fn !== 'function') {
49
+ throw new errors_1.UnexpectedInputError((0, errors_1.message)('setJSFunctionExpectsFunction'));
50
+ }
51
+ if (!params.minArgs || !params.maxArgs) {
52
+ throw new errors_1.UnexpectedInputError((0, errors_1.message)('functionRequiresMinAndMaxArgs'));
53
+ }
54
+ dispatch_1.mathFunctionRegistry[name] = entry(params.minArgs, params.maxArgs, jsWrapper(name, params.fn), 17);
55
+ }
56
+ else if (params.type === 'symbolic') {
57
+ // Check if the user provided a string
58
+ if (typeof params.fn === 'string') {
59
+ // Only parse the body when argument order must be inferred. Parsing a body with
60
+ // control flow should not execute that control flow during registration.
61
+ const args = params.argsOrder ?? Expression_1.Expression.create(params.fn).variables().sort();
62
+ dispatch_1.mathFunctionRegistry[params.name] = entry(
63
+ // If the user didn't provide a min and max arg number then default to the args length
64
+ params.minArgs ?? args.length, params.maxArgs ?? args.length, (0, functions_1.wrappedFunction)(params.fn, args));
65
+ }
66
+ // This one is the simplest one of them all. Just set the function and be done
67
+ else {
68
+ const name = params.name;
69
+ if (params.minArgs === undefined || params.maxArgs === undefined) {
70
+ throw new errors_1.UnexpectedInputError((0, errors_1.message)('functionRequiresMinAndMaxArgs'));
71
+ }
72
+ dispatch_1.mathFunctionRegistry[name] = entry(params.minArgs, params.maxArgs, params.fn);
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Converts a string from scientific notation form to decimal form
3
+ *
4
+ * @param str
5
+ * @returns
6
+ */
7
+ export declare function scientificToDecimal(str: string): string;
8
+ /**
9
+ * Splits at the decimal but ensures that array length is always 2
10
+ *
11
+ * @param str
12
+ * @returns
13
+ */
14
+ export declare function decimalSplit(str: string): string[];
15
+ /**
16
+ * A helper function to replace multiple occurrences in a string. Tag the replacement
17
+ * with a double curly.
18
+ * @example format('Hi. My name is {{name}}.', {name: 'John Doe'})
19
+ *
20
+ * @param str
21
+ * @param replacements
22
+ * @returns
23
+ */
24
+ export declare function format(str: string, replacements: {
25
+ [replacement: string]: string;
26
+ } | string[]): string;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scientificToDecimal = scientificToDecimal;
4
+ exports.decimalSplit = decimalSplit;
5
+ exports.format = format;
6
+ const errors_1 = require("../errors");
7
+ /**
8
+ * Removes the minus sign from the beginning of the string
9
+ *
10
+ * @param str
11
+ * @returns an array with the first item as true if a minus
12
+ * was found and the string minus the minus sign.
13
+ */
14
+ function stripSign(str) {
15
+ // Check if it has a minus sign
16
+ const hasMinus = str.charAt(0) === '-';
17
+ // Remove it if it does
18
+ if (hasMinus || str.charAt(0) === '+') {
19
+ str = str.substring(1);
20
+ }
21
+ return [hasMinus, str];
22
+ }
23
+ /**
24
+ * Converts a string from scientific notation form to decimal form
25
+ *
26
+ * @param str
27
+ * @returns
28
+ */
29
+ function scientificToDecimal(str) {
30
+ let isNegative;
31
+ // Remove the sign by slicing the string
32
+ [isNegative, str] = stripSign(str);
33
+ // Split it into coefficient and exponent
34
+ const [c, e] = str.toLowerCase().split('e');
35
+ // Split the coefficient into the whole and decimal portion
36
+ // eslint-disable-next-line prefer-const
37
+ let [w, d] = c.split('.');
38
+ // Provide and empty sting for safety if in the form n(e)n
39
+ d = d || '';
40
+ // The total length of the string
41
+ const length = w.length + (d ? d.length : 0);
42
+ // The total string minus the dot
43
+ const numString = w + d;
44
+ // If it's small then we need to calculate the leading zeros
45
+ // The shift of the decimal place to the left
46
+ const dotLocation = w.length + Number(e);
47
+ // Is the dot needed or not
48
+ const dot = dotLocation === length ? '' : '.';
49
+ let value;
50
+ if (dotLocation <= 0) {
51
+ // Join the value but pad after the dot with zeroes
52
+ value = `0${dot}${'0'.repeat(Math.abs(dotLocation))}${numString}`;
53
+ }
54
+ else if (dotLocation > length) {
55
+ value = `${numString}${'0'.repeat(Math.abs(dotLocation - length))}`;
56
+ }
57
+ else {
58
+ value = `${numString.substring(0, dotLocation)}${dot}${numString.substring(dotLocation)}`;
59
+ }
60
+ return isNegative ? '-' + value : value;
61
+ }
62
+ /**
63
+ * Splits at the decimal but ensures that array length is always 2
64
+ *
65
+ * @param str
66
+ * @returns
67
+ */
68
+ function decimalSplit(str) {
69
+ const parts = str.split('.');
70
+ if (parts.length > 2) {
71
+ throw new SyntaxError((0, errors_1.message)('invalidDecimalValue', { value: str }));
72
+ }
73
+ if (parts.length === 1) {
74
+ parts.push('');
75
+ }
76
+ return parts;
77
+ }
78
+ /**
79
+ * A helper function to replace multiple occurrences in a string. Tag the replacement
80
+ * with a double curly.
81
+ * @example format('Hi. My name is {{name}}.', {name: 'John Doe'})
82
+ *
83
+ * @param str
84
+ * @param replacements
85
+ * @returns
86
+ */
87
+ function format(str, replacements) {
88
+ const replace = function (str, replacement, newValue) {
89
+ return str.replace(new RegExp(`{{${replacement}}}`, 'g'), newValue);
90
+ };
91
+ if (Array.isArray(replacements)) {
92
+ for (let i = 0; i < replacements.length; i++) {
93
+ str = replace(str, String(i), replacements[i]);
94
+ }
95
+ }
96
+ else {
97
+ for (const x in replacements) {
98
+ str = replace(str, x, replacements[x]);
99
+ }
100
+ }
101
+ return str;
102
+ }
@@ -0,0 +1,90 @@
1
+ import { Expression } from '../classes/expression/Expression';
2
+ import type { ExpressionInput } from '../types';
3
+ /** Maps generated substitution symbols such as `u0` back to their original expressions. */
4
+ export type SubstitutionMap = Record<string, Expression>;
5
+ /** Result returned by {@link uSub}. */
6
+ export type USubstitutionResult = [
7
+ expression: Expression,
8
+ substitutions: SubstitutionMap
9
+ ];
10
+ /** @deprecated Use {@link SubstitutionMap}. */
11
+ export type MapObjectType = SubstitutionMap;
12
+ export declare function prodSubst(expression: Expression, value: Expression, withValue: Expression, includeNumeric?: boolean): Expression;
13
+ /**
14
+ * Performs a substitution on a sum
15
+ *
16
+ * @param expression
17
+ * @param value
18
+ * @param withValue
19
+ * @returns
20
+ */
21
+ export declare function sumSubst(expression: Expression, value: Expression, withValue: Expression, includeNumeric?: boolean): Expression;
22
+ /**
23
+ * Replaces a value with another using the existing Expression tree.
24
+ *
25
+ * @param expression The expression being used to perform the substitution
26
+ * @param value The value currently in the expression
27
+ * @param withValue The value that the substitution is being replaced with
28
+ */
29
+ export declare function subst(expression: ExpressionInput, value: ExpressionInput, withValue: ExpressionInput, includeNumeric?: boolean): Expression;
30
+ export declare function getU(x: ExpressionInput, map?: MapObjectType): string;
31
+ /**
32
+ * Replaces one repeated sub-expression with a generated `uN` symbol.
33
+ *
34
+ * The generated symbol is chosen so it does not collide with variables already present
35
+ * in the expression or substitution map. Pass the returned map to later calls when
36
+ * several substitutions should share one namespace, then use {@link uUnSub} to restore
37
+ * the original expressions.
38
+ *
39
+ * @param x - Expression in which the substitution will occur.
40
+ * @param value - Sub-expression to replace.
41
+ * @param map - Existing substitution map to extend.
42
+ * @returns The substituted expression and the updated substitution map.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const [substituted, map] = uSub('cos(x)^2+cos(x)+1', 'cos(x)');
47
+ * substituted.text({ sort: true }); // "u0^2+u0+1"
48
+ * uUnSub(substituted, map).eq('cos(x)^2+cos(x)+1'); // true
49
+ * ```
50
+ */
51
+ export declare function uSub(x: ExpressionInput, value: ExpressionInput, map?: SubstitutionMap): USubstitutionResult;
52
+ /**
53
+ * Rewrites powers of one variable through a radical substitution without
54
+ * sending the replacement back through generic nested-power simplification.
55
+ * The caller supplies the substitution degree, so fractional powers become
56
+ * exact integer powers of the replacement variable when possible.
57
+ */
58
+ export declare function rewriteRadicals(e: Expression, variable: string, newVar: Expression, n: bigint): Expression;
59
+ export declare function subRadicals(x: Expression): [Expression, MapObjectType];
60
+ /**
61
+ * Restores substitutions produced by {@link uSub}.
62
+ *
63
+ * @param expression - Expression containing generated substitution symbols.
64
+ * @param map - Map returned by one or more u-substitution calls.
65
+ * @returns The expression after restoring every mapped value.
66
+ */
67
+ export declare function uUnSub(expression: Expression, map: SubstitutionMap): Expression;
68
+ /**
69
+ * Performs a u-substitution of all the constants in the expression.
70
+ *
71
+ * @param expression
72
+ * @param map
73
+ * @returns
74
+ */
75
+ export declare function uSubConstants(expression: Expression, map?: MapObjectType): [Expression, MapObjectType];
76
+ /**
77
+ * Performs a u-substitution on all the functions in the expression
78
+ *
79
+ * @param expression
80
+ * @param map
81
+ * @returns
82
+ */
83
+ export declare function uSubFN(expression: Expression, map?: MapObjectType): [Expression, MapObjectType];
84
+ /**
85
+ * Performs a u-substitution on all the exponential functions in the expression
86
+ * @param expression
87
+ * @param map
88
+ * @returns
89
+ */
90
+ export declare function uSubEXP(expression: Expression, map?: MapObjectType): [Expression, MapObjectType];