nerdamer 1.1.13 → 2.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/LICENSE.md +184 -0
  2. package/README.md +293 -312
  3. package/dist/bundle.js +2 -0
  4. package/dist/bundle.js.LICENSE.txt +7 -0
  5. package/dist/parser.js +2 -0
  6. package/dist/parser.js.LICENSE.txt +7 -0
  7. package/docs-data/parser-functions.json +1960 -0
  8. package/index.d.ts +10 -426
  9. package/output/algebra/adapters.d.ts +33 -0
  10. package/output/algebra/adapters.js +109 -0
  11. package/output/algebra/algorithms/arith.d.ts +84 -0
  12. package/output/algebra/algorithms/arith.js +323 -0
  13. package/output/algebra/algorithms/factor.d.ts +3 -0
  14. package/output/algebra/algorithms/factor.js +5 -0
  15. package/output/algebra/algorithms/factorMultivariate.d.ts +23 -0
  16. package/output/algebra/algorithms/factorMultivariate.js +2393 -0
  17. package/output/algebra/algorithms/factorUnivariate.d.ts +72 -0
  18. package/output/algebra/algorithms/factorUnivariate.js +1072 -0
  19. package/output/algebra/algorithms/gcd.d.ts +22 -0
  20. package/output/algebra/algorithms/gcd.js +690 -0
  21. package/output/algebra/algorithms/groebnerBase.d.ts +157 -0
  22. package/output/algebra/algorithms/groebnerBase.js +1166 -0
  23. package/output/algebra/algorithms/multiPoly/MultiPoly.d.ts +137 -0
  24. package/output/algebra/algorithms/multiPoly/MultiPoly.js +346 -0
  25. package/output/algebra/algorithms/poly.d.ts +228 -0
  26. package/output/algebra/algorithms/poly.js +1299 -0
  27. package/output/algebra/algorithms/rational.d.ts +17 -0
  28. package/output/algebra/algorithms/rational.js +115 -0
  29. package/output/algebra/factor/factor.d.ts +62 -0
  30. package/output/algebra/factor/factor.js +158 -0
  31. package/output/algebra/gcd/gcd.d.ts +29 -0
  32. package/output/algebra/gcd/gcd.js +141 -0
  33. package/output/algebra/groebner.d.ts +21 -0
  34. package/output/algebra/groebner.js +42 -0
  35. package/output/algebra/partfrac.d.ts +19 -0
  36. package/output/algebra/partfrac.js +398 -0
  37. package/output/algebra/polynomialize.d.ts +20 -0
  38. package/output/algebra/polynomialize.js +24 -0
  39. package/output/algebra/simplify/complexsimp.d.ts +7 -0
  40. package/output/algebra/simplify/complexsimp.js +24 -0
  41. package/output/algebra/simplify/factorCommon.d.ts +13 -0
  42. package/output/algebra/simplify/factorCommon.js +136 -0
  43. package/output/algebra/simplify/funcsimp.d.ts +26 -0
  44. package/output/algebra/simplify/funcsimp.js +633 -0
  45. package/output/algebra/simplify/invtrigrewrite.d.ts +10 -0
  46. package/output/algebra/simplify/invtrigrewrite.js +96 -0
  47. package/output/algebra/simplify/ratsimp.d.ts +21 -0
  48. package/output/algebra/simplify/ratsimp.js +140 -0
  49. package/output/algebra/simplify/simplify.d.ts +25 -0
  50. package/output/algebra/simplify/simplify.js +228 -0
  51. package/output/algebra/simplify/trigreduce.d.ts +38 -0
  52. package/output/algebra/simplify/trigreduce.js +424 -0
  53. package/output/algebra/simplify/trigrewrite.d.ts +17 -0
  54. package/output/algebra/simplify/trigrewrite.js +156 -0
  55. package/output/algebra/simplify/trigsimp.d.ts +11 -0
  56. package/output/algebra/simplify/trigsimp.js +369 -0
  57. package/output/algebra/simplify/utils.d.ts +32 -0
  58. package/output/algebra/simplify/utils.js +56 -0
  59. package/output/algebra/utils.d.ts +32 -0
  60. package/output/algebra/utils.js +48 -0
  61. package/output/api/advanced.d.ts +7 -0
  62. package/output/api/advanced.js +18 -0
  63. package/output/api/algebra.d.ts +17 -0
  64. package/output/api/algebra.js +32 -0
  65. package/output/api/assumptions.d.ts +4 -0
  66. package/output/api/assumptions.js +11 -0
  67. package/output/api/calculus.d.ts +9 -0
  68. package/output/api/calculus.js +21 -0
  69. package/output/api/core.d.ts +17 -0
  70. package/output/api/core.js +41 -0
  71. package/output/api/debug.d.ts +16 -0
  72. package/output/api/debug.js +23 -0
  73. package/output/api/parser.d.ts +85 -0
  74. package/output/api/parser.js +16 -0
  75. package/output/api/solve.d.ts +10 -0
  76. package/output/api/solve.js +16 -0
  77. package/output/api/structures.d.ts +10 -0
  78. package/output/api/structures.js +22 -0
  79. package/output/calculus/derivative/diff.d.ts +30 -0
  80. package/output/calculus/derivative/diff.js +238 -0
  81. package/output/calculus/fresnel.d.ts +16 -0
  82. package/output/calculus/fresnel.js +39 -0
  83. package/output/calculus/integrate/byParts.d.ts +18 -0
  84. package/output/calculus/integrate/byParts.js +339 -0
  85. package/output/calculus/integrate/bySubstitution.d.ts +135 -0
  86. package/output/calculus/integrate/bySubstitution.js +411 -0
  87. package/output/calculus/integrate/integrate.d.ts +38 -0
  88. package/output/calculus/integrate/integrate.js +652 -0
  89. package/output/calculus/integrate/integrationTable.d.ts +2 -0
  90. package/output/calculus/integrate/integrationTable.js +914 -0
  91. package/output/calculus/integrate/utils.d.ts +28 -0
  92. package/output/calculus/integrate/utils.js +96 -0
  93. package/output/calculus/laplace/ilaplace.d.ts +31 -0
  94. package/output/calculus/laplace/ilaplace.js +192 -0
  95. package/output/calculus/laplace/ilaplaceTable.d.ts +2 -0
  96. package/output/calculus/laplace/ilaplaceTable.js +200 -0
  97. package/output/calculus/laplace/laplace.d.ts +22 -0
  98. package/output/calculus/laplace/laplace.js +109 -0
  99. package/output/calculus/laplace/laplaceTable.d.ts +2 -0
  100. package/output/calculus/laplace/laplaceTable.js +187 -0
  101. package/output/calculus/limit/limit.d.ts +35 -0
  102. package/output/calculus/limit/limit.js +1183 -0
  103. package/output/calculus/limit/limitsTable.d.ts +2 -0
  104. package/output/calculus/limit/limitsTable.js +7 -0
  105. package/output/core/Settings.d.ts +32 -0
  106. package/output/core/Settings.js +68 -0
  107. package/output/core/adapters.d.ts +18 -0
  108. package/output/core/adapters.js +40 -0
  109. package/output/core/classes/assumption/Assumption.d.ts +218 -0
  110. package/output/core/classes/assumption/Assumption.js +605 -0
  111. package/output/core/classes/assumption/assertiveFunctions.d.ts +6 -0
  112. package/output/core/classes/assumption/assertiveFunctions.js +64 -0
  113. package/output/core/classes/assumption/assume.d.ts +90 -0
  114. package/output/core/classes/assumption/assume.js +145 -0
  115. package/output/core/classes/collection/Collection.d.ts +107 -0
  116. package/output/core/classes/collection/Collection.js +231 -0
  117. package/output/core/classes/complex/Complex.d.ts +99 -0
  118. package/output/core/classes/complex/Complex.js +135 -0
  119. package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
  120. package/output/core/classes/decimalSet/DecimalSet.js +453 -0
  121. package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
  122. package/output/core/classes/dictionary/Dictionary.js +213 -0
  123. package/output/core/classes/equation/Equation.d.ts +256 -0
  124. package/output/core/classes/equation/Equation.js +350 -0
  125. package/output/core/classes/expression/CoeffObject.d.ts +100 -0
  126. package/output/core/classes/expression/CoeffObject.js +198 -0
  127. package/output/core/classes/expression/Expression.d.ts +1674 -0
  128. package/output/core/classes/expression/Expression.js +2332 -0
  129. package/output/core/classes/expression/analysis.d.ts +25 -0
  130. package/output/core/classes/expression/analysis.js +218 -0
  131. package/output/core/classes/expression/collect.d.ts +9 -0
  132. package/output/core/classes/expression/collect.js +49 -0
  133. package/output/core/classes/expression/format.d.ts +45 -0
  134. package/output/core/classes/expression/format.js +217 -0
  135. package/output/core/classes/expression/products.d.ts +23 -0
  136. package/output/core/classes/expression/products.js +115 -0
  137. package/output/core/classes/expression/shortcuts.d.ts +35 -0
  138. package/output/core/classes/expression/shortcuts.js +129 -0
  139. package/output/core/classes/expression/traversal.d.ts +31 -0
  140. package/output/core/classes/expression/traversal.js +216 -0
  141. package/output/core/classes/expression/trig.d.ts +25 -0
  142. package/output/core/classes/expression/trig.js +40 -0
  143. package/output/core/classes/expression/utils.d.ts +52 -0
  144. package/output/core/classes/expression/utils.js +189 -0
  145. package/output/core/classes/lookupTable/LookupTable.d.ts +12 -0
  146. package/output/core/classes/lookupTable/LookupTable.js +55 -0
  147. package/output/core/classes/matrix/Matrix.d.ts +227 -0
  148. package/output/core/classes/matrix/Matrix.js +889 -0
  149. package/output/core/classes/matrix/Sylvester.d.ts +11 -0
  150. package/output/core/classes/matrix/Sylvester.js +54 -0
  151. package/output/core/classes/matrix/functions.d.ts +26 -0
  152. package/output/core/classes/matrix/functions.js +52 -0
  153. package/output/core/classes/matrix/utils.d.ts +9 -0
  154. package/output/core/classes/matrix/utils.js +22 -0
  155. package/output/core/classes/parser/Parser.d.ts +480 -0
  156. package/output/core/classes/parser/Parser.js +1812 -0
  157. package/output/core/classes/parser/Token.d.ts +58 -0
  158. package/output/core/classes/parser/Token.js +137 -0
  159. package/output/core/classes/parser/constants.d.ts +160 -0
  160. package/output/core/classes/parser/constants.js +227 -0
  161. package/output/core/classes/parser/helpers.d.ts +21 -0
  162. package/output/core/classes/parser/helpers.js +42 -0
  163. package/output/core/classes/parser/operations/add.d.ts +15 -0
  164. package/output/core/classes/parser/operations/add.js +238 -0
  165. package/output/core/classes/parser/operations/comma.d.ts +7 -0
  166. package/output/core/classes/parser/operations/comma.js +11 -0
  167. package/output/core/classes/parser/operations/compare.d.ts +21 -0
  168. package/output/core/classes/parser/operations/compare.js +461 -0
  169. package/output/core/classes/parser/operations/divide.d.ts +2 -0
  170. package/output/core/classes/parser/operations/divide.js +72 -0
  171. package/output/core/classes/parser/operations/functions.d.ts +46 -0
  172. package/output/core/classes/parser/operations/functions.js +430 -0
  173. package/output/core/classes/parser/operations/multiply.d.ts +11 -0
  174. package/output/core/classes/parser/operations/multiply.js +321 -0
  175. package/output/core/classes/parser/operations/power.d.ts +48 -0
  176. package/output/core/classes/parser/operations/power.js +673 -0
  177. package/output/core/classes/parser/operations/subtract.d.ts +3 -0
  178. package/output/core/classes/parser/operations/subtract.js +35 -0
  179. package/output/core/classes/parser/preprocess.d.ts +14 -0
  180. package/output/core/classes/parser/preprocess.js +259 -0
  181. package/output/core/classes/parser/scripting/controlFlow.d.ts +121 -0
  182. package/output/core/classes/parser/scripting/controlFlow.js +355 -0
  183. package/output/core/classes/parser/scripting/evaluate.d.ts +10 -0
  184. package/output/core/classes/parser/scripting/evaluate.js +112 -0
  185. package/output/core/classes/parser/scripting/functions.d.ts +14 -0
  186. package/output/core/classes/parser/scripting/functions.js +59 -0
  187. package/output/core/classes/parser/scripting/scope.d.ts +35 -0
  188. package/output/core/classes/parser/scripting/scope.js +155 -0
  189. package/output/core/classes/parser/types.d.ts +125 -0
  190. package/output/core/classes/parser/types.js +2 -0
  191. package/output/core/classes/parser/wrappers/IndexedReference.d.ts +31 -0
  192. package/output/core/classes/parser/wrappers/IndexedReference.js +68 -0
  193. package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +24 -0
  194. package/output/core/classes/parser/wrappers/KeyValuePair.js +51 -0
  195. package/output/core/classes/polynomial/Polynomial.d.ts +500 -0
  196. package/output/core/classes/polynomial/Polynomial.js +1149 -0
  197. package/output/core/classes/polynomial/Term.d.ts +222 -0
  198. package/output/core/classes/polynomial/Term.js +430 -0
  199. package/output/core/classes/polynomial/functions.d.ts +69 -0
  200. package/output/core/classes/polynomial/functions.js +126 -0
  201. package/output/core/classes/polynomial/utils.d.ts +62 -0
  202. package/output/core/classes/polynomial/utils.js +206 -0
  203. package/output/core/classes/rational/Rational.d.ts +504 -0
  204. package/output/core/classes/rational/Rational.js +779 -0
  205. package/output/core/classes/seq/SEQ.d.ts +13 -0
  206. package/output/core/classes/seq/SEQ.js +137 -0
  207. package/output/core/classes/valuesSet/ValuesSet.d.ts +179 -0
  208. package/output/core/classes/valuesSet/ValuesSet.js +381 -0
  209. package/output/core/classes/vector/Vector.d.ts +222 -0
  210. package/output/core/classes/vector/Vector.js +497 -0
  211. package/output/core/classes/vector/functions.d.ts +28 -0
  212. package/output/core/classes/vector/functions.js +47 -0
  213. package/output/core/common/classes/MathematicalAggregate.d.ts +53 -0
  214. package/output/core/common/classes/MathematicalAggregate.js +140 -0
  215. package/output/core/common/classes/Scope.d.ts +62 -0
  216. package/output/core/common/classes/Scope.js +122 -0
  217. package/output/core/common/classes/StructuredEntity.d.ts +55 -0
  218. package/output/core/common/classes/StructuredEntity.js +151 -0
  219. package/output/core/common/common.d.ts +63 -0
  220. package/output/core/common/common.js +279 -0
  221. package/output/core/common/functions/functions.d.ts +14 -0
  222. package/output/core/common/functions/functions.js +33 -0
  223. package/output/core/common/functions/structuredEntityUtils.d.ts +27 -0
  224. package/output/core/common/functions/structuredEntityUtils.js +40 -0
  225. package/output/core/converters/BaseConverter.d.ts +97 -0
  226. package/output/core/converters/BaseConverter.js +405 -0
  227. package/output/core/converters/Converter.d.ts +111 -0
  228. package/output/core/converters/Converter.js +802 -0
  229. package/output/core/converters/Pattern.d.ts +71 -0
  230. package/output/core/converters/Pattern.js +302 -0
  231. package/output/core/dispatch.d.ts +34 -0
  232. package/output/core/dispatch.js +304 -0
  233. package/output/core/errors.d.ts +531 -0
  234. package/output/core/errors.js +621 -0
  235. package/output/core/functions/bigint/bigint.d.ts +121 -0
  236. package/output/core/functions/bigint/bigint.js +392 -0
  237. package/output/core/functions/bigint/primeFactor.d.ts +49 -0
  238. package/output/core/functions/bigint/primeFactor.js +267 -0
  239. package/output/core/functions/bigint/primes.d.ts +1 -0
  240. package/output/core/functions/bigint/primes.js +11 -0
  241. package/output/core/functions/build/definitions.d.ts +12 -0
  242. package/output/core/functions/build/definitions.js +133 -0
  243. package/output/core/functions/build/index.d.ts +32 -0
  244. package/output/core/functions/build/index.js +136 -0
  245. package/output/core/functions/complex.d.ts +90 -0
  246. package/output/core/functions/complex.js +482 -0
  247. package/output/core/functions/decimal.d.ts +24 -0
  248. package/output/core/functions/decimal.js +664 -0
  249. package/output/core/functions/expand/expand.d.ts +42 -0
  250. package/output/core/functions/expand/expand.js +376 -0
  251. package/output/core/functions/fresnelNumeric.d.ts +12 -0
  252. package/output/core/functions/fresnelNumeric.js +123 -0
  253. package/output/core/functions/numeric.d.ts +140 -0
  254. package/output/core/functions/numeric.js +790 -0
  255. package/output/core/functions/rationalNormalization.d.ts +11 -0
  256. package/output/core/functions/rationalNormalization.js +117 -0
  257. package/output/core/functions/setFunction.d.ts +19 -0
  258. package/output/core/functions/setFunction.js +75 -0
  259. package/output/core/functions/string.d.ts +26 -0
  260. package/output/core/functions/string.js +101 -0
  261. package/output/core/functions/subst.d.ts +90 -0
  262. package/output/core/functions/subst.js +498 -0
  263. package/output/core/functions/utils.d.ts +24 -0
  264. package/output/core/functions/utils.js +51 -0
  265. package/output/core/types.d.ts +48 -0
  266. package/output/core/types.js +2 -0
  267. package/output/index.d.ts +339 -0
  268. package/output/index.js +715 -0
  269. package/output/math/defint/defintDecimal.d.ts +37 -0
  270. package/output/math/defint/defintDecimal.js +320 -0
  271. package/output/math/defint/defintNative.d.ts +57 -0
  272. package/output/math/defint/defintNative.js +292 -0
  273. package/output/math/geometry.d.ts +8 -0
  274. package/output/math/geometry.js +32 -0
  275. package/output/math/math.d.ts +655 -0
  276. package/output/math/math.js +1811 -0
  277. package/output/math/trig.d.ts +518 -0
  278. package/output/math/trig.js +1444 -0
  279. package/output/math/trunc.d.ts +19 -0
  280. package/output/math/trunc.js +36 -0
  281. package/output/math/utils.d.ts +60 -0
  282. package/output/math/utils.js +180 -0
  283. package/output/solve/classes/DecimalMatrix.d.ts +17 -0
  284. package/output/solve/classes/DecimalMatrix.js +86 -0
  285. package/output/solve/classes/FunctionSolver.d.ts +135 -0
  286. package/output/solve/classes/FunctionSolver.js +433 -0
  287. package/output/solve/classes/MultivariateSolver.d.ts +84 -0
  288. package/output/solve/classes/MultivariateSolver.js +240 -0
  289. package/output/solve/classes/PolynomialSolver.d.ts +85 -0
  290. package/output/solve/classes/PolynomialSolver.js +292 -0
  291. package/output/solve/classes/SolutionSet.d.ts +153 -0
  292. package/output/solve/classes/SolutionSet.js +357 -0
  293. package/output/solve/classes/Solver.d.ts +17 -0
  294. package/output/solve/classes/Solver.js +132 -0
  295. package/output/solve/classes/SymbolicSolver.d.ts +74 -0
  296. package/output/solve/classes/SymbolicSolver.js +601 -0
  297. package/output/solve/linsolve.d.ts +51 -0
  298. package/output/solve/linsolve.js +225 -0
  299. package/output/solve/solve.d.ts +34 -0
  300. package/output/solve/solve.js +260 -0
  301. package/output/solve/solveSystem.d.ts +31 -0
  302. package/output/solve/solveSystem.js +290 -0
  303. package/output/solve/utils.d.ts +9 -0
  304. package/output/solve/utils.js +62 -0
  305. package/output/utils/array.d.ts +42 -0
  306. package/output/utils/array.js +98 -0
  307. package/output/utils/debug.d.ts +131 -0
  308. package/output/utils/debug.js +295 -0
  309. package/output/utils/decimal.d.ts +3 -0
  310. package/output/utils/decimal.js +16 -0
  311. package/output/utils/numeric.d.ts +14 -0
  312. package/output/utils/numeric.js +51 -0
  313. package/output/utils/object.d.ts +26 -0
  314. package/output/utils/object.js +56 -0
  315. package/package.json +213 -57
  316. package/.travis.yml +0 -3
  317. package/Algebra.js +0 -4568
  318. package/BREAKING_CHANGES.md +0 -5
  319. package/CODE_OF_CONDUCT.md +0 -46
  320. package/CONTRIBUTING.md +0 -14
  321. package/Calculus.js +0 -2675
  322. package/Extra.js +0 -622
  323. package/Solve.js +0 -1783
  324. package/all.js +0 -16
  325. package/all.min.js +0 -1
  326. package/gulpfile.js +0 -16
  327. package/index.html +0 -158
  328. package/license.txt +0 -19
  329. package/nerdamer.core.js +0 -12510
  330. package/spec/LaTeX.spec.js +0 -302
  331. package/spec/TeXConvert.spec.js +0 -8
  332. package/spec/algebra.spec.js +0 -287
  333. package/spec/basic_parser.spec.js +0 -134
  334. package/spec/build.spec.js +0 -131
  335. package/spec/calculus.spec.js +0 -183
  336. package/spec/core.spec.js +0 -2970
  337. package/spec/extra.spec.js +0 -54
  338. package/spec/solve.spec.js +0 -126
  339. package/spec/support/jasmine.json +0 -11
  340. package/spec/support/utils.js +0 -42
  341. package/spec/text.spec.js +0 -132
@@ -0,0 +1,2 @@
1
+ import { LookupTable } from '../../core/classes/lookupTable/LookupTable';
2
+ export declare const tableOfLimits: LookupTable;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tableOfLimits = void 0;
4
+ const LookupTable_1 = require("../../core/classes/lookupTable/LookupTable");
5
+ const limitsTable = {};
6
+ exports.tableOfLimits = new LookupTable_1.LookupTable();
7
+ exports.tableOfLimits.addEntries(limitsTable);
@@ -0,0 +1,32 @@
1
+ import type { Language } from './errors';
2
+ export type SettingsType = {
3
+ USE_FRACTIONS: boolean;
4
+ ALLOW_BIGINT: boolean;
5
+ EVALUATE: boolean;
6
+ SUBSTITUTE: boolean;
7
+ LANGUAGE: Language;
8
+ ALLOW_IMPLICIT_MULTIPLICATION: boolean;
9
+ SORT_TERMS: boolean;
10
+ DEFER_SIMPLIFICATION: boolean;
11
+ REWRITE_SQRT: boolean;
12
+ MAX_FRAC_INT: bigint;
13
+ ALLOW_RAT_SUBS: boolean;
14
+ IMMUTABLE_VALUE_SETS: boolean;
15
+ USE_SINGLE_LETTER_VARIABLES: boolean;
16
+ MAX_PRODUCT_AND_SUMMATION_ITERATION: number;
17
+ MAX_LOOP_ITERATIONS: number;
18
+ INITIALIZE_RULES: boolean;
19
+ INDEX_BASE: number;
20
+ };
21
+ export declare const Settings: SettingsType;
22
+ /**
23
+ * Allows for the parser to run with a desired setting for a single call
24
+ *
25
+ * @param setting The setting to modified for the call
26
+ * @param value The value of the setting under which the function is called
27
+ * @param callback The function to be called
28
+ * @returns The result of the call
29
+ */
30
+ export declare function scopedBlock<T>(setting: string, value: boolean, callback: () => T): T;
31
+ export declare const RESTRICTED: string[];
32
+ export declare const SPECIAL: string[];
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SPECIAL = exports.RESTRICTED = exports.Settings = void 0;
4
+ exports.scopedBlock = scopedBlock;
5
+ const constants_1 = require("./classes/parser/constants");
6
+ exports.Settings = {
7
+ // Forces decimals to fractions.
8
+ USE_FRACTIONS: true,
9
+ // Allow bigInt to be used when numerator or denominator get huge
10
+ ALLOW_BIGINT: true,
11
+ // If this is true then functions and numbers will be evaluated
12
+ EVALUATE: false,
13
+ // If true variable substitution will be performed
14
+ SUBSTITUTE: true,
15
+ // The language being used
16
+ LANGUAGE: 'eng',
17
+ // Allows implicit multiplications
18
+ ALLOW_IMPLICIT_MULTIPLICATION: true,
19
+ // If true the terms will be sorted. The default is false because of the added overhead.
20
+ SORT_TERMS: false,
21
+ // Avoids certain simplifications if set to false for performance boots
22
+ DEFER_SIMPLIFICATION: false,
23
+ // If true powers of 1/2 will be rewritten back to sqrt
24
+ REWRITE_SQRT: true,
25
+ // The max allowable integer when factoring numerators and denominator
26
+ MAX_FRAC_INT: BigInt(1e60),
27
+ // If set to false then rational multipliers will not be allowed in substitutions
28
+ ALLOW_RAT_SUBS: false,
29
+ // If set to true, vectors, matrices, and collections will always return a copy
30
+ IMMUTABLE_VALUE_SETS: true,
31
+ // If true each letter will be treated a a variable
32
+ USE_SINGLE_LETTER_VARIABLES: false,
33
+ // The maximum iteration allowed in sum and product
34
+ MAX_PRODUCT_AND_SUMMATION_ITERATION: 1e4,
35
+ // The maximum number of completed iterations allowed for parser control-flow loops
36
+ MAX_LOOP_ITERATIONS: 1e4,
37
+ // If true then rules will be initialized on start
38
+ INITIALIZE_RULES: true,
39
+ // The base index for element access on vectors and matrices. 0 = zero-based, 1 = one-based.
40
+ INDEX_BASE: 0,
41
+ };
42
+ /**
43
+ * Allows for the parser to run with a desired setting for a single call
44
+ *
45
+ * @param setting The setting to modified for the call
46
+ * @param value The value of the setting under which the function is called
47
+ * @param callback The function to be called
48
+ * @returns The result of the call
49
+ */
50
+ function scopedBlock(setting, value, callback) {
51
+ let retval;
52
+ // Store the value being currently used
53
+ const currentSettingValue = exports.Settings[setting];
54
+ // Update the setting to the desired value
55
+ exports.Settings[setting] = value;
56
+ try {
57
+ retval = callback();
58
+ }
59
+ finally {
60
+ // Restore the value even if the callback throws
61
+ exports.Settings[setting] = currentSettingValue;
62
+ }
63
+ return retval;
64
+ }
65
+ // The list of restricted variables
66
+ exports.RESTRICTED = [constants_1.E, constants_1.PI_NAME, constants_1.DEFAULT_IMAGINARY, constants_1.INDEX_VARIABLE, constants_1.ALL_SYMBOL];
67
+ // The list of special values that get ignore at substitution
68
+ exports.SPECIAL = [constants_1.E, constants_1.PI_NAME];
@@ -0,0 +1,18 @@
1
+ import { Polynomial } from './classes/polynomial/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,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expressionToZPoly = expressionToZPoly;
4
+ const Expression_1 = require("./classes/expression/Expression");
5
+ const Polynomial_1 = require("./classes/polynomial/Polynomial");
6
+ const bigint_1 = require("./functions/bigint/bigint");
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
+ x = Expression_1.Expression.create(x);
20
+ const p = new Polynomial_1.Polynomial(x);
21
+ const denominators = [];
22
+ for (const term of p.terms) {
23
+ const m = term.coeff.getMultiplier();
24
+ denominators.push(m.denominator);
25
+ }
26
+ // LCM of all denominators to clear fractions
27
+ const lcmDenom = denominators.reduce((acc, d) => (0, bigint_1.LCM)(acc, d), 1n);
28
+ const common = new Polynomial_1.Polynomial(Expression_1.Expression.Number(lcmDenom));
29
+ // Scale to integer coefficients
30
+ const q = p.times(common);
31
+ // Extract content (GCD of integer coefficients)
32
+ const content = new Polynomial_1.Polynomial(q.content());
33
+ // Get the primitive part
34
+ const pp = q.div(content)[0];
35
+ return {
36
+ zPoly: pp,
37
+ content: content,
38
+ denominator: common,
39
+ };
40
+ }
@@ -0,0 +1,218 @@
1
+ import Decimal from 'decimal.js';
2
+ import { Expression } from '../expression/Expression';
3
+ import { ASSUMPTION } from '../parser/constants';
4
+ import { Rational } from '../rational/Rational';
5
+ /**
6
+ * One endpoint of an {@link Assumption} interval.
7
+ *
8
+ * Infinity is always represented as an open endpoint because it is not itself a
9
+ * member of a real interval. `value` remains Decimal-facing for API compatibility;
10
+ * finite bounds also retain an exact rational representation internally.
11
+ */
12
+ export type Bound = Readonly<{
13
+ value: Decimal;
14
+ inclusive: boolean;
15
+ }>;
16
+ /** Result returned by {@link Assumption.parse}. */
17
+ export type ParsedAssumption = Readonly<{
18
+ symbol: string;
19
+ assumption: Assumption;
20
+ }>;
21
+ /** Numeric input accepted when constructing interval assumptions. */
22
+ export type AssumptionValue = Decimal | Rational | string | number;
23
+ /**
24
+ * Result of a comparison involving an interval-constrained value.
25
+ *
26
+ * `true` means the relation holds for every value allowed by the assumption.
27
+ * `false` means the opposite relation holds for every allowed value. `undefined`
28
+ * means both outcomes remain possible, so the relation cannot be proved from the
29
+ * available interval information.
30
+ */
31
+ export type AssumptionComparison = true | false | undefined;
32
+ /**
33
+ * Describes the admissible real values of a symbolic variable as one numeric interval.
34
+ *
35
+ * @remarks
36
+ * An `Assumption` is an interval constraint, not a symbolic theorem. It can prove
37
+ * relations when the interval bounds force an answer, disprove them when the bounds
38
+ * force the opposite answer, and otherwise reports an unknown result as `undefined`.
39
+ * Two variables having the same admissible interval therefore does not prove that the
40
+ * variables are equal.
41
+ *
42
+ * Instances are immutable. Repeated assumptions for a variable are intersected by
43
+ * the global assumption registry rather than modifying an existing interval.
44
+ *
45
+ * Finite bounds preserve an exact rational value internally. Decimal inputs therefore
46
+ * retain the exact value represented by their decimal text, while Rational inputs such
47
+ * as `1/3` are not rounded through Decimal precision before comparisons are made.
48
+ *
49
+ * The 2.0 assumption vocabulary covers a single real interval with numeric bounds.
50
+ * Integer, parity, complex-domain, relational (`x > y`), union, and general predicate
51
+ * assumptions are not represented by this class.
52
+ */
53
+ export declare class Assumption {
54
+ private readonly endExact;
55
+ private readonly startExact;
56
+ /** Runtime tag used by Nerdamer's assumption type guard. */
57
+ readonly dataType: typeof ASSUMPTION;
58
+ /** Upper endpoint of the admissible interval. */
59
+ readonly end: Bound;
60
+ /** Whether the interval contains exactly one finite value. */
61
+ readonly isSingleton: boolean;
62
+ /** Lower endpoint of the admissible interval. */
63
+ readonly start: Bound;
64
+ /**
65
+ * Creates a non-empty real interval.
66
+ *
67
+ * @remarks
68
+ * Infinite endpoints are normalized to open bounds. A zero-width interval is valid
69
+ * only when both endpoints are inclusive, in which case it represents one exact
70
+ * value. Rational inputs retain their exact value even when their Decimal projection
71
+ * is necessarily finite precision.
72
+ *
73
+ * @param start - Lower numeric endpoint.
74
+ * @param end - Upper numeric endpoint.
75
+ * @param startInclusive - Include the lower endpoint when it is finite.
76
+ * @param endInclusive - Include the upper endpoint when it is finite.
77
+ * @throws Error
78
+ * Thrown when a bound is `NaN`, the bounds are reversed, or the interval is empty.
79
+ */
80
+ constructor(start: AssumptionValue, end: AssumptionValue, startInclusive?: boolean, endInclusive?: boolean);
81
+ /**
82
+ * Creates an interval extending upward from `x`.
83
+ *
84
+ * @param x - Lower endpoint.
85
+ * @param inclusive - Whether a finite lower endpoint belongs to the interval.
86
+ * @returns The interval `[x, +∞)` when inclusive, otherwise `(x, +∞)`.
87
+ */
88
+ static atLeast(x: AssumptionValue, inclusive?: boolean): Assumption;
89
+ /**
90
+ * Creates an interval extending downward from `x`.
91
+ *
92
+ * @param x - Upper endpoint.
93
+ * @param inclusive - Whether a finite upper endpoint belongs to the interval.
94
+ * @returns The interval `(-∞, x]` when inclusive, otherwise `(-∞, x)`.
95
+ */
96
+ static atMost(x: AssumptionValue, inclusive?: boolean): Assumption;
97
+ /**
98
+ * Creates the singleton interval containing exactly `x`.
99
+ *
100
+ * @param x - The one admissible value.
101
+ * @returns The closed singleton interval `[x, x]`.
102
+ */
103
+ static exactly(x: AssumptionValue): Assumption;
104
+ static isAssumption(obj: unknown): obj is Assumption;
105
+ /**
106
+ * Parses one numeric interval constraint such as `x >= 0` or `n < 10`.
107
+ *
108
+ * @remarks
109
+ * Whitespace is ignored. Variable names use the ASCII identifier form
110
+ * `[A-Za-z_][A-Za-z0-9_]*`. Supported operators are `=`, `==`, `>`, `>=`, `<`,
111
+ * and `<=`. Bounds are Decimal-compatible numeric literals; `inf`, `infinity`,
112
+ * `+inf`, `+infinity`, `-inf`, and `-infinity` are also accepted.
113
+ *
114
+ * Expressions such as `x > y`, `x = 1/2`, and property predicates such as
115
+ * `integer(x)` are outside the string assumption grammar. Parser assertive calls may
116
+ * still provide already-evaluated Rational bounds directly.
117
+ *
118
+ * @param expr - Constraint to parse.
119
+ * @returns The parsed symbol and its interval assumption.
120
+ * @throws Error
121
+ * Thrown when the constraint has an invalid identifier, operator, or numeric bound.
122
+ */
123
+ static parse(expr: string): ParsedAssumption;
124
+ /**
125
+ * Tests whether a numeric value belongs to this interval.
126
+ *
127
+ * @param x - Numeric value to test.
128
+ * @returns `true` when `x` satisfies both interval bounds.
129
+ */
130
+ contains(x: AssumptionValue): boolean;
131
+ /**
132
+ * Determines whether values constrained by this interval are equal to `x`.
133
+ *
134
+ * @remarks
135
+ * Equality is proved only when both sides identify the same single value. It is
136
+ * disproved when the admissible values are disjoint. Overlapping ranges, including
137
+ * identical non-singleton ranges, return `undefined` because equality depends on the
138
+ * actual values chosen from those ranges.
139
+ *
140
+ * @param x - Another interval-constrained value or a numeric expression.
141
+ * @returns `true` when equality is forced, `false` when inequality is forced, or
142
+ * `undefined` when the available information permits either outcome.
143
+ */
144
+ eq(x: Assumption | Expression): AssumptionComparison;
145
+ /**
146
+ * Returns the exact value represented by a singleton interval.
147
+ *
148
+ * @returns A numeric Expression when this interval is a singleton, otherwise
149
+ * `undefined`.
150
+ */
151
+ getSingletonValue(): Expression | undefined;
152
+ /**
153
+ * Determines whether every value in this interval is strictly greater than `x`.
154
+ *
155
+ * @param x - Another interval-constrained value or a numeric expression.
156
+ * @returns `true` when `>` is forced, `false` when `<=` is forced, or `undefined`
157
+ * when the interval information permits both outcomes.
158
+ */
159
+ gt(x: Assumption | Expression): AssumptionComparison;
160
+ /**
161
+ * Determines whether every value in this interval is greater than or equal to `x`.
162
+ *
163
+ * @param x - Another interval-constrained value or a numeric expression.
164
+ * @returns `true` when `>=` is forced, `false` when `<` is forced, or `undefined`
165
+ * when the interval information permits both outcomes.
166
+ */
167
+ gte(x: Assumption | Expression): AssumptionComparison;
168
+ /**
169
+ * Intersects this interval with another interval.
170
+ *
171
+ * Endpoint selection uses the exact finite representation retained by each interval,
172
+ * so repeated constraints do not lose rational precision while narrowing the range.
173
+ *
174
+ * @param x - Interval to intersect with this one.
175
+ * @returns The non-empty intersection, or `undefined` when the intervals are disjoint.
176
+ */
177
+ intersect(x: Assumption): Assumption | undefined;
178
+ /**
179
+ * Determines whether every value in this interval is strictly less than `x`.
180
+ *
181
+ * @param x - Another interval-constrained value or a numeric expression.
182
+ * @returns `true` when `<` is forced, `false` when `>=` is forced, or `undefined`
183
+ * when the interval information permits both outcomes.
184
+ */
185
+ lt(x: Assumption | Expression): AssumptionComparison;
186
+ /**
187
+ * Determines whether every value in this interval is less than or equal to `x`.
188
+ *
189
+ * @param x - Another interval-constrained value or a numeric expression.
190
+ * @returns `true` when `<=` is forced, `false` when `>` is forced, or `undefined`
191
+ * when the interval information permits both outcomes.
192
+ */
193
+ lte(x: Assumption | Expression): AssumptionComparison;
194
+ /**
195
+ * Tests whether this interval and `x` share at least one admissible value.
196
+ *
197
+ * @param x - Interval to test for overlap.
198
+ * @returns `true` when the intersection is non-empty.
199
+ */
200
+ overlaps(x: Assumption): boolean;
201
+ /**
202
+ * Tests whether two objects describe the same interval constraint.
203
+ *
204
+ * @remarks
205
+ * This is structural interval equality and is separate from {@link eq}: two different
206
+ * variables may have identical intervals without being known to have the same value.
207
+ *
208
+ * @param x - Interval constraint to compare with this one.
209
+ * @returns `true` when both endpoints and their inclusivity are identical.
210
+ */
211
+ sameInterval(x: Assumption): boolean;
212
+ /**
213
+ * Formats the interval using mathematical bracket notation.
214
+ *
215
+ * @returns A representation such as `[0, 10)` or `(-Infinity, Infinity)`.
216
+ */
217
+ toString(): string;
218
+ }