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,1674 @@
1
+ import Decimal from 'decimal.js';
2
+ import { Rational } from '../rational/Rational';
3
+ import type { Base } from '../../common/common';
4
+ import type { ParserEntity, ExpressionInput, NerdamerInput } from '../../types';
5
+ import type { ParserValuesObject, TextOptions } from '../parser/types';
6
+ export type ElementsSortType = (a: Expression, b: Expression) => number;
7
+ /**
8
+ * Represents a symbolic expression in Nerdamer's canonical expression tree.
9
+ *
10
+ * @remarks
11
+ * `Expression` is the central symbolic value type used by the parser and by the
12
+ * algebra, calculus, and solver layers. Parsed expressions are normalized into a
13
+ * small set of internal node categories such as numbers, variables, functions,
14
+ * powers, products, and sums. Numeric coefficients are normally stored in a
15
+ * {@link Rational} multiplier rather than as separate product elements.
16
+ *
17
+ * Most arithmetic and transformation methods return a new `Expression`, but the
18
+ * class itself is mutable because parser and algorithm internals rebuild nodes in
19
+ * place. Accessors such as {@link Expression.getArguments},
20
+ * {@link Expression.getMultiplier}, and {@link Expression.getPower} may lazily
21
+ * initialize and return internal objects. Use {@link Expression.copy} when an
22
+ * independently mutable expression tree is required.
23
+ *
24
+ * {@link Expression.create} is the preferred construction API. In particular,
25
+ * `Expression.create(existingExpression)` preserves object identity unless its
26
+ * `copy` argument is set to `true`.
27
+ *
28
+ * The internal expression groups are organizational categories used by Nerdamer's
29
+ * canonicalization logic. They should not be confused with general mathematical
30
+ * classifications:
31
+ *
32
+ * - `NUM` stores plain numeric values.
33
+ * - `VAR` stores symbols/variables whose powers fit the variable representation.
34
+ * - `EXP` stores bases with powers that require a separate exponential node; it is
35
+ * not the same thing as an exponential function.
36
+ * - `FUN` stores function calls.
37
+ * - `GRP` stores sums with a common base but differing powers, such as
38
+ * `x + x^y` or `cos(x) - 3*cos(x)^2`.
39
+ * - `PRD` stores products of non-numeric symbolic factors; numeric coefficients are
40
+ * moved to the outer multiplier during parsing.
41
+ * - `SUM` stores other sums. For example, `1 + x + x^2` is a `SUM` containing a
42
+ * numeric term and a grouped polynomial-like component.
43
+ * - `INF` stores infinite values.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const expression = Expression.create('2*x + 1');
48
+ *
49
+ * expression.text(); // "1+2*x"
50
+ * expression.evaluate({ x: 3 }).text(); // "7"
51
+ * ```
52
+ */
53
+ export declare class Expression implements Base<Expression> {
54
+ /**
55
+ * Controls whether addition first distributes an outer multiplier on a sum.
56
+ *
57
+ * @remarks
58
+ * This is a process-wide parser/algebra setting used by the addition operation.
59
+ * Changing it affects subsequent symbolic operations globally.
60
+ */
61
+ static DISTRIBUTE_MULTIPLIER: boolean;
62
+ /**
63
+ * The symbol currently reserved for the imaginary unit.
64
+ *
65
+ * Use {@link Parser.setI} to change the symbol so the parser's restricted-name
66
+ * bookkeeping is updated at the same time.
67
+ */
68
+ static imaginary: string;
69
+ /** Names used by the internal logarithm representation and converters. */
70
+ static LOG: string;
71
+ static LOG10: string;
72
+ /**
73
+ * Placeholder key used when numeric terms are grouped inside expression containers.
74
+ *
75
+ * This is part of the internal canonical-key representation rather than the
76
+ * rendered mathematical value of a number.
77
+ */
78
+ static numberHash: string;
79
+ /** Power operator used by expression text formatting. */
80
+ static POW_OPR: string;
81
+ /**
82
+ * Symbols excluded from ordinary variable collection.
83
+ *
84
+ * @remarks
85
+ * This list differs from the parser's restricted-name list.
86
+ * It is used by expression traversal when deciding which `VAR` nodes should be
87
+ * reported as free variables. The distinction is historical and should not be
88
+ * interpreted as a general parser-reservation policy.
89
+ */
90
+ static RESERVED: string[];
91
+ /**
92
+ * Comparator used when expression elements are emitted in canonical display order.
93
+ *
94
+ * @remarks
95
+ * The ordering is representational, not a mathematical ordering relation. It keeps
96
+ * the imaginary unit last, orders like node types by value and descending power,
97
+ * and otherwise falls back to the internal expression-type order. Replacing this
98
+ * function changes ordering globally for subsequent formatting and reconstruction.
99
+ */
100
+ static sortFunction: ElementsSortType;
101
+ /** Internal expression-type constants used by parser and algebra code. */
102
+ static TYPES: {
103
+ NUM: number;
104
+ VAR: number;
105
+ EXP: number;
106
+ FUN: number;
107
+ GRP: number;
108
+ PRD: number;
109
+ SUM: number;
110
+ INF: number;
111
+ VEC: number;
112
+ MAT: number;
113
+ };
114
+ /**
115
+ * Arguments stored by a function node.
116
+ *
117
+ * Prefer {@link Expression.getArguments} when consuming this representation.
118
+ */
119
+ args?: Expression[];
120
+ /**
121
+ * Explicit mathematical base stored by an `EXP` node.
122
+ *
123
+ * Non-`EXP` nodes derive their base through {@link Expression.getBase} instead.
124
+ */
125
+ base?: Expression;
126
+ /** Parser entity discriminator for expression values. */
127
+ dataType: string;
128
+ /**
129
+ * Signals that the Expression was parsed with the deferred flag true
130
+ */
131
+ deferred: boolean;
132
+ /**
133
+ * Canonically keyed child expressions for aggregate nodes such as sums and products.
134
+ *
135
+ * @remarks
136
+ * The record is mutable representation state. {@link Expression.getElements}
137
+ * returns this object directly when it exists; callers that mutate it are
138
+ * responsible for preserving a valid expression representation and regenerating derived values.
139
+ */
140
+ elements?: Record<string, Expression>;
141
+ /**
142
+ * Let's the parser know not to treat it as a set of values
143
+ */
144
+ isEnumerable: boolean;
145
+ /**
146
+ * Outer rational coefficient carried by this node when explicitly initialized.
147
+ *
148
+ * Use {@link Expression.getMultiplier} to obtain the effective multiplier.
149
+ */
150
+ multiplier?: Rational;
151
+ /**
152
+ * The function name if any
153
+ */
154
+ name?: string;
155
+ /**
156
+ * Outer power carried by this node when explicitly initialized.
157
+ *
158
+ * Use {@link Expression.getPower} to obtain the effective power.
159
+ */
160
+ power?: Expression;
161
+ /**
162
+ * If set, this is the maximum known precision of any of the intermediate operations
163
+ */
164
+ precision?: number;
165
+ /**
166
+ * The default type is a number for the expression since the default value
167
+ * for an expression is "1". The assert flag is used because TypeScript
168
+ * currently doesn't recognized that it's also set in the copyOver method
169
+ */
170
+ type: number;
171
+ /**
172
+ * The value of the expression. This hash is used for comparing variable.
173
+ * This value is set in the constructor or the copyOver method
174
+ */
175
+ value: string;
176
+ /**
177
+ * Constructs or copies an expression value.
178
+ *
179
+ * @remarks
180
+ * Direct construction is primarily a representation-level API. When `x` is an
181
+ * existing `Expression`, the constructor deep-copies its expression tree. When
182
+ * `plainConstruct` is `true` and `x` is a string, that string is stored as the
183
+ * raw node value without parsing. Other inputs are delegated to
184
+ * {@link Expression.create}, and JavaScript constructor return semantics therefore
185
+ * allow that factory-created expression to become the result of `new Expression(...)`.
186
+ *
187
+ * For ordinary user input, prefer {@link Expression.create}; it makes parsing and
188
+ * identity behavior explicit.
189
+ *
190
+ * @param x - The expression or Nerdamer input used to construct the value.
191
+ * @param plainConstruct - Store a string as a raw internal value instead of parsing it.
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * const expression = Expression.create('x + 1');
196
+ * const copy = new Expression(expression);
197
+ *
198
+ * copy === expression; // false
199
+ * copy.text(); // "1+x"
200
+ * ```
201
+ */
202
+ constructor(x: NerdamerInput, plainConstruct?: boolean);
203
+ /**
204
+ * Converts supported Nerdamer input into an `Expression`.
205
+ *
206
+ * @remarks
207
+ * Strings and primitive numeric inputs are parsed through {@link Parser}. An
208
+ * existing `Expression` is returned unchanged when no substitution `values` are
209
+ * supplied; pass `copy: true` to request an independent deep copy. A
210
+ * {@link Rational} is converted to a numeric expression while preserving its
211
+ * decimal-origin marker.
212
+ *
213
+ * An {@link Equation} is converted to its residual expression by moving the right
214
+ * side to the left on a copy of the equation. For example, `x = 2` becomes the
215
+ * expression `x - 2` in canonical form.
216
+ *
217
+ * @param x - The expression-compatible input to convert.
218
+ * @param values - Parser substitutions applied while parsing non-`Expression` input.
219
+ * @param copy - Copy an existing `Expression` instead of preserving its identity.
220
+ * @returns The parsed, converted, reused, or copied expression.
221
+ * @throws {@link core!UnexpectedDataType}
222
+ * Thrown when parsing produces another parser entity, such as a vector or matrix,
223
+ * where an `Expression` is required.
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * const expression = Expression.create('x^2 + 1');
228
+ *
229
+ * Expression.create(expression) === expression; // true
230
+ * Expression.create(expression, undefined, true) === expression; // false
231
+ * Expression.create('a+b', { a: 2, b: 3 }).text(); // "5"
232
+ * ```
233
+ */
234
+ static create(x: NerdamerInput, values?: ParserValuesObject, copy?: boolean): Expression;
235
+ /**
236
+ * Creates Euler's constant as a symbolic or evaluated expression.
237
+ *
238
+ * @param asNumericValue - Force the evaluated representation even when parser
239
+ * evaluation mode is disabled.
240
+ * @returns Symbolic `e`, or its current numeric representation when evaluation is enabled.
241
+ *
242
+ * @example
243
+ * ```ts
244
+ * Expression.E().text(); // "e"
245
+ * Expression.E(true).text(); // numeric approximation
246
+ * ```
247
+ */
248
+ static E(asNumericValue?: boolean): Expression;
249
+ /**
250
+ * Converts a rational value into a numeric expression.
251
+ *
252
+ * The conversion preserves the rational's `asDecimal` provenance flag so later
253
+ * formatting and decimal-contagion logic can distinguish decimal-origin values.
254
+ *
255
+ * @param x - Rational value to convert.
256
+ * @returns A new numeric expression with an independent multiplier.
257
+ *
258
+ * @example
259
+ * ```ts
260
+ * const rational = Rational.create('3/4');
261
+ * Expression.fromRational(rational).text(); // "3/4"
262
+ * ```
263
+ */
264
+ static fromRational(x: Rational): Expression;
265
+ /**
266
+ * Converts a structured entity carrying symbolic bracket access into the scalar
267
+ * Expression form used by ordinary algebra and function nodes.
268
+ *
269
+ * Structured entities without symbolic access are left unchanged by returning
270
+ * `undefined`; callers can then apply their normal conversion rules.
271
+ */
272
+ static fromSymbolicAccess(x: NerdamerInput): Expression | undefined;
273
+ /**
274
+ * Creates a symbolic function node with the given name.
275
+ *
276
+ * This creates a bare function symbol without arguments. To create a function
277
+ * with arguments, use {@link Expression.toFunction} instead.
278
+ *
279
+ * @param x - The function name.
280
+ * @returns A function-typed Expression.
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * Expression.Function('f').text() // "f"
285
+ * ```
286
+ */
287
+ static Function(x: string): Expression;
288
+ /**
289
+ * Generates a canonical string representation for an array of sub-expressions,
290
+ * joined by `+` (for SUM/GRP) or `*` (for PRD), with sums wrapped in parentheses
291
+ * when inside a product.
292
+ *
293
+ * @param arr - The array of sub-expressions.
294
+ * @param f - The string method to call on each element: `'idString'`, `'keyValue'`, or `'text'`.
295
+ * @param expressionType - The parent expression type (SUM, GRP, or PRD).
296
+ * @returns The joined string representation.
297
+ */
298
+ static getValue(arr: Expression[], f: 'idString' | 'keyValue' | 'text', expressionType: number): string;
299
+ /**
300
+ * Intercepts values passed through the `Expression` constructor.
301
+ *
302
+ * @remarks
303
+ * The default implementation is the identity function. Applications may replace
304
+ * this static hook, but doing so changes direct-construction behavior globally.
305
+ * {@link Expression.create} does not route every parsed input through this hook.
306
+ *
307
+ * @param x - Raw constructor input.
308
+ * @returns The value the constructor should continue processing.
309
+ */
310
+ static hook(x: NerdamerInput): NerdamerInput;
311
+ /**
312
+ * Creates the variable node representing the current imaginary-unit symbol.
313
+ *
314
+ * @returns A new variable expression using {@link Expression.imaginary}.
315
+ *
316
+ * @example
317
+ * ```ts
318
+ * Expression.Img().text(); // "i" with the default parser configuration
319
+ * ```
320
+ *
321
+ * @see {@link Parser.setI}
322
+ */
323
+ static Img(): Expression;
324
+ /**
325
+ * Creates a symbolic positive infinity Expression.
326
+ *
327
+ * @returns An Expression representing `+∞`.
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * Expression.Inf().text() // "Infinity"
332
+ * ```
333
+ */
334
+ static Inf(): Expression;
335
+ /**
336
+ * Type guard that checks whether an object is an Expression.
337
+ *
338
+ * @param obj - The value to test.
339
+ * @returns `true` if `obj` is an Expression instance.
340
+ *
341
+ * @example
342
+ * ```ts
343
+ * Expression.isExpression(Expression.create('x')) // true
344
+ * Expression.isExpression(42) // false
345
+ * ```
346
+ */
347
+ static isExpression(obj: unknown): obj is Expression;
348
+ /**
349
+ * Type guard that checks whether every element of an array is an Expression.
350
+ *
351
+ * @param obj - The value to test.
352
+ * @returns `true` if `obj` is an array and all elements are Expressions.
353
+ */
354
+ static isExpressionArray(obj: unknown): obj is Expression[];
355
+ /**
356
+ * Creates the internal summation/product index placeholder variable `_n`.
357
+ *
358
+ * @returns An Expression representing the variable `_n`.
359
+ */
360
+ static N(): Expression;
361
+ /**
362
+ * Creates a symbolic negative infinity Expression.
363
+ *
364
+ * @returns An Expression representing `−∞`.
365
+ *
366
+ * @example
367
+ * ```ts
368
+ * Expression.NegInf().text() // "-Infinity"
369
+ * ```
370
+ */
371
+ static NegInf(): Expression;
372
+ /**
373
+ * Creates a numeric (`NUM`) expression node from a numeric representation.
374
+ *
375
+ * @remarks
376
+ * This is a low-level constructor for numeric expression nodes. The supplied value
377
+ * is stored as text and is interpreted as a {@link Rational} when the multiplier is
378
+ * first requested. Use {@link Expression.create} when the input should be parsed as
379
+ * a general mathematical expression.
380
+ *
381
+ * @param x - Numeric representation to store.
382
+ * @returns A new numeric expression.
383
+ *
384
+ * @example
385
+ * ```ts
386
+ * Expression.Number('42').text(); // "42"
387
+ * Expression.Number('3/4').text(); // "3/4"
388
+ * ```
389
+ */
390
+ static Number(x: string | bigint | number | Decimal): Expression;
391
+ /**
392
+ * Creates π as a symbolic or evaluated expression.
393
+ *
394
+ * @param asNumericValue - Force the evaluated representation even when parser
395
+ * evaluation mode is disabled.
396
+ * @returns Symbolic `pi`, or its current numeric representation when evaluation is enabled.
397
+ *
398
+ * @example
399
+ * ```ts
400
+ * Expression.Pi().text(); // "pi"
401
+ * Expression.Pi(true).text(); // numeric approximation
402
+ * ```
403
+ */
404
+ static Pi(asNumericValue?: boolean): Expression;
405
+ /**
406
+ * Sets the power of an Expression. Use this instead of assigning `power` directly.
407
+ *
408
+ * @param x - The Expression whose power to set.
409
+ * @param power - The new power Expression.
410
+ * @returns The modified Expression `x`.
411
+ */
412
+ static setPower(x: Expression, power: Expression): Expression;
413
+ /**
414
+ * Creates multiple Expressions at once from a list of inputs.
415
+ *
416
+ * @param values - One or more inputs to convert to Expressions.
417
+ * @returns An array of Expressions.
418
+ *
419
+ * @example
420
+ * ```ts
421
+ * const [x, y] = Expression.symbols('x', 'y');
422
+ * x.text() // "x"
423
+ * y.text() // "y"
424
+ * ```
425
+ */
426
+ static symbols(...values: ExpressionInput[]): Expression[];
427
+ /**
428
+ * Creates the internal scalar Expression used to represent symbolic bracket access.
429
+ * The formatter renders this as ordinary bracket notation rather than exposing the
430
+ * internal function name.
431
+ */
432
+ static toAccessor(target: Expression, indices: Expression[]): Expression;
433
+ /**
434
+ * Constructs an `EXP` node without applying the normal power simplification rules.
435
+ *
436
+ * @remarks
437
+ * This is an internal representation helper for bases whose exponent must be stored
438
+ * separately. When `powerLess` is `true`, the existing outer power is deleted from
439
+ * the converted base before it is wrapped. Because {@link Expression.create} may
440
+ * reuse an input `Expression`, callers must not use that option when the original
441
+ * object must remain unchanged.
442
+ *
443
+ * @param x - Base to store in the `EXP` node.
444
+ * @param pow - Exponent to store on the node.
445
+ * @param powerLess - Remove an existing outer power from the base before wrapping it.
446
+ * @returns The constructed power expression, or the base itself when the base is one.
447
+ */
448
+ static toEXP(x: ExpressionInput, pow: ExpressionInput, powerLess?: boolean): Expression;
449
+ /**
450
+ * Constructs a function node and assigns its arguments.
451
+ *
452
+ * `undefined` entries are omitted. Existing `Expression` arguments may be retained
453
+ * by identity because conversion uses {@link Expression.create} without requesting
454
+ * copies. A Vector or Matrix carrying symbolic bracket access is first normalized
455
+ * to its scalar accessor Expression; ordinary structured values remain invalid
456
+ * function arguments where an Expression is required.
457
+ *
458
+ * @param name - Function name stored on the node.
459
+ * @param args - Function arguments; `undefined` entries are ignored.
460
+ * @returns The reconstructed function expression.
461
+ */
462
+ static toFunction(name: string, args: (NerdamerInput | undefined)[]): Expression;
463
+ /**
464
+ * Low-level helper that creates an Expression with a specific internal type.
465
+ *
466
+ * @param x - The value string.
467
+ * @param type - The Expression type constant (NUM, VAR, FUN, EXP, etc.).
468
+ * @returns A new Expression of the specified type.
469
+ */
470
+ static Type(x: string, type: number): Expression;
471
+ /**
472
+ * Creates a symbolic variable Expression.
473
+ *
474
+ * @param x - The variable name.
475
+ * @returns A `VAR`-typed Expression.
476
+ *
477
+ * @example
478
+ * ```ts
479
+ * Expression.Variable('x').text() // "x"
480
+ * ```
481
+ */
482
+ static Variable(x: string): Expression;
483
+ /**
484
+ * Returns the symbolic absolute value of this expression.
485
+ *
486
+ * The operation delegates to Nerdamer's `abs` implementation and may simplify
487
+ * values whose sign or complex magnitude can be determined.
488
+ *
489
+ * @returns The resulting expression; the receiver is not modified.
490
+ *
491
+ * @example
492
+ * ```ts
493
+ * Expression.create(-5).abs().text(); // "5"
494
+ * Expression.create('x').abs().text(); // "abs(x)"
495
+ * ```
496
+ */
497
+ abs(): Expression;
498
+ /**
499
+ * Legacy alias for {@link plus}.
500
+ *
501
+ * @param x - The value to add.
502
+ * @returns A new Expression representing `this + x`.
503
+ */
504
+ add(x: ExpressionInput): Expression;
505
+ /**
506
+ * Compiles this expression into a native JavaScript numeric function.
507
+ *
508
+ * @remarks
509
+ * The generated function uses JavaScript `number` arithmetic and the registered
510
+ * numerical implementations. It is intended for repeated, relatively low-precision
511
+ * scalar evaluation rather than arbitrary-precision symbolic computation. Functions
512
+ * without a faithful JavaScript-number equivalent are rejected instead of being
513
+ * compiled with approximate or unrelated semantics.
514
+ *
515
+ * When `args` is omitted, free variables are collected and sorted alphabetically.
516
+ * Supplying `args` defines the positional argument order explicitly.
517
+ *
518
+ * @param args - Variable names in the positional order expected by the compiled function.
519
+ * @returns A JavaScript function accepting numeric arguments and returning a number.
520
+ * @throws {@link core!UnsupportedOperationError} If a surviving function has no faithful
521
+ * JavaScript-number implementation.
522
+ *
523
+ * @example
524
+ * ```ts
525
+ * const fn = Expression.create('x^2 + y').buildFunction(['x', 'y']);
526
+ * fn(3, 1); // 10
527
+ * ```
528
+ */
529
+ buildFunction(args?: string[]): (...args: number[]) => number;
530
+ /**
531
+ * Collects coefficients with respect to one or more requested variables.
532
+ *
533
+ * @remarks
534
+ * The expression is expanded as part of coefficient collection. For multivariate
535
+ * input, coefficient keys encode the exponent tuple in the same order as
536
+ * `variables`. Terms that do not contain a requested variable are retained as
537
+ * coefficients rather than discarded.
538
+ *
539
+ * @param variables - Variables whose powers define the coefficient keys.
540
+ * @returns Nerdamer's coefficient object for the requested variable ordering.
541
+ *
542
+ * @example
543
+ * ```ts
544
+ * const coefficients = Expression.create('3*x^2 + 2*x + 1').coeffs('x');
545
+ * coefficients.toArray().map(value => value.text()); // ["1", "2", "3"]
546
+ * ```
547
+ */
548
+ coeffs(...variables: string[]): import("./CoeffObject").CoeffObject;
549
+ /**
550
+ * Deep-copies the expression tree.
551
+ *
552
+ * @remarks
553
+ * Multipliers, powers, function arguments, explicit exponential bases, and aggregate
554
+ * elements are recursively copied. Mutating those structures on the returned
555
+ * expression therefore does not mutate the corresponding structures on the source.
556
+ *
557
+ * @returns An independently mutable expression with the same symbolic representation.
558
+ *
559
+ * @example
560
+ * ```ts
561
+ * const source = Expression.create('x + 1');
562
+ * const copy = source.copy();
563
+ *
564
+ * copy === source; // false
565
+ * copy.text(); // "1+x"
566
+ * ```
567
+ */
568
+ copy(): Expression;
569
+ /**
570
+ * Legacy alias for {@link getDenominator}.
571
+ *
572
+ * @returns The denominator Expression.
573
+ */
574
+ denominator(): Expression;
575
+ /**
576
+ * Distributes this node's outer multiplier through a linear sum.
577
+ *
578
+ * @remarks
579
+ * A copy is created before any changes are made. Distribution is performed only
580
+ * when the expression is sum-like, has power one, and carries a non-unit outer
581
+ * multiplier. Nested sum terms encountered during the pass are handled recursively.
582
+ * Expressions that do not meet those conditions are returned as equivalent copies.
583
+ *
584
+ * @returns A new expression with the eligible multiplier distributed.
585
+ *
586
+ * @example
587
+ * ```ts
588
+ * Expression.create('2*(x+y)').distributeMultiplier().text(); // "2*x+2*y"
589
+ * ```
590
+ */
591
+ distributeMultiplier(): Expression;
592
+ /**
593
+ * Divides this Expression by the given value.
594
+ *
595
+ * @param x - The divisor.
596
+ * @returns A new Expression representing `this / x`.
597
+ *
598
+ * @example
599
+ * ```ts
600
+ * Expression.create('x^2').div('x').text() // "x"
601
+ * Expression.create(10).div(3).text() // "10/3"
602
+ * ```
603
+ */
604
+ div(x: ExpressionInput): Expression;
605
+ /**
606
+ * Legacy alias for {@link div}.
607
+ *
608
+ * @param x - The divisor.
609
+ * @returns A new Expression representing `this / x`.
610
+ */
611
+ divide(x: ExpressionInput): Expression;
612
+ /**
613
+ * Visits the immediate terms represented by this expression.
614
+ *
615
+ * @remarks
616
+ * Aggregate nodes pass each stored element and its key to `fn`. Atomic nodes invoke
617
+ * the callback once with a unit-multiplier form of the expression and the node's
618
+ * value as the key. The callback's return value is ignored; this method does not
619
+ * rebuild the expression. Use {@link Expression.forEveryElement} when returned
620
+ * replacements should participate in reconstruction.
621
+ *
622
+ * For atomic nodes, creating the unit-multiplier argument does not mutate the receiver.
623
+ * Aggregate elements, however, are passed by reference, so the callback can mutate
624
+ * their internal objects if it chooses to do so.
625
+ *
626
+ * @param fn - Visitor receiving an immediate expression element and its key.
627
+ * @returns This expression for chaining.
628
+ */
629
+ each(fn: (a: Expression, b: string | number) => void | Expression): this;
630
+ /**
631
+ * Returns the immediate expression elements in canonical sort order.
632
+ *
633
+ * @remarks
634
+ * Sum-like nodes flatten nested linear sums one level while products retain nested
635
+ * sums. Atomic nodes contribute a unit-multiplier copy. When `withMultiplier` is
636
+ * `true`, a product's outer multiplier is appended as a numeric expression before
637
+ * sorting. The option has no effect on sums.
638
+ *
639
+ * Stored aggregate elements are returned by reference rather than deep-copied.
640
+ *
641
+ * @param withMultiplier - Include a product's outer coefficient as an array element.
642
+ * @returns The sorted immediate elements.
643
+ */
644
+ elementsArray(withMultiplier?: boolean): Expression[];
645
+ /**
646
+ * Tests whether this expression is symbolically equal to another value.
647
+ *
648
+ * @remarks
649
+ * Equality is not a JavaScript identity or raw-tree comparison. Nerdamer first
650
+ * consults applicable assumptions and otherwise subtracts the expressions,
651
+ * canonicalizes numeric radicals where needed, expands the difference, and accepts
652
+ * equality when that result reduces to numeric zero. A `false` result therefore
653
+ * means equality was not established by the current comparison machinery; it is
654
+ * not a general theorem-prover result for arbitrary symbolic identities.
655
+ *
656
+ * @param x - Value to compare with this expression.
657
+ * @returns `true` when Nerdamer establishes equality, otherwise `false`.
658
+ *
659
+ * @example
660
+ * ```ts
661
+ * Expression.create('x+1').eq('1+x'); // true
662
+ * Expression.create(3).eq(4); // false
663
+ * ```
664
+ */
665
+ eq(x: ParserEntity | ExpressionInput): boolean;
666
+ /**
667
+ * Re-evaluates this expression numerically, optionally substituting variable values.
668
+ *
669
+ * @remarks
670
+ * Evaluation serializes the current expression and sends it through
671
+ * {@link Parser.evaluate}. That parser path enables Nerdamer's evaluation mode, so
672
+ * numeric constants and supported numeric functions are evaluated according to the
673
+ * parser's current precision and settings. The original expression is not modified.
674
+ *
675
+ * @param values - Variable substitutions applied during evaluation.
676
+ * @returns The evaluated expression.
677
+ *
678
+ * @example
679
+ * ```ts
680
+ * Expression.create('x^2 + 1').evaluate({ x: 3 }).text(); // "10"
681
+ * Expression.create('pi/2').evaluate().text(); // numeric approximation
682
+ * ```
683
+ */
684
+ evaluate(values?: ParserValuesObject): Expression;
685
+ /**
686
+ * Expands products and eligible powers into an equivalent symbolic expression.
687
+ *
688
+ * @remarks
689
+ * Expansion delegates to Nerdamer's canonical expansion algorithm. The result is
690
+ * independent of the receiver, but callers should treat object identity as an
691
+ * implementation detail rather than relying on expansion to allocate a particular
692
+ * representation. Branch-sensitive power rules are preserved rather than treating
693
+ * every algebraic power identity as universally valid over the complex domain.
694
+ *
695
+ * @returns The expanded expression.
696
+ *
697
+ * @example
698
+ * ```ts
699
+ * Expression.create('(x+1)^2').expand().text(); // "1+2*x+x^2"
700
+ * ```
701
+ */
702
+ expand(): Expression;
703
+ /**
704
+ * Applies a transformation while recursively rebuilding this expression.
705
+ *
706
+ * @remarks
707
+ * Unlike {@link Expression.each}, callback results are used as replacements. The
708
+ * traversal reconstructs functions, products, sums, and exponential powers while
709
+ * restoring the original outer multiplier and power. Numeric and variable roots are
710
+ * returned unchanged by the traversal helper rather than passed through `fn`, so the
711
+ * result may preserve the receiver's identity for those atomic cases.
712
+ *
713
+ * @param fn - Transformation applied to traversed symbolic components.
714
+ * @returns The rebuilt expression.
715
+ */
716
+ forEveryElement(fn: (x: Expression) => Expression): Expression;
717
+ /**
718
+ * Collects distinct function occurrences from the expression tree.
719
+ *
720
+ * @remarks
721
+ * By default the returned strings are function names such as `sin` and `cos`.
722
+ * When `getValues` is `true`, the collector instead returns each function node's
723
+ * stored value string, such as `sin(x)`, while still deduplicating repeated values.
724
+ * Traversal includes function arguments, aggregate elements, and `EXP` bases and
725
+ * powers.
726
+ *
727
+ * If `fns` is supplied, results are appended to that same array.
728
+ *
729
+ * @param fns - Optional accumulator that receives unique strings.
730
+ * @param getValues - Collect stored function-expression strings instead of names.
731
+ * @returns The accumulator containing the collected function strings.
732
+ *
733
+ * @example
734
+ * ```ts
735
+ * Expression.create('sin(x) + cos(y)').functions(); // ["sin", "cos"]
736
+ * ```
737
+ */
738
+ functions(fns?: string[], getValues?: boolean): string[];
739
+ /**
740
+ * Returns the mutable argument array stored by this function node.
741
+ *
742
+ * @remarks
743
+ * The array is lazily created when no arguments are present and is returned by
744
+ * reference, not copied. Mutating the returned array therefore mutates this
745
+ * expression. Call {@link Expression.updateValue} after structural changes when
746
+ * the stored `value` string must be regenerated.
747
+ *
748
+ * @returns The internal function-argument array.
749
+ *
750
+ * @example
751
+ * ```ts
752
+ * Expression.create('sin(x)').getArguments()[0].text(); // "x"
753
+ * ```
754
+ */
755
+ getArguments(): Expression[];
756
+ /**
757
+ * Returns the mathematical base represented by this node.
758
+ *
759
+ * @remarks
760
+ * `EXP` nodes return their stored base directly because signs and coefficients that
761
+ * belong inside an exponential base must remain part of that base. Other node types
762
+ * derive the same base from a deep structural copy with the outer multiplier and
763
+ * outer power removed.
764
+ *
765
+ * The `EXP` branch returns the internal base by reference. The non-`EXP` branch
766
+ * returns an independent expression and does not re-enter the parser.
767
+ *
768
+ * @returns The stored or derived base expression.
769
+ *
770
+ * @example
771
+ * ```ts
772
+ * Expression.create('3*x^2').getBase().text(); // "x"
773
+ * Expression.create('2^(x+1)').getBase().text(); // "2"
774
+ * ```
775
+ */
776
+ getBase(): Expression;
777
+ /**
778
+ * Extracts the denominator represented by this expression's current structure.
779
+ *
780
+ * @remarks
781
+ * The operation collects the rational multiplier's denominator and factors carried
782
+ * by negative powers in a product. It does not first combine a sum over a common
783
+ * denominator. For example, `a/x + 8` is a sum whose outer denominator is one, while
784
+ * the individual term `a/x` has denominator `x`.
785
+ *
786
+ * @returns The denominator represented by the current expression structure.
787
+ *
788
+ * @example
789
+ * ```ts
790
+ * Expression.create('x/y').getDenominator().text() // "y"
791
+ * Expression.create('3/4').getDenominator().text() // "4"
792
+ * ```
793
+ */
794
+ getDenominator(): Expression;
795
+ /**
796
+ * Returns the mutable child-element record stored by an aggregate expression.
797
+ *
798
+ * @remarks
799
+ * When `elements` exists, the actual internal record is returned rather than a copy.
800
+ * Mutating it therefore mutates this expression and can invalidate canonical keys or
801
+ * the stored `value` string unless the caller restores the corresponding representation state. When this
802
+ * node has no element record, a new empty object is returned and is not attached to
803
+ * the expression.
804
+ *
805
+ * @returns The internal element record, or a detached empty record for atomic nodes.
806
+ */
807
+ getElements(): Record<string, Expression>;
808
+ /**
809
+ * Returns this node's effective outer rational multiplier.
810
+ *
811
+ * @remarks
812
+ * The multiplier is initialized lazily. Numeric nodes derive it from their stored
813
+ * value; other nodes default to one. Without `asExpression`, the returned
814
+ * {@link Rational} is the actual mutable multiplier owned by this expression, not a
815
+ * copy. Passing `true` wraps that rational value in a new numeric `Expression`.
816
+ *
817
+ * @param asExpression - Return the coefficient as a numeric expression instead of a rational.
818
+ * @returns The internal multiplier, or a numeric expression representing it.
819
+ *
820
+ * @example
821
+ * ```ts
822
+ * Expression.create('3*x').getMultiplier().text(); // "3"
823
+ * Expression.create('3*x').getMultiplier(true).text(); // "3"
824
+ * ```
825
+ */
826
+ getMultiplier(asExpression: true): Expression;
827
+ getMultiplier(asExpression: false): Rational;
828
+ getMultiplier(): Rational;
829
+ /**
830
+ * Extracts the numerator represented by this expression's current structure.
831
+ *
832
+ * @remarks
833
+ * The operation separates the numerator of the rational multiplier and recursively
834
+ * collects numerator factors from linear products. It does not first rewrite a sum
835
+ * over a common denominator; a sum such as `a/x + 8` therefore remains the numerator
836
+ * of that top-level representation.
837
+ *
838
+ * @returns The numerator represented by the current expression structure.
839
+ *
840
+ * @example
841
+ * ```ts
842
+ * Expression.create('x/y').getNumerator().text() // "x"
843
+ * Expression.create('3/4').getNumerator().text() // "3"
844
+ * ```
845
+ */
846
+ getNumerator(): Expression;
847
+ /**
848
+ * Returns this node's effective outer power.
849
+ *
850
+ * @remarks
851
+ * The power is initialized lazily and stored on the expression. Numeric (`NUM`)
852
+ * nodes default to power zero because their numeric value is carried by the
853
+ * multiplier; other node types default to power one. The returned `Expression` is
854
+ * the mutable internal power object, not a copy.
855
+ *
856
+ * @returns The internal power expression.
857
+ *
858
+ * @example
859
+ * ```ts
860
+ * Expression.create('x^3').getPower().text(); // "3"
861
+ * Expression.create('x').getPower().text(); // "1"
862
+ * ```
863
+ */
864
+ getPower(): Expression;
865
+ /**
866
+ * Retrieves a matching variable factor from this node.
867
+ *
868
+ * The method returns this expression when its stored value matches `variable`, or
869
+ * the matching immediate factor when this is a product. When no match is found it
870
+ * returns the numeric zero expression rather than `undefined`.
871
+ *
872
+ * @param variable - Stored variable value to locate.
873
+ * @returns The matching expression reference, or zero when no match exists.
874
+ */
875
+ getVariable(variable: string): Expression;
876
+ /**
877
+ * Tests whether this expression is `>` another value.
878
+ *
879
+ * @remarks
880
+ * Nerdamer consults applicable assumptions and otherwise evaluates the difference
881
+ * numerically/symbolically. These `Expression` comparison methods remain boolean for
882
+ * compatibility. An unknown assumption result falls through to the ordinary comparison
883
+ * path; if the relation still cannot be established, the method returns `false`. The
884
+ * lower-level `Assumption` relations preserve unknown as `undefined`. Complex values are
885
+ * not ordered and cause the comparison to throw.
886
+ *
887
+ * @param x - Value to compare with this expression.
888
+ * @returns `true` when the requested ordering is established, otherwise `false`.
889
+ * @throws {@link core!UnsupportedOperationError}
890
+ * Thrown when either side is classified as complex.
891
+ */
892
+ gt(x: ExpressionInput | ParserEntity): boolean;
893
+ /**
894
+ * Tests whether this expression is `>=` another value.
895
+ *
896
+ * @remarks
897
+ * Nerdamer consults applicable assumptions and otherwise evaluates the difference
898
+ * numerically/symbolically. These `Expression` comparison methods remain boolean for
899
+ * compatibility. An unknown assumption result falls through to the ordinary comparison
900
+ * path; if the relation still cannot be established, the method returns `false`. The
901
+ * lower-level `Assumption` relations preserve unknown as `undefined`. Complex values are
902
+ * not ordered and cause the comparison to throw.
903
+ *
904
+ * @param x - Value to compare with this expression.
905
+ * @returns `true` when the requested ordering is established, otherwise `false`.
906
+ * @throws {@link core!UnsupportedOperationError}
907
+ * Thrown when either side is classified as complex.
908
+ */
909
+ gte(x: ExpressionInput | ParserEntity): boolean;
910
+ /**
911
+ * Reports whether decimal-origin numeric data occurs anywhere in this expression.
912
+ *
913
+ * @remarks
914
+ * The check follows the multiplier, explicit power, exponential base, function
915
+ * arguments, and aggregate elements. It tests the rational `asDecimal` provenance
916
+ * marker; it does not merely search rendered text for a decimal point.
917
+ *
918
+ * @returns `true` when any contained rational originated from decimal input.
919
+ */
920
+ hasDecimal(): boolean;
921
+ /**
922
+ * Tests whether a named function occurs in this expression.
923
+ *
924
+ * @remarks
925
+ * Aggregate elements are always searched. When `deep` is `true`, function arguments
926
+ * and the explicit base and power of `EXP` nodes are searched recursively as well.
927
+ * With `deep` disabled, nested function arguments and `EXP` components are not
928
+ * traversed.
929
+ *
930
+ * @param name - Function name to locate.
931
+ * @param deep - Include function arguments and `EXP` base/power traversal.
932
+ * @returns `true` when the named function is found.
933
+ */
934
+ hasFunction(name: string, deep?: boolean): boolean;
935
+ /**
936
+ * Tests the node's outer power for a rational exponent with a non-unit denominator.
937
+ *
938
+ * @remarks
939
+ * This predicate examines this node's effective power; it does not recursively scan
940
+ * every descendant for radicals. When `checkIrrationalDenominator` is `true`, the
941
+ * power must also be negative, which identifies a radical occurring in a denominator.
942
+ *
943
+ * @param checkIrrationalDenominator - Require the fractional power to be negative.
944
+ * @returns `true` when the outer power meets the requested radical condition.
945
+ */
946
+ hasRadical(checkIrrationalDenominator?: boolean): boolean;
947
+ /**
948
+ * Tests whether a variable node with the requested value occurs in the expression tree.
949
+ *
950
+ * Function arguments, aggregate elements, and `EXP` bases and powers are searched
951
+ * recursively. This predicate does not apply the free-variable filtering used by
952
+ * {@link Expression.variables}; reserved constants can still match when requested
953
+ * explicitly.
954
+ *
955
+ * @param variable - Variable value to locate.
956
+ * @returns `true` when a matching `VAR` node occurs.
957
+ */
958
+ hasVariable(variable: string): boolean;
959
+ /**
960
+ * Multiplies this Expression by the imaginary unit, converting it to an imaginary value.
961
+ *
962
+ * @returns A new Expression equal to `this * i`.
963
+ *
964
+ * @example
965
+ * ```ts
966
+ * Expression.create(3).i().text() // "3*i"
967
+ * ```
968
+ */
969
+ i(): Expression;
970
+ /**
971
+ * Returns a string representation used internally for structural comparison
972
+ * of expressions.
973
+ *
974
+ * @returns A string identifier suitable for equality checks.
975
+ */
976
+ idString(): string;
977
+ /**
978
+ * Returns Nerdamer's symbolic decomposition of the imaginary component.
979
+ *
980
+ * @remarks
981
+ * The result excludes the imaginary-unit factor itself. Decomposition follows
982
+ * principal-branch handling for powered complex values and preserves unresolved
983
+ * complex function components symbolically instead of silently treating them as
984
+ * zero. `realpart(...)` and `imagpart(...)` nodes are treated as real-valued component
985
+ * expressions.
986
+ *
987
+ * @returns The symbolic imaginary coefficient.
988
+ */
989
+ imagPart(): Expression;
990
+ /**
991
+ * Returns the multiplicative inverse of this expression.
992
+ *
993
+ * @remarks
994
+ * Real symbolic nodes are copied and inverted by negating the outer power and
995
+ * rational multiplier. Complex expressions use the general division path so real and
996
+ * imaginary components are handled correctly. Simple radical denominators are
997
+ * rationalized when the power operation identifies an eligible radical.
998
+ *
999
+ * The receiver is not modified.
1000
+ *
1001
+ * @returns The reciprocal expression.
1002
+ * @throws {@link core!DivisionByZeroError}
1003
+ * Thrown by the underlying rational or division operation when the expression is zero.
1004
+ */
1005
+ invert(): Expression;
1006
+ /**
1007
+ * Reports whether the current expression tree contains a complex-valued component.
1008
+ *
1009
+ * @remarks
1010
+ * The check is structural: it recognizes the current imaginary-unit symbol, recurses
1011
+ * through function arguments, `EXP` bases and powers, and aggregate elements. The
1012
+ * component functions `realpart(...)` and `imagpart(...)` are treated as real-valued
1013
+ * by definition even when their arguments contain complex values.
1014
+ *
1015
+ * This predicate does not impose an ordering or otherwise claim that an unrestricted
1016
+ * symbolic expression is provably real.
1017
+ *
1018
+ * @returns `true` when the represented expression contains a recognized complex component.
1019
+ */
1020
+ isComplex(): boolean;
1021
+ /**
1022
+ * Tests whether this node is `realpart(...)` or `imagpart(...)`.
1023
+ *
1024
+ * These component functions are treated as real-valued by the complex-decomposition
1025
+ * logic even when their arguments are complex.
1026
+ */
1027
+ isComplexComponentFunction(): boolean;
1028
+ /**
1029
+ * Tests whether this node belongs to Nerdamer's currently recognized constant forms.
1030
+ *
1031
+ * @remarks
1032
+ * This is narrower than the mathematical statement "contains no free
1033
+ * variables." It recognizes numeric nodes, parser constants such as `pi` and `e`,
1034
+ * constant-base/constant-power `EXP` nodes, and sums or products whose elements are
1035
+ * recursively recognized as constant. The imaginary unit is handled by
1036
+ * dedicated complex logic rather than classified here as a parser constant.
1037
+ *
1038
+ * Do not use this predicate as a general proof that an arbitrary function expression
1039
+ * is or is not mathematically constant.
1040
+ *
1041
+ * @returns `true` for the constant forms recognized by this predicate.
1042
+ */
1043
+ isConstant(): boolean;
1044
+ /**
1045
+ * Tests whether this node's stored value is the Euler-constant symbol `e`.
1046
+ *
1047
+ * The check is representation-level and does not require a unit multiplier or power.
1048
+ *
1049
+ * @returns `true` when `value` is the current `e` symbol.
1050
+ */
1051
+ isE(): boolean;
1052
+ /**
1053
+ * Checks whether this Expression is an even integer.
1054
+ *
1055
+ * @returns `true` if the expression is `NUM` and its multiplier is even.
1056
+ *
1057
+ * @example
1058
+ * ```ts
1059
+ * Expression.create(4).isEven() // true
1060
+ * Expression.create(3).isEven() // false
1061
+ * ```
1062
+ */
1063
+ isEven(): boolean;
1064
+ /**
1065
+ * Checks whether this Expression has the EXP (exponential/power) internal type.
1066
+ *
1067
+ * @returns `true` if the type is EXP.
1068
+ */
1069
+ isEXP(): this is this & {
1070
+ base: Expression;
1071
+ };
1072
+ /**
1073
+ * Checks whether this Expression is a function node.
1074
+ *
1075
+ * @returns `true` if the expression is a function node.
1076
+ *
1077
+ * @example
1078
+ * ```ts
1079
+ * Expression.create('sin(x)').isFunction() // true
1080
+ * Expression.create('x').isFunction() // false
1081
+ * ```
1082
+ */
1083
+ isFunction(): this is this & {
1084
+ name: string;
1085
+ };
1086
+ /**
1087
+ * Checks whether this Expression is a function node with one of the given names.
1088
+ *
1089
+ * @param names - A single function name or an array of names to match.
1090
+ * @returns `true` if the expression is a function node with a matching name.
1091
+ *
1092
+ * @example
1093
+ * ```ts
1094
+ * Expression.create('sin(x)').isFunction('sin') // true
1095
+ * Expression.create('sin(x)').isFunction('cos') // false
1096
+ * ```
1097
+ */
1098
+ isFunction(names: string | string[]): boolean;
1099
+ /**
1100
+ * Checks whether this Expression is exactly `1/2`.
1101
+ *
1102
+ * @returns `true` if the expression is the numeric value `1/2`.
1103
+ */
1104
+ isHalf(): boolean;
1105
+ /**
1106
+ * Tests whether this node's stored value is the current imaginary-unit symbol.
1107
+ *
1108
+ * @remarks
1109
+ * This is a representation-level symbol check. It does not require the node to have
1110
+ * multiplier one or power one, so callers that require exactly the mathematical unit
1111
+ * `i` must impose those additional conditions themselves.
1112
+ *
1113
+ * @returns `true` when `value` matches {@link Expression.imaginary}.
1114
+ */
1115
+ isI(): boolean;
1116
+ /**
1117
+ * Evaluates the expression and reports whether the result is classified as complex.
1118
+ *
1119
+ * @remarks
1120
+ * Despite the historical method name, this is not a test for a purely imaginary
1121
+ * value with zero real part. A value such as `3 + 2*i` also returns `true` because
1122
+ * the evaluated result contains a complex component.
1123
+ *
1124
+ * @returns `true` when the evaluated expression satisfies {@link Expression.isComplex}.
1125
+ */
1126
+ isImaginary(): boolean;
1127
+ /**
1128
+ * Checks whether this Expression represents infinity (positive or negative).
1129
+ *
1130
+ * @returns `true` if the type is INF.
1131
+ */
1132
+ isInf(): boolean;
1133
+ /**
1134
+ * Checks whether this Expression is an exact integer.
1135
+ *
1136
+ * @returns `true` if the expression is `NUM` with an integer multiplier.
1137
+ *
1138
+ * @example
1139
+ * ```ts
1140
+ * Expression.create(5).isInteger() // true
1141
+ * Expression.create('3/2').isInteger() // false
1142
+ * ```
1143
+ */
1144
+ isInteger(): boolean;
1145
+ /**
1146
+ * Checks whether this Expression has power equal to `1` (i.e. is linear in itself).
1147
+ *
1148
+ * @returns `true` if the power is `1`.
1149
+ */
1150
+ isLinear(): boolean;
1151
+ /**
1152
+ * Checks whether this Expression is exactly `-1`.
1153
+ *
1154
+ * @returns `true` if the expression equals `-1`.
1155
+ */
1156
+ isMinusOne(): boolean;
1157
+ /**
1158
+ * Tests whether both evaluated complex components are small relative to Decimal precision.
1159
+ *
1160
+ * @remarks
1161
+ * The tolerance is `10^(-Decimal.precision + k)`. This is a numerical-algorithm
1162
+ * convenience and must not be used as a replacement for exact symbolic zero testing;
1163
+ * use {@link Expression.isZero} when exact representation-level zero is required.
1164
+ *
1165
+ * @param k - Number of guard digits removed from the active Decimal precision.
1166
+ * @returns `true` when the magnitudes of both real and imaginary components are within the tolerance.
1167
+ */
1168
+ isNearlyZero(k?: number): boolean;
1169
+ /**
1170
+ * Tests whether this expression is established to be strictly less than zero.
1171
+ *
1172
+ * The result follows {@link Expression.lt}: unresolved symbolic sign information
1173
+ * currently produces `false`, while complex values cannot be ordered.
1174
+ *
1175
+ * @returns `true` when the current comparison machinery establishes a negative value.
1176
+ * @throws {@link core!UnsupportedOperationError}
1177
+ * Thrown when the expression is classified as complex.
1178
+ */
1179
+ isNegative(): boolean;
1180
+ /**
1181
+ * Checks whether this Expression is negative infinity (`−∞`).
1182
+ *
1183
+ * @returns `true` if the expression is `−∞`.
1184
+ */
1185
+ isNegInf(): boolean;
1186
+ /**
1187
+ * Checks whether this Expression has the `NUM` (numeric) internal type.
1188
+ *
1189
+ * This only matches explicit numbers, not symbolic constants like `pi` or `e`.
1190
+ * Use {@link isConstant} to check for all values that reduce to a constant.
1191
+ *
1192
+ * @returns `true` if the type is `NUM`.
1193
+ *
1194
+ * @example
1195
+ * ```ts
1196
+ * Expression.create(5).isNUM() // true
1197
+ * Expression.create('pi').isNUM() // false
1198
+ * ```
1199
+ */
1200
+ isNUM(): boolean;
1201
+ /**
1202
+ * Tests whether this Expression is represented as a plain numeric value.
1203
+ *
1204
+ * @returns `true` for NUM expressions.
1205
+ */
1206
+ isNumber(): boolean;
1207
+ /**
1208
+ * Checks whether this Expression is an odd integer.
1209
+ *
1210
+ * @returns `true` only for numeric integer expressions whose multiplier is odd.
1211
+ */
1212
+ isOdd(): boolean;
1213
+ /**
1214
+ * Checks whether this Expression is exactly `1`.
1215
+ *
1216
+ * @returns `true` if the expression equals `1`.
1217
+ */
1218
+ isOne(): boolean;
1219
+ /**
1220
+ * Tests whether this node's stored value matches a recognized π symbol.
1221
+ *
1222
+ * The check is representation-level and does not require a unit multiplier or power.
1223
+ *
1224
+ * @returns `true` when `value` is one of Nerdamer's π aliases.
1225
+ */
1226
+ isPi(): boolean;
1227
+ /**
1228
+ * Checks whether this Expression is a plain variable with no multiplier and
1229
+ * no power (i.e. multiplier `1`, power `1`, type `VAR`).
1230
+ *
1231
+ * @returns `true` for a bare variable like `x`.
1232
+ *
1233
+ * @example
1234
+ * ```ts
1235
+ * Expression.create('x').isPlainVariable() // true
1236
+ * Expression.create('2*x').isPlainVariable() // false
1237
+ * Expression.create('x^2').isPlainVariable() // false
1238
+ * ```
1239
+ */
1240
+ isPlainVariable(): boolean;
1241
+ /**
1242
+ * Tests whether this expression has the structural form of a polynomial over rational coefficients.
1243
+ *
1244
+ * @remarks
1245
+ * The predicate accepts recursively composed sums and products whose outer powers are
1246
+ * non-negative integers. Function nodes, `EXP` nodes, infinities, negative powers,
1247
+ * and fractional powers are rejected. This is a structural eligibility check used by
1248
+ * polynomial-oriented algorithms; it does not construct a {@link algebra!Polynomial}.
1249
+ *
1250
+ * @returns `true` when the expression satisfies the current polynomial-like restrictions.
1251
+ */
1252
+ isPolynomialLike(): boolean;
1253
+ /**
1254
+ * Checks whether this Expression is positive infinity (`+∞`).
1255
+ *
1256
+ * @returns `true` if the expression is `+∞`.
1257
+ */
1258
+ isPosInf(): boolean;
1259
+ /**
1260
+ * Checks whether this Expression has the PRD (product) internal type.
1261
+ *
1262
+ * @returns `true` if the type is PRD.
1263
+ */
1264
+ isProduct(): boolean;
1265
+ /**
1266
+ * Checks whether this Expression is exactly `1/4`.
1267
+ *
1268
+ * @returns `true` if the expression is the numeric value `1/4`.
1269
+ */
1270
+ isQuarter(): boolean;
1271
+ /**
1272
+ * Checks whether this Expression is a summation-like type (SUM or GRP).
1273
+ *
1274
+ * @returns `true` if the type is SUM or GRP.
1275
+ */
1276
+ isSum(): boolean;
1277
+ /**
1278
+ * Checks whether this Expression has the VAR (variable) internal type.
1279
+ *
1280
+ * @returns `true` if the type is VAR.
1281
+ */
1282
+ isVAR(): boolean;
1283
+ /**
1284
+ * Checks whether this Expression is exactly `0`.
1285
+ *
1286
+ * @returns `true` if the multiplier is zero.
1287
+ *
1288
+ * @example
1289
+ * ```ts
1290
+ * Expression.create(0).isZero() // true
1291
+ * Expression.create(1).isZero() // false
1292
+ * ```
1293
+ */
1294
+ isZero(): boolean;
1295
+ /**
1296
+ * Builds the canonical lookup key used to group compatible expression terms.
1297
+ *
1298
+ * @remarks
1299
+ * This is an internal canonicalization key, not a user-facing serialization format.
1300
+ * Numeric nodes normally collapse to {@link Expression.numberHash}; variables,
1301
+ * functions, exponentials, and infinities use multiplier-free identifiers; aggregate
1302
+ * nodes derive a key from their canonical elements. Group (`GRP`) handling can use the
1303
+ * power directly when `isGroup` is requested.
1304
+ *
1305
+ * The exact key format is coupled to parser/algebra combination logic and should not
1306
+ * be persisted as an external interchange format.
1307
+ *
1308
+ * @param asSubExpression - Use the fuller sub-expression representation where supported.
1309
+ * @param isGroup - Build a group-member key from this expression's power.
1310
+ * @returns The canonical lookup key.
1311
+ * @throws Error
1312
+ * Thrown when no key-generation rule exists for the node's internal type.
1313
+ */
1314
+ keyValue(asSubExpression?: boolean, isGroup?: boolean): string;
1315
+ /**
1316
+ * Tests whether this expression is `<` another value.
1317
+ *
1318
+ * @remarks
1319
+ * Nerdamer consults applicable assumptions and otherwise evaluates the difference
1320
+ * numerically/symbolically. These `Expression` comparison methods remain boolean for
1321
+ * compatibility. An unknown assumption result falls through to the ordinary comparison
1322
+ * path; if the relation still cannot be established, the method returns `false`. The
1323
+ * lower-level `Assumption` relations preserve unknown as `undefined`. Complex values are
1324
+ * not ordered and cause the comparison to throw.
1325
+ *
1326
+ * @param x - Value to compare with this expression.
1327
+ * @returns `true` when the requested ordering is established, otherwise `false`.
1328
+ * @throws {@link core!UnsupportedOperationError}
1329
+ * Thrown when either side is classified as complex.
1330
+ */
1331
+ lt(x: ExpressionInput | ParserEntity): boolean;
1332
+ /**
1333
+ * Tests whether this expression is `<=` another value.
1334
+ *
1335
+ * @remarks
1336
+ * Nerdamer consults applicable assumptions and otherwise evaluates the difference
1337
+ * numerically/symbolically. These `Expression` comparison methods remain boolean for
1338
+ * compatibility. An unknown assumption result falls through to the ordinary comparison
1339
+ * path; if the relation still cannot be established, the method returns `false`. The
1340
+ * lower-level `Assumption` relations preserve unknown as `undefined`. Complex values are
1341
+ * not ordered and cause the comparison to throw.
1342
+ *
1343
+ * @param x - Value to compare with this expression.
1344
+ * @returns `true` when the requested ordering is established, otherwise `false`.
1345
+ * @throws {@link core!UnsupportedOperationError}
1346
+ * Thrown when either side is classified as complex.
1347
+ */
1348
+ lte(x: ExpressionInput | ParserEntity): boolean;
1349
+ /**
1350
+ * Subtracts `x` from this Expression.
1351
+ *
1352
+ * @param x - The value to subtract.
1353
+ * @returns A new Expression representing `this − x`.
1354
+ *
1355
+ * @example
1356
+ * ```ts
1357
+ * Expression.create('x').minus(1).text() // "-1+x"
1358
+ * Expression.create(10).minus(3).text() // "7"
1359
+ * ```
1360
+ */
1361
+ minus(x: ExpressionInput): Expression;
1362
+ /**
1363
+ * Computes the modulo of this Expression by `x`.
1364
+ *
1365
+ * @param x - The divisor.
1366
+ * @returns A new Expression representing `this mod x`.
1367
+ *
1368
+ * @example
1369
+ * ```ts
1370
+ * Expression.create(10).mod(3).text() // "1"
1371
+ * ```
1372
+ */
1373
+ mod(x: ExpressionInput): Expression;
1374
+ /**
1375
+ * Legacy alias for {@link times}.
1376
+ *
1377
+ * @param x - The value to multiply by.
1378
+ * @returns A new Expression representing `this * x`.
1379
+ */
1380
+ multiply(x: ExpressionInput): Expression;
1381
+ /**
1382
+ * Negates this Expression by flipping the sign of the multiplier.
1383
+ *
1384
+ * @returns A new Expression equal to `this * −1`.
1385
+ *
1386
+ * @example
1387
+ * ```ts
1388
+ * Expression.create(5).neg().text() // "-5"
1389
+ * Expression.create('x').neg().text() // "-x"
1390
+ * ```
1391
+ */
1392
+ neg(): Expression;
1393
+ /**
1394
+ * Legacy alias for {@link getNumerator}.
1395
+ *
1396
+ * @returns The numerator Expression.
1397
+ */
1398
+ numerator(): Expression;
1399
+ /**
1400
+ * Compatibility alias for the copy-oriented base extraction used by
1401
+ * {@link Expression.toLinearAndUnitMultiplier}.
1402
+ *
1403
+ * @returns An independent Expression representing the node's mathematical base.
1404
+ */
1405
+ parseValue(): Expression;
1406
+ /**
1407
+ * Adds `x` to this Expression.
1408
+ *
1409
+ * @param x - The value to add.
1410
+ * @returns A new Expression representing `this + x`.
1411
+ *
1412
+ * @example
1413
+ * ```ts
1414
+ * Expression.create('x').plus(1).text() // "1+x"
1415
+ * Expression.create(2).plus(3).text() // "5"
1416
+ * ```
1417
+ */
1418
+ plus(x: ExpressionInput): Expression;
1419
+ /**
1420
+ * Raises this expression to a symbolic or numeric exponent.
1421
+ *
1422
+ * @remarks
1423
+ * The operation delegates to Nerdamer's power canonicalization and simplification
1424
+ * rules. Noninteger and complex powers follow principal-branch semantics; identities
1425
+ * such as distributing a fractional power over arbitrary products are therefore
1426
+ * applied only when the implementation can preserve the relevant branch.
1427
+ *
1428
+ * The receiver is not modified.
1429
+ *
1430
+ * @param x - Exponent to apply.
1431
+ * @returns The simplified power expression.
1432
+ * @throws {@link core!UndefinedError}
1433
+ * Thrown for undefined infinity-related powers handled by the power operation.
1434
+ * @throws {@link core!ZeroToZeroPowerError}
1435
+ * Thrown for zero-power cases classified as undefined by the power operation.
1436
+ */
1437
+ pow(x: ExpressionInput): Expression;
1438
+ /**
1439
+ * Returns Nerdamer's symbolic decomposition of the real component.
1440
+ *
1441
+ * @remarks
1442
+ * Decomposition follows principal-branch handling for powered complex values.
1443
+ * Explicitly complex function calls that cannot be decomposed are preserved through
1444
+ * a symbolic `realpart(...)` wrapper rather than being guessed. The component
1445
+ * functions `realpart(...)` and `imagpart(...)` are themselves treated as real-valued.
1446
+ *
1447
+ * @returns The symbolic real component.
1448
+ */
1449
+ realPart(): Expression;
1450
+ /**
1451
+ * Returns the sign encoded by this node's coefficient representation.
1452
+ *
1453
+ * @remarks
1454
+ * This is not a general symbolic sign analysis. Most node types return the sign of
1455
+ * their outer {@link Rational} multiplier. `EXP` nodes additionally multiply that
1456
+ * result by the representation-level sign of their stored base. Unknown assumptions
1457
+ * are not inferred here.
1458
+ *
1459
+ * @returns `-1`, `0`, or `1` from the represented coefficient/base sign.
1460
+ */
1461
+ sign(): number;
1462
+ /**
1463
+ * Removes the sign represented by this expression's current form.
1464
+ *
1465
+ * @remarks
1466
+ * Complex expressions return their modulus `sqrt(re^2 + im^2)`. For other
1467
+ * expressions, the method copies the node and removes a negative stored sign or
1468
+ * multiplier. This is representation-oriented normalization, not a general
1469
+ * assumption-driven implementation of symbolic `abs(...)`.
1470
+ *
1471
+ * @returns A new sign-free expression or complex modulus.
1472
+ */
1473
+ signFree(): Expression;
1474
+ /**
1475
+ * Formats this expression using SymPy-style `**` exponentiation syntax.
1476
+ *
1477
+ * @remarks
1478
+ * Formatting temporarily switches the class-wide power-operator token while
1479
+ * delegating to the normal expression formatter, then restores `^`. The expression
1480
+ * itself is not modified.
1481
+ *
1482
+ * @param options - Formatting options accepted by the normal text formatter.
1483
+ * @param asId - Request the internal identifier-oriented formatting mode.
1484
+ * @returns SymPy-compatible expression text.
1485
+ */
1486
+ sptext(options?: TextOptions, asId?: boolean): string;
1487
+ /**
1488
+ * Squares this Expression. Shorthand for `this.pow('2')`.
1489
+ *
1490
+ * @returns A new Expression representing `this²`.
1491
+ *
1492
+ * @example
1493
+ * ```ts
1494
+ * Expression.create('x').sq().text() // "x^2"
1495
+ * Expression.create(5).sq().text() // "25"
1496
+ * ```
1497
+ */
1498
+ sq(): Expression;
1499
+ /**
1500
+ * Tests Nerdamer equality while also requiring the same top-level internal type.
1501
+ *
1502
+ * @remarks
1503
+ * This is stricter than {@link Expression.eq}, but it is still not object identity or
1504
+ * byte-for-byte tree equality. After verifying matching top-level types (or matching
1505
+ * function names for function nodes), it delegates to Nerdamer's symbolic equality
1506
+ * comparison.
1507
+ *
1508
+ * @param x - Value to compare with this expression.
1509
+ * @returns `true` when the type/name requirement and symbolic equality both hold.
1510
+ */
1511
+ strictEqual(x: ExpressionInput): boolean;
1512
+ /**
1513
+ * Legacy alias for {@link subst}.
1514
+ *
1515
+ * @param value - The sub-expression to find.
1516
+ * @param withValue - The replacement expression.
1517
+ * @returns A new Expression with the substitution applied.
1518
+ */
1519
+ sub(value: ExpressionInput, withValue: ExpressionInput): Expression;
1520
+ /**
1521
+ * Replaces occurrences of one symbolic expression with another.
1522
+ *
1523
+ * @remarks
1524
+ * Substitution supports more than direct variable replacement: the underlying
1525
+ * algorithm can match compatible products and sums, recurse into function arguments,
1526
+ * and substitute within powers. Inputs are converted through
1527
+ * {@link Expression.create}. The receiver is not mutated as part of normal execution. Unchanged
1528
+ * branches can preserve the receiver's identity, and an exact match can return the
1529
+ * supplied replacement object directly, so callers that require independent ownership
1530
+ * should copy the result explicitly.
1531
+ *
1532
+ * @param value - Symbolic value or sub-expression to match.
1533
+ * @param withValue - Replacement value.
1534
+ * @returns The expression produced by the substitution algorithm.
1535
+ */
1536
+ subst(value: ExpressionInput, withValue: ExpressionInput): Expression;
1537
+ /**
1538
+ * Legacy alias for {@link minus}.
1539
+ *
1540
+ * @param x - The value to subtract.
1541
+ * @returns A new Expression representing `this − x`.
1542
+ */
1543
+ subtract(x: ExpressionInput): Expression;
1544
+ /**
1545
+ * Formats this expression using Nerdamer's canonical text formatter.
1546
+ *
1547
+ * @remarks
1548
+ * Exact rational text is the default. Use `sort: true` to render terms in Nerdamer's
1549
+ * conventional display order without changing the stored expression. Decimal output,
1550
+ * precision, and power wrapping can also be selected per call. The `asId` mode is used
1551
+ * by internal identity/canonicalization logic and should not be
1552
+ * treated as a stable interchange format.
1553
+ *
1554
+ * @param options - Text-formatting options.
1555
+ * @param asId - Use the internal identifier-oriented formatting mode.
1556
+ * @returns The formatted expression text.
1557
+ *
1558
+ * @example
1559
+ * ```ts
1560
+ * Expression.create('x^2 + 2*x + 1').text(); // "1+2*x+x^2"
1561
+ * Expression.create('x^2 + 2*x + 1').text({ sort: true }); // "x^2+2*x+1"
1562
+ * Expression.create('1/3').text(); // "1/3"
1563
+ * Expression.create('1/3').text({ decimal: true }); // decimal representation
1564
+ * ```
1565
+ */
1566
+ text(options?: TextOptions, asId?: boolean): string;
1567
+ /**
1568
+ * Multiplies this Expression by `x`.
1569
+ *
1570
+ * @param x - The value to multiply by.
1571
+ * @returns A new Expression representing `this * x`.
1572
+ *
1573
+ * @example
1574
+ * ```ts
1575
+ * Expression.create('x').times(3).text() // "3*x"
1576
+ * Expression.create('x').times('y').text() // "x*y"
1577
+ * ```
1578
+ */
1579
+ times(x: ExpressionInput): Expression;
1580
+ /**
1581
+ * Formats this expression using decimal numeric output.
1582
+ *
1583
+ * This is a formatting operation equivalent to calling {@link Expression.text} with
1584
+ * `{ decimal: true }`; it does not convert the expression tree into a floating-point
1585
+ * data structure.
1586
+ *
1587
+ * @param precision - Optional decimal formatting precision.
1588
+ * @returns Decimal-form expression text.
1589
+ */
1590
+ toDecimal(precision?: number): string;
1591
+ /**
1592
+ * Returns an independent base expression with the outer multiplier and power removed.
1593
+ *
1594
+ * @remarks
1595
+ * Base extraction is defined by {@link Expression.getBase}. Because `getBase()`
1596
+ * exposes an `EXP` node's stored base by reference, this method copies
1597
+ * that base before returning it. Non-`EXP` bases are already independent copies.
1598
+ *
1599
+ * @returns An independent expression representing the node without its outer multiplier and power.
1600
+ */
1601
+ toLinearAndUnitMultiplier(): Expression;
1602
+ /**
1603
+ * Returns the string representation. Alias for {@link text}.
1604
+ *
1605
+ * @param options - Formatting options passed to {@link text}.
1606
+ * @returns The text representation.
1607
+ */
1608
+ toString(options?: TextOptions): string;
1609
+ /**
1610
+ * Returns the total degree of a monomial by summing the powers of all factors
1611
+ * in a product expression. For non-product types, returns the expression's own power.
1612
+ *
1613
+ * @returns The total power as an Expression.
1614
+ *
1615
+ * @example
1616
+ * ```ts
1617
+ * Expression.create('x^2*y^3').totalPower().text() // "5"
1618
+ * Expression.create('x^4').totalPower().text() // "4"
1619
+ * ```
1620
+ */
1621
+ totalPower(): Expression;
1622
+ /**
1623
+ * Returns a copy of this Expression with the multiplier removed (set to `1`).
1624
+ *
1625
+ * For `NUM` types (where the multiplier *is* the value), returns `1`.
1626
+ *
1627
+ * @returns A new multiplier-free Expression.
1628
+ *
1629
+ * @example
1630
+ * ```ts
1631
+ * Expression.create('3*x').toUnitMultiplier().text() // "x"
1632
+ * Expression.create(5).toUnitMultiplier().text() // "1"
1633
+ * ```
1634
+ */
1635
+ toUnitMultiplier(): Expression;
1636
+ /**
1637
+ * Regenerates the stored `value` string from mutable structural state where supported.
1638
+ *
1639
+ * @remarks
1640
+ * Function nodes rebuild `value` from their name and arguments. Product and sum-like
1641
+ * nodes rebuild it from their current elements. Other node types are left unchanged.
1642
+ * This method mutates the receiver and returns the same object for chaining.
1643
+ *
1644
+ * @returns This expression after updating its stored value where applicable.
1645
+ */
1646
+ updateValue(): this;
1647
+ /**
1648
+ * Provides the primitive value used by JavaScript coercion.
1649
+ *
1650
+ * Numeric (`NUM`) expressions return the primitive value of their rational
1651
+ * multiplier. Other expressions return decimal-formatted text. This coercion API is
1652
+ * intended for JavaScript interoperability; use explicit symbolic comparison methods
1653
+ * when mathematical equality or ordering is required.
1654
+ *
1655
+ * @returns A number for numeric nodes, otherwise decimal-form expression text.
1656
+ */
1657
+ valueOf(): number | string;
1658
+ /**
1659
+ * Collects distinct free-variable names from this expression tree.
1660
+ *
1661
+ * @remarks
1662
+ * Only `VAR` nodes are collected. The current imaginary-unit symbol and names in
1663
+ * {@link Expression.RESERVED} are excluded. Traversal includes function arguments,
1664
+ * aggregate elements, and `EXP` bases and powers. Encounter order is preserved unless
1665
+ * the caller sorts the returned array separately.
1666
+ *
1667
+ * If `vars` is supplied, new names are appended to that same accumulator without
1668
+ * duplicating names already present.
1669
+ *
1670
+ * @param vars - Optional accumulator of names already collected.
1671
+ * @returns The accumulator containing distinct variable names.
1672
+ */
1673
+ variables(vars?: string[]): string[];
1674
+ }