nerdamer 1.1.13 → 2.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BREAKING_CHANGES.md +244 -5
- package/LICENSE.md +184 -0
- package/README.md +232 -318
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +7 -0
- package/dist/parser.js +2 -0
- package/dist/parser.js.LICENSE.txt +7 -0
- package/docs-data/parser-functions.json +2248 -0
- package/index.d.ts +10 -426
- package/output/algebra/adapters.d.ts +3 -0
- package/output/algebra/adapters.js +11 -0
- package/output/algebra/algorithms/arith.d.ts +84 -0
- package/output/algebra/algorithms/arith.js +324 -0
- package/output/algebra/algorithms/groebnerBase.d.ts +161 -0
- package/output/algebra/algorithms/groebnerBase.js +929 -0
- package/output/algebra/dispatch.d.ts +1 -0
- package/output/algebra/dispatch.js +25 -0
- package/output/algebra/factor/factor.d.ts +77 -0
- package/output/algebra/factor/factor.js +245 -0
- package/output/algebra/gcd/gcd.d.ts +30 -0
- package/output/algebra/gcd/gcd.js +95 -0
- package/output/algebra/groebner.d.ts +21 -0
- package/output/algebra/groebner.js +36 -0
- package/output/algebra/partfrac.d.ts +19 -0
- package/output/algebra/partfrac.js +365 -0
- package/output/algebra/polynomial/ModularSparsePolynomial.d.ts +131 -0
- package/output/algebra/polynomial/ModularSparsePolynomial.js +378 -0
- package/output/algebra/polynomial/ModularSparsePolynomialFactor.d.ts +40 -0
- package/output/algebra/polynomial/ModularSparsePolynomialFactor.js +661 -0
- package/output/algebra/polynomial/SparsePolynomialFactor.d.ts +64 -0
- package/output/algebra/polynomial/SparsePolynomialFactor.js +492 -0
- package/output/algebra/polynomial/SparsePolynomialGcd.d.ts +29 -0
- package/output/algebra/polynomial/SparsePolynomialGcd.js +259 -0
- package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.d.ts +82 -0
- package/output/algebra/polynomial/SparsePolynomialMultivariateFactor.js +604 -0
- package/output/algebra/polynomial/modularGcd.d.ts +40 -0
- package/output/algebra/polynomial/modularGcd.js +365 -0
- package/output/algebra/polynomialize.d.ts +20 -0
- package/output/algebra/polynomialize.js +26 -0
- package/output/algebra/simplify/complexsimp.d.ts +7 -0
- package/output/algebra/simplify/complexsimp.js +24 -0
- package/output/algebra/simplify/factorCommon.d.ts +13 -0
- package/output/algebra/simplify/factorCommon.js +136 -0
- package/output/algebra/simplify/funcsimp.d.ts +26 -0
- package/output/algebra/simplify/funcsimp.js +633 -0
- package/output/algebra/simplify/invtrigrewrite.d.ts +10 -0
- package/output/algebra/simplify/invtrigrewrite.js +96 -0
- package/output/algebra/simplify/ratsimp.d.ts +21 -0
- package/output/algebra/simplify/ratsimp.js +140 -0
- package/output/algebra/simplify/simplify.d.ts +25 -0
- package/output/algebra/simplify/simplify.js +237 -0
- package/output/algebra/simplify/trigreduce.d.ts +38 -0
- package/output/algebra/simplify/trigreduce.js +424 -0
- package/output/algebra/simplify/trigrewrite.d.ts +17 -0
- package/output/algebra/simplify/trigrewrite.js +156 -0
- package/output/algebra/simplify/trigsimp.d.ts +11 -0
- package/output/algebra/simplify/trigsimp.js +369 -0
- package/output/algebra/simplify/utils.d.ts +32 -0
- package/output/algebra/simplify/utils.js +56 -0
- package/output/algebra/utils.d.ts +32 -0
- package/output/algebra/utils.js +48 -0
- package/output/api/advanced.d.ts +8 -0
- package/output/api/advanced.js +18 -0
- package/output/api/algebra.d.ts +17 -0
- package/output/api/algebra.js +35 -0
- package/output/api/assumptions.d.ts +4 -0
- package/output/api/assumptions.js +11 -0
- package/output/api/calculus.d.ts +10 -0
- package/output/api/calculus.js +22 -0
- package/output/api/core.d.ts +17 -0
- package/output/api/core.js +41 -0
- package/output/api/debug.d.ts +16 -0
- package/output/api/debug.js +23 -0
- package/output/api/languages/deu.d.ts +3 -0
- package/output/api/languages/deu.js +266 -0
- package/output/api/languages/fra.d.ts +3 -0
- package/output/api/languages/fra.js +266 -0
- package/output/api/languages/ita.d.ts +3 -0
- package/output/api/languages/ita.js +266 -0
- package/output/api/languages/nld.d.ts +3 -0
- package/output/api/languages/nld.js +266 -0
- package/output/api/languages/por.d.ts +3 -0
- package/output/api/languages/por.js +266 -0
- package/output/api/languages/spa.d.ts +3 -0
- package/output/api/languages/spa.js +266 -0
- package/output/api/parser.d.ts +93 -0
- package/output/api/parser.js +18 -0
- package/output/api/solve.d.ts +10 -0
- package/output/api/solve.js +17 -0
- package/output/api/structures.d.ts +10 -0
- package/output/api/structures.js +23 -0
- package/output/calculus/adapters.d.ts +8 -0
- package/output/calculus/adapters.js +41 -0
- package/output/calculus/derivative/diff.d.ts +30 -0
- package/output/calculus/derivative/diff.js +241 -0
- package/output/calculus/dispatch.d.ts +1 -0
- package/output/calculus/dispatch.js +25 -0
- package/output/calculus/fresnel.d.ts +16 -0
- package/output/calculus/fresnel.js +39 -0
- package/output/calculus/integrate/byParts.d.ts +18 -0
- package/output/calculus/integrate/byParts.js +339 -0
- package/output/calculus/integrate/bySubstitution.d.ts +135 -0
- package/output/calculus/integrate/bySubstitution.js +411 -0
- package/output/calculus/integrate/integrate.d.ts +38 -0
- package/output/calculus/integrate/integrate.js +652 -0
- package/output/calculus/integrate/integrationTable.d.ts +2 -0
- package/output/calculus/integrate/integrationTable.js +914 -0
- package/output/calculus/integrate/utils.d.ts +28 -0
- package/output/calculus/integrate/utils.js +96 -0
- package/output/calculus/laplace/ilaplace.d.ts +31 -0
- package/output/calculus/laplace/ilaplace.js +192 -0
- package/output/calculus/laplace/ilaplaceTable.d.ts +2 -0
- package/output/calculus/laplace/ilaplaceTable.js +200 -0
- package/output/calculus/laplace/laplace.d.ts +22 -0
- package/output/calculus/laplace/laplace.js +109 -0
- package/output/calculus/laplace/laplaceTable.d.ts +2 -0
- package/output/calculus/laplace/laplaceTable.js +187 -0
- package/output/calculus/limit/limit.d.ts +35 -0
- package/output/calculus/limit/limit.js +1183 -0
- package/output/calculus/limit/limitsTable.d.ts +2 -0
- package/output/calculus/limit/limitsTable.js +7 -0
- package/output/core/Settings.d.ts +32 -0
- package/output/core/Settings.js +68 -0
- package/output/core/classes/assumption/Assumption.d.ts +218 -0
- package/output/core/classes/assumption/Assumption.js +609 -0
- package/output/core/classes/assumption/assertiveFunctions.d.ts +6 -0
- package/output/core/classes/assumption/assertiveFunctions.js +64 -0
- package/output/core/classes/assumption/assume.d.ts +90 -0
- package/output/core/classes/assumption/assume.js +145 -0
- package/output/core/classes/assumption/dispatch.d.ts +1 -0
- package/output/core/classes/assumption/dispatch.js +11 -0
- package/output/core/classes/collection/Collection.d.ts +107 -0
- package/output/core/classes/collection/Collection.js +240 -0
- package/output/core/classes/complex/Complex.d.ts +109 -0
- package/output/core/classes/complex/Complex.js +153 -0
- package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
- package/output/core/classes/decimalSet/DecimalSet.js +454 -0
- package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
- package/output/core/classes/dictionary/Dictionary.js +216 -0
- package/output/core/classes/equation/Equation.d.ts +256 -0
- package/output/core/classes/equation/Equation.js +350 -0
- package/output/core/classes/expression/CoeffObject.d.ts +100 -0
- package/output/core/classes/expression/CoeffObject.js +197 -0
- package/output/core/classes/expression/Expression.d.ts +1691 -0
- package/output/core/classes/expression/Expression.js +2381 -0
- package/output/core/classes/expression/analysis.d.ts +25 -0
- package/output/core/classes/expression/analysis.js +218 -0
- package/output/core/classes/expression/collect.d.ts +9 -0
- package/output/core/classes/expression/collect.js +49 -0
- package/output/core/classes/expression/format.d.ts +54 -0
- package/output/core/classes/expression/format.js +340 -0
- package/output/core/classes/expression/products.d.ts +23 -0
- package/output/core/classes/expression/products.js +115 -0
- package/output/core/classes/expression/shortcuts.d.ts +35 -0
- package/output/core/classes/expression/shortcuts.js +129 -0
- package/output/core/classes/expression/traversal.d.ts +31 -0
- package/output/core/classes/expression/traversal.js +216 -0
- package/output/core/classes/expression/trig.d.ts +25 -0
- package/output/core/classes/expression/trig.js +40 -0
- package/output/core/classes/expression/utils.d.ts +61 -0
- package/output/core/classes/expression/utils.js +235 -0
- package/output/core/classes/lookupTable/LookupTable.d.ts +12 -0
- package/output/core/classes/lookupTable/LookupTable.js +55 -0
- package/output/core/classes/matrix/Matrix.d.ts +227 -0
- package/output/core/classes/matrix/Matrix.js +901 -0
- package/output/core/classes/matrix/Sylvester.d.ts +11 -0
- package/output/core/classes/matrix/Sylvester.js +54 -0
- package/output/core/classes/matrix/dispatch.d.ts +1 -0
- package/output/core/classes/matrix/dispatch.js +19 -0
- package/output/core/classes/matrix/functions.d.ts +28 -0
- package/output/core/classes/matrix/functions.js +57 -0
- package/output/core/classes/matrix/utils.d.ts +9 -0
- package/output/core/classes/matrix/utils.js +22 -0
- package/output/core/classes/parser/Parser.d.ts +493 -0
- package/output/core/classes/parser/Parser.js +1863 -0
- package/output/core/classes/parser/Token.d.ts +58 -0
- package/output/core/classes/parser/Token.js +137 -0
- package/output/core/classes/parser/constants.d.ts +162 -0
- package/output/core/classes/parser/constants.js +229 -0
- package/output/core/classes/parser/controlFlowSignals.d.ts +38 -0
- package/output/core/classes/parser/controlFlowSignals.js +60 -0
- package/output/core/classes/parser/helpers.d.ts +21 -0
- package/output/core/classes/parser/helpers.js +42 -0
- package/output/core/classes/parser/operations/add.d.ts +15 -0
- package/output/core/classes/parser/operations/add.js +236 -0
- package/output/core/classes/parser/operations/comma.d.ts +7 -0
- package/output/core/classes/parser/operations/comma.js +11 -0
- package/output/core/classes/parser/operations/compare.d.ts +21 -0
- package/output/core/classes/parser/operations/compare.js +474 -0
- package/output/core/classes/parser/operations/divide.d.ts +2 -0
- package/output/core/classes/parser/operations/divide.js +72 -0
- package/output/core/classes/parser/operations/functions.d.ts +46 -0
- package/output/core/classes/parser/operations/functions.js +438 -0
- package/output/core/classes/parser/operations/multiply.d.ts +11 -0
- package/output/core/classes/parser/operations/multiply.js +328 -0
- package/output/core/classes/parser/operations/power.d.ts +48 -0
- package/output/core/classes/parser/operations/power.js +673 -0
- package/output/core/classes/parser/operations/subtract.d.ts +3 -0
- package/output/core/classes/parser/operations/subtract.js +36 -0
- package/output/core/classes/parser/preprocess.d.ts +7 -0
- package/output/core/classes/parser/preprocess.js +246 -0
- package/output/core/classes/parser/scripting/controlFlow.d.ts +23 -0
- package/output/core/classes/parser/scripting/controlFlow.js +279 -0
- package/output/core/classes/parser/scripting/deferred.d.ts +4 -0
- package/output/core/classes/parser/scripting/deferred.js +65 -0
- package/output/core/classes/parser/scripting/dispatch.d.ts +1 -0
- package/output/core/classes/parser/scripting/dispatch.js +62 -0
- package/output/core/classes/parser/scripting/evaluate.d.ts +23 -0
- package/output/core/classes/parser/scripting/evaluate.js +128 -0
- package/output/core/classes/parser/scripting/functions.d.ts +14 -0
- package/output/core/classes/parser/scripting/functions.js +59 -0
- package/output/core/classes/parser/scripting/scope.d.ts +8 -0
- package/output/core/classes/parser/scripting/scope.js +132 -0
- package/output/core/classes/parser/types.d.ts +130 -0
- package/output/core/classes/parser/types.js +2 -0
- package/output/core/classes/parser/wrappers/IndexedReference.d.ts +31 -0
- package/output/core/classes/parser/wrappers/IndexedReference.js +68 -0
- package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +24 -0
- package/output/core/classes/parser/wrappers/KeyValuePair.js +51 -0
- package/output/core/classes/polynomial/Polynomial.d.ts +504 -0
- package/output/core/classes/polynomial/Polynomial.js +1195 -0
- package/output/core/classes/polynomial/SparsePolynomial.d.ts +221 -0
- package/output/core/classes/polynomial/SparsePolynomial.js +824 -0
- package/output/core/classes/polynomial/SparsePolynomialAdapter.d.ts +56 -0
- package/output/core/classes/polynomial/SparsePolynomialAdapter.js +241 -0
- package/output/core/classes/polynomial/Term.d.ts +222 -0
- package/output/core/classes/polynomial/Term.js +430 -0
- package/output/core/classes/polynomial/adapters.d.ts +18 -0
- package/output/core/classes/polynomial/adapters.js +33 -0
- package/output/core/classes/polynomial/dispatch.d.ts +1 -0
- package/output/core/classes/polynomial/dispatch.js +14 -0
- package/output/core/classes/polynomial/functions.d.ts +77 -0
- package/output/core/classes/polynomial/functions.js +189 -0
- package/output/core/classes/polynomial/utils.d.ts +62 -0
- package/output/core/classes/polynomial/utils.js +207 -0
- package/output/core/classes/rational/Rational.d.ts +501 -0
- package/output/core/classes/rational/Rational.js +829 -0
- package/output/core/classes/seq/SEQ.d.ts +13 -0
- package/output/core/classes/seq/SEQ.js +137 -0
- package/output/core/classes/valuesSet/ValuesSet.d.ts +187 -0
- package/output/core/classes/valuesSet/ValuesSet.js +399 -0
- package/output/core/classes/vector/Vector.d.ts +222 -0
- package/output/core/classes/vector/Vector.js +501 -0
- package/output/core/classes/vector/dispatch.d.ts +1 -0
- package/output/core/classes/vector/dispatch.js +11 -0
- package/output/core/classes/vector/functions.d.ts +28 -0
- package/output/core/classes/vector/functions.js +47 -0
- package/output/core/common/classes/MathematicalAggregate.d.ts +53 -0
- package/output/core/common/classes/MathematicalAggregate.js +149 -0
- package/output/core/common/classes/Scope.d.ts +62 -0
- package/output/core/common/classes/Scope.js +122 -0
- package/output/core/common/classes/StructuredEntity.d.ts +55 -0
- package/output/core/common/classes/StructuredEntity.js +151 -0
- package/output/core/common/common.d.ts +62 -0
- package/output/core/common/common.js +74 -0
- package/output/core/common/functions/functions.d.ts +14 -0
- package/output/core/common/functions/functions.js +33 -0
- package/output/core/common/functions/structuredEntityUtils.d.ts +27 -0
- package/output/core/common/functions/structuredEntityUtils.js +40 -0
- package/output/core/converters/BaseConverter.d.ts +97 -0
- package/output/core/converters/BaseConverter.js +405 -0
- package/output/core/converters/Converter.d.ts +111 -0
- package/output/core/converters/Converter.js +806 -0
- package/output/core/converters/Pattern.d.ts +71 -0
- package/output/core/converters/Pattern.js +302 -0
- package/output/core/dispatch.d.ts +52 -0
- package/output/core/dispatch.js +26 -0
- package/output/core/errors.d.ts +316 -0
- package/output/core/errors.js +349 -0
- package/output/core/fullFunctions.d.ts +7 -0
- package/output/core/fullFunctions.js +31 -0
- package/output/core/functions/bigint/bigint.d.ts +133 -0
- package/output/core/functions/bigint/bigint.js +444 -0
- package/output/core/functions/bigint/primeFactor.d.ts +51 -0
- package/output/core/functions/bigint/primeFactor.js +267 -0
- package/output/core/functions/bigint/primes.d.ts +1 -0
- package/output/core/functions/bigint/primes.js +11 -0
- package/output/core/functions/build/definitions.d.ts +12 -0
- package/output/core/functions/build/definitions.js +139 -0
- package/output/core/functions/build/index.d.ts +32 -0
- package/output/core/functions/build/index.js +136 -0
- package/output/core/functions/complex.d.ts +90 -0
- package/output/core/functions/complex.dispatch.d.ts +1 -0
- package/output/core/functions/complex.dispatch.js +16 -0
- package/output/core/functions/complex.js +482 -0
- package/output/core/functions/decimal.d.ts +24 -0
- package/output/core/functions/decimal.js +665 -0
- package/output/core/functions/expand/expand.d.ts +42 -0
- package/output/core/functions/expand/expand.js +376 -0
- package/output/core/functions/fresnelNumeric.d.ts +12 -0
- package/output/core/functions/fresnelNumeric.js +123 -0
- package/output/core/functions/numeric.d.ts +140 -0
- package/output/core/functions/numeric.js +790 -0
- package/output/core/functions/rationalNormalization.d.ts +11 -0
- package/output/core/functions/rationalNormalization.js +117 -0
- package/output/core/functions/setFunction.d.ts +19 -0
- package/output/core/functions/setFunction.js +75 -0
- package/output/core/functions/string.d.ts +26 -0
- package/output/core/functions/string.js +102 -0
- package/output/core/functions/subst.d.ts +90 -0
- package/output/core/functions/subst.js +506 -0
- package/output/core/functions/utils.d.ts +24 -0
- package/output/core/functions/utils.js +51 -0
- package/output/core/parserFunctions.d.ts +7 -0
- package/output/core/parserFunctions.js +25 -0
- package/output/core/types.d.ts +48 -0
- package/output/core/types.js +2 -0
- package/output/index.d.ts +359 -0
- package/output/index.js +739 -0
- package/output/math/defint/defint.d.ts +18 -0
- package/output/math/defint/defint.js +60 -0
- package/output/math/defint/defintDecimal.d.ts +37 -0
- package/output/math/defint/defintDecimal.js +321 -0
- package/output/math/defint/defintNative.d.ts +57 -0
- package/output/math/defint/defintNative.js +281 -0
- package/output/math/dispatch.d.ts +1 -0
- package/output/math/dispatch.js +101 -0
- package/output/math/geometry.d.ts +12 -0
- package/output/math/geometry.js +55 -0
- package/output/math/math.d.ts +695 -0
- package/output/math/math.js +1955 -0
- package/output/math/trig.d.ts +518 -0
- package/output/math/trig.js +1444 -0
- package/output/math/trunc.d.ts +19 -0
- package/output/math/trunc.js +36 -0
- package/output/math/utils.d.ts +66 -0
- package/output/math/utils.js +219 -0
- package/output/solve/classes/DecimalMatrix.d.ts +17 -0
- package/output/solve/classes/DecimalMatrix.js +86 -0
- package/output/solve/classes/FunctionSolver.d.ts +135 -0
- package/output/solve/classes/FunctionSolver.js +433 -0
- package/output/solve/classes/MultivariateSolver.d.ts +84 -0
- package/output/solve/classes/MultivariateSolver.js +240 -0
- package/output/solve/classes/PolynomialSolver.d.ts +104 -0
- package/output/solve/classes/PolynomialSolver.js +492 -0
- package/output/solve/classes/SolutionSet.d.ts +172 -0
- package/output/solve/classes/SolutionSet.js +434 -0
- package/output/solve/classes/Solver.d.ts +17 -0
- package/output/solve/classes/Solver.js +132 -0
- package/output/solve/classes/SymbolicSolver.d.ts +74 -0
- package/output/solve/classes/SymbolicSolver.js +601 -0
- package/output/solve/dispatch.d.ts +1 -0
- package/output/solve/dispatch.js +13 -0
- package/output/solve/linsolve.d.ts +53 -0
- package/output/solve/linsolve.js +233 -0
- package/output/solve/solve.d.ts +44 -0
- package/output/solve/solve.js +368 -0
- package/output/solve/solveSystem.d.ts +31 -0
- package/output/solve/solveSystem.js +266 -0
- package/output/solve/utils.d.ts +10 -0
- package/output/solve/utils.js +58 -0
- package/output/utils/array.d.ts +42 -0
- package/output/utils/array.js +98 -0
- package/output/utils/debug.d.ts +131 -0
- package/output/utils/debug.js +296 -0
- package/output/utils/decimal.d.ts +3 -0
- package/output/utils/decimal.js +16 -0
- package/output/utils/numeric.d.ts +14 -0
- package/output/utils/numeric.js +51 -0
- package/output/utils/object.d.ts +26 -0
- package/output/utils/object.js +56 -0
- package/package.json +178 -57
- package/.travis.yml +0 -3
- package/Algebra.js +0 -4568
- package/CODE_OF_CONDUCT.md +0 -46
- package/CONTRIBUTING.md +0 -14
- package/Calculus.js +0 -2675
- package/Extra.js +0 -622
- package/Solve.js +0 -1783
- package/all.js +0 -16
- package/all.min.js +0 -1
- package/gulpfile.js +0 -16
- package/index.html +0 -158
- package/license.txt +0 -19
- package/nerdamer.core.js +0 -12510
- package/spec/LaTeX.spec.js +0 -302
- package/spec/TeXConvert.spec.js +0 -8
- package/spec/algebra.spec.js +0 -287
- package/spec/basic_parser.spec.js +0 -134
- package/spec/build.spec.js +0 -131
- package/spec/calculus.spec.js +0 -183
- package/spec/core.spec.js +0 -2970
- package/spec/extra.spec.js +0 -54
- package/spec/solve.spec.js +0 -126
- package/spec/support/jasmine.json +0 -11
- package/spec/support/utils.js +0 -42
- package/spec/text.spec.js +0 -132
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module arith
|
|
4
|
+
*
|
|
5
|
+
* Low-level integer and modular arithmetic helpers used throughout the library.
|
|
6
|
+
*
|
|
7
|
+
* - All integer arithmetic is done with `bigint`.
|
|
8
|
+
* - Modular routines assume a prime modulus `p` when inverses are required.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.GcdBudgetExceededError = exports.PrimeSelectionError = void 0;
|
|
12
|
+
exports.abs = abs;
|
|
13
|
+
exports.gcd = gcd;
|
|
14
|
+
exports.pow = pow;
|
|
15
|
+
exports.powN = powN;
|
|
16
|
+
exports.bigIntSqrt = bigIntSqrt;
|
|
17
|
+
exports.intNthRootExact = intNthRootExact;
|
|
18
|
+
exports.getDivisors = getDivisors;
|
|
19
|
+
exports.modNorm = modNorm;
|
|
20
|
+
exports.modSymmetric = modSymmetric;
|
|
21
|
+
exports.modInv = modInv;
|
|
22
|
+
exports.contentBigint = contentBigint;
|
|
23
|
+
exports.bigintBitLength = bigintBitLength;
|
|
24
|
+
exports.nextPrime32 = nextPrime32;
|
|
25
|
+
const errors_1 = require("../../core/errors");
|
|
26
|
+
/**
|
|
27
|
+
* Shared integer + modular arithmetic primitives used across Zippel GCD and
|
|
28
|
+
* multivariate factorization.
|
|
29
|
+
*
|
|
30
|
+
* Design goals:
|
|
31
|
+
* - BigInt-only arithmetic for coefficient paths.
|
|
32
|
+
* - Small, stable surface area: use `abs`, `gcd`, `pow`.
|
|
33
|
+
*/
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// Integer arithmetic
|
|
36
|
+
// ============================================================================
|
|
37
|
+
/** Absolute value for BigInt. */
|
|
38
|
+
function abs(a) {
|
|
39
|
+
return a < 0n ? -a : a;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Euclidean GCD for BigInt.
|
|
43
|
+
*
|
|
44
|
+
* Returns a nonnegative gcd. gcd(0,0) = 0.
|
|
45
|
+
*/
|
|
46
|
+
function gcd(a, b) {
|
|
47
|
+
a = abs(a);
|
|
48
|
+
b = abs(b);
|
|
49
|
+
while (b !== 0n) {
|
|
50
|
+
[a, b] = [b, a % b];
|
|
51
|
+
}
|
|
52
|
+
return a;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Integer exponentiation for BigInt with a nonnegative exponent.
|
|
56
|
+
*
|
|
57
|
+
* This is NOT modular exponentiation (see {@link modPow}).
|
|
58
|
+
*/
|
|
59
|
+
function pow(base, exp) {
|
|
60
|
+
if (exp < 0n) {
|
|
61
|
+
throw new Error((0, errors_1.message)('arithPowNegativeExponent'));
|
|
62
|
+
}
|
|
63
|
+
let b = base;
|
|
64
|
+
let e = exp;
|
|
65
|
+
let r = 1n;
|
|
66
|
+
while (e > 0n) {
|
|
67
|
+
if (e & 1n) {
|
|
68
|
+
r *= b;
|
|
69
|
+
}
|
|
70
|
+
b *= b;
|
|
71
|
+
e >>= 1n;
|
|
72
|
+
}
|
|
73
|
+
return r;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Integer exponentiation for BigInt with a small nonnegative JS number exponent.
|
|
77
|
+
*
|
|
78
|
+
* Convenience wrapper used throughout factorization code where exponents are known
|
|
79
|
+
* to fit in a number.
|
|
80
|
+
*/
|
|
81
|
+
function powN(base, exp) {
|
|
82
|
+
if (!Number.isInteger(exp) || exp < 0) {
|
|
83
|
+
throw new Error((0, errors_1.message)('arithPowNNonnegativeInteger'));
|
|
84
|
+
}
|
|
85
|
+
return pow(base, BigInt(exp));
|
|
86
|
+
}
|
|
87
|
+
// ============================================================================
|
|
88
|
+
// Number theory helpers (BigInt)
|
|
89
|
+
// ============================================================================
|
|
90
|
+
/**
|
|
91
|
+
* Integer square root: floor(sqrt(n)) for n >= 0.
|
|
92
|
+
*/
|
|
93
|
+
function bigIntSqrt(n) {
|
|
94
|
+
if (n < 0n) {
|
|
95
|
+
throw new Error((0, errors_1.message)('arithBigIntSqrtNegative'));
|
|
96
|
+
}
|
|
97
|
+
if (n < 2n) {
|
|
98
|
+
return n;
|
|
99
|
+
}
|
|
100
|
+
// Newton iteration.
|
|
101
|
+
let x0 = n;
|
|
102
|
+
let x1 = (x0 + 1n) >> 1n;
|
|
103
|
+
while (x1 < x0) {
|
|
104
|
+
x0 = x1;
|
|
105
|
+
x1 = (x1 + n / x1) >> 1n;
|
|
106
|
+
}
|
|
107
|
+
return x0;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Exact n-th root if it exists.
|
|
111
|
+
* Returns r such that r^n === value, or null if value is not a perfect n-th power.
|
|
112
|
+
*/
|
|
113
|
+
function intNthRootExact(value, n) {
|
|
114
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
115
|
+
throw new Error((0, errors_1.message)('arithNthRootPositiveInteger'));
|
|
116
|
+
}
|
|
117
|
+
if (value < 0n) {
|
|
118
|
+
// Only odd roots exist for negative values.
|
|
119
|
+
if ((n & 1) === 0) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const r = intNthRootExact(-value, n);
|
|
123
|
+
return r === null ? null : -r;
|
|
124
|
+
}
|
|
125
|
+
if (value === 0n) {
|
|
126
|
+
return 0n;
|
|
127
|
+
}
|
|
128
|
+
if (value === 1n) {
|
|
129
|
+
return 1n;
|
|
130
|
+
}
|
|
131
|
+
// Exponential search for an upper bound.
|
|
132
|
+
let lo = 0n;
|
|
133
|
+
let hi = 1n;
|
|
134
|
+
while (powN(hi, n) < value) {
|
|
135
|
+
hi <<= 1n;
|
|
136
|
+
}
|
|
137
|
+
// Binary search.
|
|
138
|
+
while (lo + 1n < hi) {
|
|
139
|
+
const mid = (lo + hi) >> 1n;
|
|
140
|
+
const p = powN(mid, n);
|
|
141
|
+
if (p === value) {
|
|
142
|
+
return mid;
|
|
143
|
+
}
|
|
144
|
+
if (p < value) {
|
|
145
|
+
lo = mid;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
hi = mid;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return powN(hi, n) === value ? hi : powN(lo, n) === value ? lo : null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Return positive divisors of n (n > 0) by trial division.
|
|
155
|
+
*
|
|
156
|
+
* NOTE: This is intended for small integers used in factoring heuristics.
|
|
157
|
+
*/
|
|
158
|
+
function getDivisors(n) {
|
|
159
|
+
if (n <= 0n) {
|
|
160
|
+
throw new Error((0, errors_1.message)('arithDivisorsPositive'));
|
|
161
|
+
}
|
|
162
|
+
const out = [];
|
|
163
|
+
const r = bigIntSqrt(n);
|
|
164
|
+
for (let d = 1n; d <= r; d++) {
|
|
165
|
+
if (n % d === 0n) {
|
|
166
|
+
out.push(d);
|
|
167
|
+
const q = n / d;
|
|
168
|
+
if (q !== d) {
|
|
169
|
+
out.push(q);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
out.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Extended Euclidean algorithm.
|
|
178
|
+
*
|
|
179
|
+
* Returns `{ g, x, y }` such that `a*x + b*y = g = gcd(a,b)` (up to sign).
|
|
180
|
+
*/
|
|
181
|
+
function egcd(a, b) {
|
|
182
|
+
let old_r = a, r = b;
|
|
183
|
+
let old_s = 1n, s = 0n;
|
|
184
|
+
let old_t = 0n, t = 1n;
|
|
185
|
+
while (r !== 0n) {
|
|
186
|
+
const q = old_r / r;
|
|
187
|
+
[old_r, r] = [r, old_r - q * r];
|
|
188
|
+
[old_s, s] = [s, old_s - q * s];
|
|
189
|
+
[old_t, t] = [t, old_t - q * t];
|
|
190
|
+
}
|
|
191
|
+
return { g: old_r, x: old_s, y: old_t };
|
|
192
|
+
}
|
|
193
|
+
// ============================================================================
|
|
194
|
+
// Modular arithmetic
|
|
195
|
+
// ============================================================================
|
|
196
|
+
/** Normalize a into the range [0, |p|). Throws if p is zero. */
|
|
197
|
+
function modNorm(a, p) {
|
|
198
|
+
if (p === 0n) {
|
|
199
|
+
throw new Error((0, errors_1.message)('arithModNormNonzeroModulus'));
|
|
200
|
+
}
|
|
201
|
+
const m = abs(p);
|
|
202
|
+
const r = a % m;
|
|
203
|
+
return r < 0n ? r + m : r;
|
|
204
|
+
}
|
|
205
|
+
/** Map a to the symmetric residue class (-|p|/2, |p|/2]. */
|
|
206
|
+
function modSymmetric(a, p) {
|
|
207
|
+
if (p === 0n) {
|
|
208
|
+
throw new Error((0, errors_1.message)('arithModSymmetricNonzeroModulus'));
|
|
209
|
+
}
|
|
210
|
+
const m = abs(p);
|
|
211
|
+
const r = modNorm(a, m);
|
|
212
|
+
const half = m / 2n;
|
|
213
|
+
return r > half ? r - m : r;
|
|
214
|
+
}
|
|
215
|
+
/** Modular multiplicative inverse of a mod p, where gcd(a,p)=1. */
|
|
216
|
+
function modInv(a, p) {
|
|
217
|
+
const aa = modNorm(a, p);
|
|
218
|
+
if (aa === 0n) {
|
|
219
|
+
throw new Error((0, errors_1.message)('arithModInvZeroNoninvertible'));
|
|
220
|
+
}
|
|
221
|
+
const { g, x } = egcd(aa, p);
|
|
222
|
+
if (g !== 1n && g !== -1n) {
|
|
223
|
+
throw new Error((0, errors_1.message)('arithModInvNoninvertible'));
|
|
224
|
+
}
|
|
225
|
+
return modNorm(x, p);
|
|
226
|
+
}
|
|
227
|
+
// ============================================================================
|
|
228
|
+
// Coefficient utilities
|
|
229
|
+
// ============================================================================
|
|
230
|
+
/**
|
|
231
|
+
* Content (GCD of coefficients) for an iterable of bigint coefficients.
|
|
232
|
+
* Returns 0n for the all-zero collection.
|
|
233
|
+
*/
|
|
234
|
+
function contentBigint(coeffs) {
|
|
235
|
+
let g0 = 0n;
|
|
236
|
+
for (const c of coeffs) {
|
|
237
|
+
const a = abs(c);
|
|
238
|
+
g0 = gcd(g0, a);
|
|
239
|
+
if (g0 === 1n) {
|
|
240
|
+
return 1n;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return g0;
|
|
244
|
+
}
|
|
245
|
+
// ---------------------------------------------------------------------------
|
|
246
|
+
// Univariate polynomial arithmetic over F_p (coeff arrays low->high)
|
|
247
|
+
// ---------------------------------------------------------------------------
|
|
248
|
+
// ============================================================================
|
|
249
|
+
// Misc small utilities
|
|
250
|
+
// ============================================================================
|
|
251
|
+
/** Bit-length of a bigint (0 -> 0). */
|
|
252
|
+
function bigintBitLength(a) {
|
|
253
|
+
if (a < 0n) {
|
|
254
|
+
a = -a;
|
|
255
|
+
}
|
|
256
|
+
let bits = 0;
|
|
257
|
+
while (a > 0n) {
|
|
258
|
+
bits++;
|
|
259
|
+
a >>= 1n;
|
|
260
|
+
}
|
|
261
|
+
return bits;
|
|
262
|
+
}
|
|
263
|
+
/** Simple primality test for 32-bit positive integers. */
|
|
264
|
+
function isPrime32(n) {
|
|
265
|
+
if (!Number.isInteger(n) || n < 2) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
if (n === 2 || n === 3) {
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
if ((n & 1) === 0) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
if (n % 3 === 0) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
const limit = Math.floor(Math.sqrt(n));
|
|
278
|
+
for (let d = 5; d <= limit; d += 6) {
|
|
279
|
+
if (n % d === 0 || n % (d + 2) === 0) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
/** Next prime >= start. */
|
|
286
|
+
function nextPrime32(start) {
|
|
287
|
+
let n = start;
|
|
288
|
+
if (n <= 2) {
|
|
289
|
+
return 2;
|
|
290
|
+
}
|
|
291
|
+
if ((n & 1) === 0) {
|
|
292
|
+
n++;
|
|
293
|
+
}
|
|
294
|
+
while (!isPrime32(n)) {
|
|
295
|
+
n += 2;
|
|
296
|
+
}
|
|
297
|
+
return n;
|
|
298
|
+
}
|
|
299
|
+
class AlgebraError extends Error {
|
|
300
|
+
/** Additional structured debugging info. Always present (possibly empty). */
|
|
301
|
+
details;
|
|
302
|
+
phase;
|
|
303
|
+
constructor(message, phase = 'unknown', details) {
|
|
304
|
+
super(message);
|
|
305
|
+
this.name = this.constructor.name;
|
|
306
|
+
this.phase = phase;
|
|
307
|
+
this.details = details ?? {};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
class PrimeSelectionError extends AlgebraError {
|
|
311
|
+
constructor(message, details) {
|
|
312
|
+
super(message, 'prime-selection', details);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
exports.PrimeSelectionError = PrimeSelectionError;
|
|
316
|
+
/**
|
|
317
|
+
* Thrown when Zippel-style multivariate GCD exceeds its specialization / interpolation budget.
|
|
318
|
+
*/
|
|
319
|
+
class GcdBudgetExceededError extends AlgebraError {
|
|
320
|
+
constructor(message, details) {
|
|
321
|
+
super(message, 'budget', details);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
exports.GcdBudgetExceededError = GcdBudgetExceededError;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module groebner
|
|
3
|
+
*
|
|
4
|
+
* Gröbner basis computation, elimination, ideal membership, and solving.
|
|
5
|
+
*
|
|
6
|
+
* This implementation is a Buchberger-style engine with:
|
|
7
|
+
* - configurable monomial order (LEX, GRLEX, GREVLEX)
|
|
8
|
+
* - sugar-strategy pair selection for performance
|
|
9
|
+
* - optional budgets and stats
|
|
10
|
+
* - fraction-free normal form helpers
|
|
11
|
+
* - elimination ideals
|
|
12
|
+
* - ideal membership testing
|
|
13
|
+
* - triangular back-substitution solver
|
|
14
|
+
*
|
|
15
|
+
* External references consulted:
|
|
16
|
+
* - SymPy Gröbner basis implementation:
|
|
17
|
+
* https://github.com/sympy/sympy/blob/120ee85f346f6292b763cc195afda4f907260d4a/sympy/polys/groebnertools.py
|
|
18
|
+
* - Giovini, Mora, Niesi, Robbiano, Traverso, "One Sugar Cube, Please":
|
|
19
|
+
* https://doi.org/10.1145/120694.120701
|
|
20
|
+
* - Bigatti, Caboara, Robbiano, "Computing inhomogeneous Gröbner bases":
|
|
21
|
+
* https://doi.org/10.1016/j.jsc.2010.10.002
|
|
22
|
+
*/
|
|
23
|
+
import { SparsePolynomial } from '../../core/classes/polynomial/SparsePolynomial';
|
|
24
|
+
/** Monomial order used for leading terms, pair processing, and reduction. */
|
|
25
|
+
export type MonomialOrder = 'LEX' | 'GRLEX' | 'GREVLEX';
|
|
26
|
+
/** Deterministic work counters captured when a Groebner resource budget is exceeded. */
|
|
27
|
+
export type GroebnerStats = {
|
|
28
|
+
/** Critical pairs removed from the processing queue. */
|
|
29
|
+
pairsPopped: number;
|
|
30
|
+
/** Pairs skipped because their leading monomials are relatively prime. */
|
|
31
|
+
pairsSkippedProduct: number;
|
|
32
|
+
/** Pairs skipped by Buchberger's chain criterion. */
|
|
33
|
+
pairsSkippedChain: number;
|
|
34
|
+
/** Processed pairs whose reduced S-polynomial was zero. */
|
|
35
|
+
pairsReducedToZero: number;
|
|
36
|
+
/** Nonzero reduced S-polynomials appended to the working basis. */
|
|
37
|
+
basisAppends: number;
|
|
38
|
+
};
|
|
39
|
+
/** Controls monomial order, result normalization, pair strategy, and deterministic budgets. */
|
|
40
|
+
export type GroebnerBasisOptions = {
|
|
41
|
+
/** Monomial order; defaults to `LEX`. Variable priority follows exponent index order. */
|
|
42
|
+
order?: MonomialOrder;
|
|
43
|
+
/**
|
|
44
|
+
* If true (default), return a reduced/normalized basis (canonicalize/interreduce/primitive normalize).
|
|
45
|
+
* If false, returns the raw Buchberger basis as produced by the pair loop.
|
|
46
|
+
*/
|
|
47
|
+
reduced?: boolean;
|
|
48
|
+
/** Hard cap on Buchberger pair iterations (deterministic, not time-based). */
|
|
49
|
+
maxPairsPopped?: number;
|
|
50
|
+
/** Hard cap on basis size (including initial generators). */
|
|
51
|
+
maxBasisSize?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Pair selection strategy.
|
|
54
|
+
* - 'sugar' (default): use sugar degree heuristic for better performance
|
|
55
|
+
* - 'fifo': simple first-in first-out (original behavior)
|
|
56
|
+
*/
|
|
57
|
+
strategy?: 'sugar' | 'fifo';
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Thrown when a Groebner pair-count or basis-size budget is exhausted.
|
|
61
|
+
*
|
|
62
|
+
* {@link GroebnerBudgetExceeded.stats} is the live counter snapshot from the aborted
|
|
63
|
+
* computation. The error keeps that object by reference and does not freeze it.
|
|
64
|
+
*/
|
|
65
|
+
export declare class GroebnerBudgetExceeded extends Error {
|
|
66
|
+
/** Work counters at the point the budget was exceeded. */
|
|
67
|
+
readonly stats: GroebnerStats;
|
|
68
|
+
/**
|
|
69
|
+
* @param message - Human-readable budget condition.
|
|
70
|
+
* @param stats - Counter snapshot retained on the error.
|
|
71
|
+
*/
|
|
72
|
+
constructor(message: string, stats: GroebnerStats);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Computes a Groebner basis for exact sparse integer polynomials.
|
|
76
|
+
*
|
|
77
|
+
* The input polynomials must belong to the same ring. With `reduced: true`, the
|
|
78
|
+
* basis is interreduced, coefficient content is removed, leading signs are normalized,
|
|
79
|
+
* and exact monic normalization is applied when possible. Results are sorted
|
|
80
|
+
* deterministically and the supplied polynomials are not modified.
|
|
81
|
+
*
|
|
82
|
+
* @param polys - Ideal generators in one sparse polynomial ring.
|
|
83
|
+
* @param order - Monomial order; defaults to `LEX`.
|
|
84
|
+
* @param reduced - Return the normalized/interreduced basis; defaults to `true`.
|
|
85
|
+
* @returns New sparse basis polynomials in deterministic presentation order.
|
|
86
|
+
*/
|
|
87
|
+
export declare function Groebner(polys: readonly SparsePolynomial[], order?: MonomialOrder, reduced?: boolean): SparsePolynomial[];
|
|
88
|
+
/**
|
|
89
|
+
* Computes a Groebner basis with ordering, strategy, and budget control.
|
|
90
|
+
*
|
|
91
|
+
* @param polys - Exact sparse integer-coefficient generators in one ring.
|
|
92
|
+
* @param opts - Ordering, normalization, pair-selection, and deterministic budget options.
|
|
93
|
+
* @returns New basis polynomials. Work statistics are exposed only when a budget is
|
|
94
|
+
* exceeded; successful calls return the basis itself.
|
|
95
|
+
* @throws {@link GroebnerBudgetExceeded} Thrown after a configured pair-count or
|
|
96
|
+
* basis-size limit is exceeded.
|
|
97
|
+
*/
|
|
98
|
+
export declare function groebnerBasisWithOptions(polys: readonly SparsePolynomial[], opts?: GroebnerBasisOptions): SparsePolynomial[];
|
|
99
|
+
/**
|
|
100
|
+
* Computes the part of the ideal that lies in the polynomial ring generated by `keepVars`.
|
|
101
|
+
*
|
|
102
|
+
* @param polys - Exact integer-coefficient generators.
|
|
103
|
+
* @param vars - All variables in exponent-index order. Variables to eliminate must
|
|
104
|
+
* precede retained variables for lexicographic elimination.
|
|
105
|
+
* @param keepVars - Variables to retain, expected to be a suffix of `vars`.
|
|
106
|
+
* @param opts - Reduction, pair strategy, and budgets; order is always `LEX`.
|
|
107
|
+
* @returns New basis polynomials involving only retained variables.
|
|
108
|
+
* @throws {@link GroebnerBudgetExceeded} Thrown when a configured budget is exceeded.
|
|
109
|
+
*/
|
|
110
|
+
export declare function eliminate(polys: readonly SparsePolynomial[], vars: readonly string[], keepVars: readonly string[], opts?: Omit<GroebnerBasisOptions, 'order'>): SparsePolynomial[];
|
|
111
|
+
/**
|
|
112
|
+
* Tests exact ideal membership by reducing against a computed Groebner basis.
|
|
113
|
+
*
|
|
114
|
+
* @param f - Polynomial to test.
|
|
115
|
+
* @param polys - Exact integer-coefficient ideal generators.
|
|
116
|
+
* @param order - Monomial order; defaults to `LEX`.
|
|
117
|
+
* @param opts - Pair strategy and deterministic budgets.
|
|
118
|
+
* @returns Whether the normal form of `f` is zero.
|
|
119
|
+
* @throws {@link GroebnerBudgetExceeded} Thrown when basis computation exceeds a budget.
|
|
120
|
+
*/
|
|
121
|
+
export declare function idealMembership(f: SparsePolynomial, polys: readonly SparsePolynomial[], order?: MonomialOrder, opts?: Omit<GroebnerBasisOptions, 'order' | 'reduced'>): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Reduces a polynomial by a basis or arbitrary reducer set using fraction-free arithmetic.
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* This does not compute or verify a Groebner basis. The result is a canonical ideal
|
|
127
|
+
* normal form only when `basis` is already a basis for the selected order.
|
|
128
|
+
*
|
|
129
|
+
* @param f - Polynomial to reduce.
|
|
130
|
+
* @param basis - Reducers, normally a Groebner basis.
|
|
131
|
+
* @param order - Monomial order used to select leading terms.
|
|
132
|
+
* @returns The primitive-normalized remainder.
|
|
133
|
+
*/
|
|
134
|
+
export declare function reduceByBasis(f: SparsePolynomial, basis: readonly SparsePolynomial[], order?: MonomialOrder): SparsePolynomial;
|
|
135
|
+
/**
|
|
136
|
+
* Maps each solved variable to a reduced rational numerator/denominator pair.
|
|
137
|
+
*
|
|
138
|
+
* Only rational coordinates discovered by triangular back-substitution are represented.
|
|
139
|
+
*/
|
|
140
|
+
export type RationalSolution = Map<string, {
|
|
141
|
+
n: bigint;
|
|
142
|
+
d: bigint;
|
|
143
|
+
}>;
|
|
144
|
+
/**
|
|
145
|
+
* Solves a zero-dimensional polynomial system for rational coordinates.
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* This is the low-level exact solver used with the Groebner representation, not the
|
|
149
|
+
* ordinary expression solver. It computes a reduced lexicographic basis, walks variables
|
|
150
|
+
* from least to most significant, applies the Rational Root Theorem to univariate
|
|
151
|
+
* constraints, and substitutes each partial assignment into its own basis copy.
|
|
152
|
+
* Irrational and complex roots are outside this routine's result set.
|
|
153
|
+
*
|
|
154
|
+
* @param polys - Exact integer-coefficient system generators.
|
|
155
|
+
* @param vars - Variables in lexicographic elimination order, most significant first.
|
|
156
|
+
* @param opts - Pair strategy and budgets forwarded to basis computation.
|
|
157
|
+
* @returns New solution maps. An empty array can mean inconsistency, no rational roots,
|
|
158
|
+
* or a non-finite/unsupported triangular result; these cases are not distinguished.
|
|
159
|
+
* @throws {@link GroebnerBudgetExceeded} Thrown when basis computation exceeds a budget.
|
|
160
|
+
*/
|
|
161
|
+
export declare function solve(polys: readonly SparsePolynomial[], vars: readonly string[], opts?: Omit<GroebnerBasisOptions, 'order' | 'reduced'>): RationalSolution[];
|