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.
- package/LICENSE.md +184 -0
- package/README.md +293 -312
- 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 +1960 -0
- package/index.d.ts +10 -426
- package/output/algebra/adapters.d.ts +33 -0
- package/output/algebra/adapters.js +109 -0
- package/output/algebra/algorithms/arith.d.ts +84 -0
- package/output/algebra/algorithms/arith.js +323 -0
- package/output/algebra/algorithms/factor.d.ts +3 -0
- package/output/algebra/algorithms/factor.js +5 -0
- package/output/algebra/algorithms/factorMultivariate.d.ts +23 -0
- package/output/algebra/algorithms/factorMultivariate.js +2393 -0
- package/output/algebra/algorithms/factorUnivariate.d.ts +72 -0
- package/output/algebra/algorithms/factorUnivariate.js +1072 -0
- package/output/algebra/algorithms/gcd.d.ts +22 -0
- package/output/algebra/algorithms/gcd.js +690 -0
- package/output/algebra/algorithms/groebnerBase.d.ts +157 -0
- package/output/algebra/algorithms/groebnerBase.js +1166 -0
- package/output/algebra/algorithms/multiPoly/MultiPoly.d.ts +137 -0
- package/output/algebra/algorithms/multiPoly/MultiPoly.js +346 -0
- package/output/algebra/algorithms/poly.d.ts +228 -0
- package/output/algebra/algorithms/poly.js +1299 -0
- package/output/algebra/algorithms/rational.d.ts +17 -0
- package/output/algebra/algorithms/rational.js +115 -0
- package/output/algebra/factor/factor.d.ts +62 -0
- package/output/algebra/factor/factor.js +158 -0
- package/output/algebra/gcd/gcd.d.ts +29 -0
- package/output/algebra/gcd/gcd.js +141 -0
- package/output/algebra/groebner.d.ts +21 -0
- package/output/algebra/groebner.js +42 -0
- package/output/algebra/partfrac.d.ts +19 -0
- package/output/algebra/partfrac.js +398 -0
- package/output/algebra/polynomialize.d.ts +20 -0
- package/output/algebra/polynomialize.js +24 -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 +228 -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 +7 -0
- package/output/api/advanced.js +18 -0
- package/output/api/algebra.d.ts +17 -0
- package/output/api/algebra.js +32 -0
- package/output/api/assumptions.d.ts +4 -0
- package/output/api/assumptions.js +11 -0
- package/output/api/calculus.d.ts +9 -0
- package/output/api/calculus.js +21 -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/parser.d.ts +85 -0
- package/output/api/parser.js +16 -0
- package/output/api/solve.d.ts +10 -0
- package/output/api/solve.js +16 -0
- package/output/api/structures.d.ts +10 -0
- package/output/api/structures.js +22 -0
- package/output/calculus/derivative/diff.d.ts +30 -0
- package/output/calculus/derivative/diff.js +238 -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/adapters.d.ts +18 -0
- package/output/core/adapters.js +40 -0
- package/output/core/classes/assumption/Assumption.d.ts +218 -0
- package/output/core/classes/assumption/Assumption.js +605 -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/collection/Collection.d.ts +107 -0
- package/output/core/classes/collection/Collection.js +231 -0
- package/output/core/classes/complex/Complex.d.ts +99 -0
- package/output/core/classes/complex/Complex.js +135 -0
- package/output/core/classes/decimalSet/DecimalSet.d.ts +226 -0
- package/output/core/classes/decimalSet/DecimalSet.js +453 -0
- package/output/core/classes/dictionary/Dictionary.d.ts +102 -0
- package/output/core/classes/dictionary/Dictionary.js +213 -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 +198 -0
- package/output/core/classes/expression/Expression.d.ts +1674 -0
- package/output/core/classes/expression/Expression.js +2332 -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 +45 -0
- package/output/core/classes/expression/format.js +217 -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 +52 -0
- package/output/core/classes/expression/utils.js +189 -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 +889 -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/functions.d.ts +26 -0
- package/output/core/classes/matrix/functions.js +52 -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 +480 -0
- package/output/core/classes/parser/Parser.js +1812 -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 +160 -0
- package/output/core/classes/parser/constants.js +227 -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 +238 -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 +461 -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 +430 -0
- package/output/core/classes/parser/operations/multiply.d.ts +11 -0
- package/output/core/classes/parser/operations/multiply.js +321 -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 +35 -0
- package/output/core/classes/parser/preprocess.d.ts +14 -0
- package/output/core/classes/parser/preprocess.js +259 -0
- package/output/core/classes/parser/scripting/controlFlow.d.ts +121 -0
- package/output/core/classes/parser/scripting/controlFlow.js +355 -0
- package/output/core/classes/parser/scripting/evaluate.d.ts +10 -0
- package/output/core/classes/parser/scripting/evaluate.js +112 -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 +35 -0
- package/output/core/classes/parser/scripting/scope.js +155 -0
- package/output/core/classes/parser/types.d.ts +125 -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 +500 -0
- package/output/core/classes/polynomial/Polynomial.js +1149 -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/functions.d.ts +69 -0
- package/output/core/classes/polynomial/functions.js +126 -0
- package/output/core/classes/polynomial/utils.d.ts +62 -0
- package/output/core/classes/polynomial/utils.js +206 -0
- package/output/core/classes/rational/Rational.d.ts +504 -0
- package/output/core/classes/rational/Rational.js +779 -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 +179 -0
- package/output/core/classes/valuesSet/ValuesSet.js +381 -0
- package/output/core/classes/vector/Vector.d.ts +222 -0
- package/output/core/classes/vector/Vector.js +497 -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 +140 -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 +63 -0
- package/output/core/common/common.js +279 -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 +802 -0
- package/output/core/converters/Pattern.d.ts +71 -0
- package/output/core/converters/Pattern.js +302 -0
- package/output/core/dispatch.d.ts +34 -0
- package/output/core/dispatch.js +304 -0
- package/output/core/errors.d.ts +531 -0
- package/output/core/errors.js +621 -0
- package/output/core/functions/bigint/bigint.d.ts +121 -0
- package/output/core/functions/bigint/bigint.js +392 -0
- package/output/core/functions/bigint/primeFactor.d.ts +49 -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 +133 -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.js +482 -0
- package/output/core/functions/decimal.d.ts +24 -0
- package/output/core/functions/decimal.js +664 -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 +101 -0
- package/output/core/functions/subst.d.ts +90 -0
- package/output/core/functions/subst.js +498 -0
- package/output/core/functions/utils.d.ts +24 -0
- package/output/core/functions/utils.js +51 -0
- package/output/core/types.d.ts +48 -0
- package/output/core/types.js +2 -0
- package/output/index.d.ts +339 -0
- package/output/index.js +715 -0
- package/output/math/defint/defintDecimal.d.ts +37 -0
- package/output/math/defint/defintDecimal.js +320 -0
- package/output/math/defint/defintNative.d.ts +57 -0
- package/output/math/defint/defintNative.js +292 -0
- package/output/math/geometry.d.ts +8 -0
- package/output/math/geometry.js +32 -0
- package/output/math/math.d.ts +655 -0
- package/output/math/math.js +1811 -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 +60 -0
- package/output/math/utils.js +180 -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 +85 -0
- package/output/solve/classes/PolynomialSolver.js +292 -0
- package/output/solve/classes/SolutionSet.d.ts +153 -0
- package/output/solve/classes/SolutionSet.js +357 -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/linsolve.d.ts +51 -0
- package/output/solve/linsolve.js +225 -0
- package/output/solve/solve.d.ts +34 -0
- package/output/solve/solve.js +260 -0
- package/output/solve/solveSystem.d.ts +31 -0
- package/output/solve/solveSystem.js +290 -0
- package/output/solve/utils.d.ts +9 -0
- package/output/solve/utils.js +62 -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 +295 -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 +213 -57
- package/.travis.yml +0 -3
- package/Algebra.js +0 -4568
- package/BREAKING_CHANGES.md +0 -5
- 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,19 @@
|
|
|
1
|
+
import { Expression } from '../core/classes/expression/Expression';
|
|
2
|
+
import type { ExpressionInput } from '../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* Truncates a number toward zero.
|
|
5
|
+
*
|
|
6
|
+
* Numeric inputs discard their fractional part without changing the sign of the
|
|
7
|
+
* integer portion. Symbolic inputs remain unevaluated.
|
|
8
|
+
*
|
|
9
|
+
* @param x - The expression to truncate.
|
|
10
|
+
* @returns The integer portion of `x`, or symbolic `trunc(x)`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* trunc('3.7').text() // "3"
|
|
15
|
+
* trunc('-2.7').text() // "-2"
|
|
16
|
+
* trunc('x').text() // "trunc(x)"
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function trunc(x: ExpressionInput): Expression;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trunc = trunc;
|
|
4
|
+
const Expression_1 = require("../core/classes/expression/Expression");
|
|
5
|
+
const constants_1 = require("../core/classes/parser/constants");
|
|
6
|
+
/**
|
|
7
|
+
* Truncates a number toward zero.
|
|
8
|
+
*
|
|
9
|
+
* Numeric inputs discard their fractional part without changing the sign of the
|
|
10
|
+
* integer portion. Symbolic inputs remain unevaluated.
|
|
11
|
+
*
|
|
12
|
+
* @param x - The expression to truncate.
|
|
13
|
+
* @returns The integer portion of `x`, or symbolic `trunc(x)`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* trunc('3.7').text() // "3"
|
|
18
|
+
* trunc('-2.7').text() // "-2"
|
|
19
|
+
* trunc('x').text() // "trunc(x)"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
function trunc(x) {
|
|
23
|
+
x = Expression_1.Expression.create(x);
|
|
24
|
+
let retval;
|
|
25
|
+
if (x.isPosInf() || x.isNegInf()) {
|
|
26
|
+
retval = x.isNegInf() ? Expression_1.Expression.NegInf() : Expression_1.Expression.Inf();
|
|
27
|
+
}
|
|
28
|
+
else if (x.isNUM()) {
|
|
29
|
+
const m = x.getMultiplier();
|
|
30
|
+
retval = Expression_1.Expression.Number(m.numerator / m.denominator);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
retval = Expression_1.Expression.toFunction(constants_1.TRUNC, [x]);
|
|
34
|
+
}
|
|
35
|
+
return retval;
|
|
36
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Expression } from '../core/classes/expression/Expression';
|
|
2
|
+
export { product, stripPower, sum } from '../core/classes/expression/utils';
|
|
3
|
+
import type { ExpressionInput, ParserEntity } from '../core/types';
|
|
4
|
+
/**
|
|
5
|
+
* Contains useful functions which are not likely to be exported to the user through `build`
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Places the Expression in a form that will defer any simplification. Expand must be explicitly called.
|
|
9
|
+
* TODO: This should likely be its own type but it seems a bit overblown to create whole new type
|
|
10
|
+
* just for factors.
|
|
11
|
+
*
|
|
12
|
+
* @param x
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function toFactor(x: Expression): Expression;
|
|
16
|
+
export declare function roots(x: number, y: number, product: number): [number, number];
|
|
17
|
+
export declare function getCombinations(factors: number[], num?: number, startAt?: number, combinations?: number[]): number[];
|
|
18
|
+
export declare function findMatches(factors: number[], target: number): number[][];
|
|
19
|
+
/**
|
|
20
|
+
* Converts an array of coefficient in decending power order to a polynomial string
|
|
21
|
+
*
|
|
22
|
+
* @param arr Array of coefficients in order of descending powers
|
|
23
|
+
* @param variable The variable to be used. Defaults to 'x'
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
export declare function polynomialStringFromArray(arr: number[], variable?: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Trims leading zeroes from an array
|
|
29
|
+
*
|
|
30
|
+
* @param polyArray
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare function trimZeros(polyArray: Expression[]): Expression[];
|
|
34
|
+
/**
|
|
35
|
+
* Returns the index of an element in an array. Use this instead of Array.indexOf
|
|
36
|
+
* since it recognized equality in Expression, Vectors, Matrices, etc.
|
|
37
|
+
*
|
|
38
|
+
* @param arr
|
|
39
|
+
* @param e
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
export declare function indexOf(arr: ParserEntity[], e: ParserEntity): number;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the number of elements in a Vector, SolutionSet, ValuesSet
|
|
45
|
+
* @param x
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
export declare function count(x: ParserEntity): Expression;
|
|
49
|
+
/** Returns the dimensions of a structured parser value. */
|
|
50
|
+
export declare function size(x: ParserEntity): ParserEntity;
|
|
51
|
+
/**
|
|
52
|
+
* Tests whether an exact integer expression is prime.
|
|
53
|
+
*
|
|
54
|
+
* Non-integer or unresolved symbolic input remains as an unevaluated `isprime(...)`
|
|
55
|
+
* expression so it can be simplified later.
|
|
56
|
+
*
|
|
57
|
+
* @param x - Expression-compatible value to test.
|
|
58
|
+
* @returns `1` for prime integers, `0` for composite integers, or an unevaluated symbolic call.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isprime(x: ExpressionInput): Expression;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sum = exports.stripPower = exports.product = void 0;
|
|
4
|
+
exports.toFactor = toFactor;
|
|
5
|
+
exports.roots = roots;
|
|
6
|
+
exports.getCombinations = getCombinations;
|
|
7
|
+
exports.findMatches = findMatches;
|
|
8
|
+
exports.polynomialStringFromArray = polynomialStringFromArray;
|
|
9
|
+
exports.trimZeros = trimZeros;
|
|
10
|
+
exports.indexOf = indexOf;
|
|
11
|
+
exports.count = count;
|
|
12
|
+
exports.size = size;
|
|
13
|
+
exports.isprime = isprime;
|
|
14
|
+
const Collection_1 = require("../core/classes/collection/Collection");
|
|
15
|
+
const Dictionary_1 = require("../core/classes/dictionary/Dictionary");
|
|
16
|
+
const Expression_1 = require("../core/classes/expression/Expression");
|
|
17
|
+
const shortcuts_1 = require("../core/classes/expression/shortcuts");
|
|
18
|
+
var utils_1 = require("../core/classes/expression/utils");
|
|
19
|
+
Object.defineProperty(exports, "product", { enumerable: true, get: function () { return utils_1.product; } });
|
|
20
|
+
Object.defineProperty(exports, "stripPower", { enumerable: true, get: function () { return utils_1.stripPower; } });
|
|
21
|
+
Object.defineProperty(exports, "sum", { enumerable: true, get: function () { return utils_1.sum; } });
|
|
22
|
+
const Matrix_1 = require("../core/classes/matrix/Matrix");
|
|
23
|
+
const constants_1 = require("../core/classes/parser/constants");
|
|
24
|
+
const ValuesSet_1 = require("../core/classes/valuesSet/ValuesSet");
|
|
25
|
+
const Vector_1 = require("../core/classes/vector/Vector");
|
|
26
|
+
const primeFactor_1 = require("../core/functions/bigint/primeFactor");
|
|
27
|
+
/**
|
|
28
|
+
* Contains useful functions which are not likely to be exported to the user through `build`
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Places the Expression in a form that will defer any simplification. Expand must be explicitly called.
|
|
32
|
+
* TODO: This should likely be its own type but it seems a bit overblown to create whole new type
|
|
33
|
+
* just for factors.
|
|
34
|
+
*
|
|
35
|
+
* @param x
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
function toFactor(x) {
|
|
39
|
+
return Expression_1.Expression.toEXP(x, (0, shortcuts_1.one)());
|
|
40
|
+
}
|
|
41
|
+
function roots(x, y, product) {
|
|
42
|
+
const a = (x + y + Math.sqrt((x + y) ** 2 - 4 * product)) / 2;
|
|
43
|
+
const b = (x + y - Math.sqrt((x + y) ** 2 - 4 * product)) / 2;
|
|
44
|
+
return [Math.min(a, b), Math.max(a, b)];
|
|
45
|
+
}
|
|
46
|
+
function getCombinations(factors, num, startAt = 1, combinations) {
|
|
47
|
+
combinations ??= [factors[0]];
|
|
48
|
+
// Start at the beginning
|
|
49
|
+
num = num || factors[0];
|
|
50
|
+
for (let i = startAt; i < factors.length; i++) {
|
|
51
|
+
// Calculate this combination
|
|
52
|
+
const product = num * factors[i];
|
|
53
|
+
combinations.push(product);
|
|
54
|
+
// Get the rest of the combinations with this
|
|
55
|
+
for (let j = startAt + 1; j < factors.length; j++) {
|
|
56
|
+
combinations.push(factors[startAt] * factors[j]);
|
|
57
|
+
}
|
|
58
|
+
// We now have to calculate the combinations witht the remaining factors
|
|
59
|
+
getCombinations(factors, product, i + 1, combinations);
|
|
60
|
+
}
|
|
61
|
+
combinations = [...new Set(combinations)].sort((a, b) => a - b);
|
|
62
|
+
return combinations;
|
|
63
|
+
}
|
|
64
|
+
function findMatches(factors, target) {
|
|
65
|
+
const matches = [];
|
|
66
|
+
for (let i = 0; i < factors.length; i++) {
|
|
67
|
+
const a = factors[i];
|
|
68
|
+
for (let j = factors.length - 1; j > i; j--) {
|
|
69
|
+
const b = factors[j];
|
|
70
|
+
const product = a * b;
|
|
71
|
+
// If the range is less than the target number then we're out of range
|
|
72
|
+
if (product < target) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
// The combination has to be an exact match
|
|
76
|
+
if (product === target) {
|
|
77
|
+
matches.push([Math.min(a, b), Math.max(a, b)]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return matches;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Converts an array of coefficient in decending power order to a polynomial string
|
|
85
|
+
*
|
|
86
|
+
* @param arr Array of coefficients in order of descending powers
|
|
87
|
+
* @param variable The variable to be used. Defaults to 'x'
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
function polynomialStringFromArray(arr, variable = 'x') {
|
|
91
|
+
const terms = [];
|
|
92
|
+
// Make a copy and reverse
|
|
93
|
+
const polyArray = [...arr].reverse();
|
|
94
|
+
for (let p = 0; p < polyArray.length; p++) {
|
|
95
|
+
const c = polyArray[p];
|
|
96
|
+
if (c !== 0) {
|
|
97
|
+
if (p === 0) {
|
|
98
|
+
terms.push(String(c));
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
const m = c === 1 ? '' : c === -1 ? '-' : `${c}*`;
|
|
102
|
+
const pow = p === 1 ? '' : '^' + p;
|
|
103
|
+
terms.push(`${m}${variable}${pow}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return terms.reverse().join('+').replace(/\+-/g, '-');
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Trims leading zeroes from an array
|
|
111
|
+
*
|
|
112
|
+
* @param polyArray
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
function trimZeros(polyArray) {
|
|
116
|
+
let i = polyArray.length - 1;
|
|
117
|
+
while (i > 0 && polyArray[i].isZero()) {
|
|
118
|
+
i--;
|
|
119
|
+
}
|
|
120
|
+
return polyArray.slice(0, i + 1);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Returns the index of an element in an array. Use this instead of Array.indexOf
|
|
124
|
+
* since it recognized equality in Expression, Vectors, Matrices, etc.
|
|
125
|
+
*
|
|
126
|
+
* @param arr
|
|
127
|
+
* @param e
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
function indexOf(arr, e) {
|
|
131
|
+
for (let i = 0; i < arr.length; i++) {
|
|
132
|
+
const element = arr[i];
|
|
133
|
+
if (element.eq(e)) {
|
|
134
|
+
return i;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return -1;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns the number of elements in a Vector, SolutionSet, ValuesSet
|
|
141
|
+
* @param x
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
144
|
+
function count(x) {
|
|
145
|
+
if (Vector_1.Vector.isVector(x) || ValuesSet_1.ValuesSet.isValuesSet(x) || Dictionary_1.Dictionary.isDictionary(x)) {
|
|
146
|
+
return Expression_1.Expression.Number(x.count());
|
|
147
|
+
}
|
|
148
|
+
return Expression_1.Expression.toFunction(constants_1.COUNT, [x]);
|
|
149
|
+
}
|
|
150
|
+
/** Returns the dimensions of a structured parser value. */
|
|
151
|
+
function size(x) {
|
|
152
|
+
if (Vector_1.Vector.isVector(x) ||
|
|
153
|
+
Matrix_1.Matrix.isMatrix(x) ||
|
|
154
|
+
Collection_1.Collection.isCollection(x) ||
|
|
155
|
+
ValuesSet_1.ValuesSet.isValuesSet(x) ||
|
|
156
|
+
Dictionary_1.Dictionary.isDictionary(x)) {
|
|
157
|
+
return Vector_1.Vector.create(x.dimensions());
|
|
158
|
+
}
|
|
159
|
+
return Expression_1.Expression.toFunction(constants_1.SIZE, [x]);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Tests whether an exact integer expression is prime.
|
|
163
|
+
*
|
|
164
|
+
* Non-integer or unresolved symbolic input remains as an unevaluated `isprime(...)`
|
|
165
|
+
* expression so it can be simplified later.
|
|
166
|
+
*
|
|
167
|
+
* @param x - Expression-compatible value to test.
|
|
168
|
+
* @returns `1` for prime integers, `0` for composite integers, or an unevaluated symbolic call.
|
|
169
|
+
*/
|
|
170
|
+
function isprime(x) {
|
|
171
|
+
const expression = Expression_1.Expression.create(x);
|
|
172
|
+
let retval;
|
|
173
|
+
if (expression.isInteger()) {
|
|
174
|
+
retval = Expression_1.Expression.Number(Number((0, primeFactor_1.isPrimeBig)(expression.getMultiplier().numerator)));
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
retval = Expression_1.Expression.toFunction(constants_1.ISPRIME, [expression]);
|
|
178
|
+
}
|
|
179
|
+
return retval;
|
|
180
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
/**
|
|
3
|
+
* A lightweight numeric matrix over Decimal.js for use in numerical solvers.
|
|
4
|
+
* Supports only the operations needed for Newton-Raphson: construction and linear solve.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DecimalMatrix {
|
|
7
|
+
private readonly cols;
|
|
8
|
+
private data;
|
|
9
|
+
private readonly rows;
|
|
10
|
+
constructor(data: Decimal[][]);
|
|
11
|
+
/**
|
|
12
|
+
* Solves the linear system Ax = b using Gaussian elimination with partial pivoting.
|
|
13
|
+
* Returns the solution vector x, or null if the system is singular.
|
|
14
|
+
*/
|
|
15
|
+
static solve(A: DecimalMatrix, b: Decimal[]): Decimal[] | null;
|
|
16
|
+
private get;
|
|
17
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DecimalMatrix = void 0;
|
|
7
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
|
+
/**
|
|
9
|
+
* A lightweight numeric matrix over Decimal.js for use in numerical solvers.
|
|
10
|
+
* Supports only the operations needed for Newton-Raphson: construction and linear solve.
|
|
11
|
+
*/
|
|
12
|
+
class DecimalMatrix {
|
|
13
|
+
cols;
|
|
14
|
+
data;
|
|
15
|
+
rows;
|
|
16
|
+
constructor(data) {
|
|
17
|
+
this.rows = data.length;
|
|
18
|
+
this.cols = data.length > 0 ? data[0].length : 0;
|
|
19
|
+
this.data = data.map(row => row.map(v => new decimal_js_1.default(v)));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Solves the linear system Ax = b using Gaussian elimination with partial pivoting.
|
|
23
|
+
* Returns the solution vector x, or null if the system is singular.
|
|
24
|
+
*/
|
|
25
|
+
static solve(A, b) {
|
|
26
|
+
const n = A.rows;
|
|
27
|
+
if (n !== A.cols || n !== b.length) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
// Build augmented matrix [A | b]
|
|
31
|
+
const aug = [];
|
|
32
|
+
for (let i = 0; i < n; i++) {
|
|
33
|
+
const row = [];
|
|
34
|
+
for (let j = 0; j < n; j++) {
|
|
35
|
+
row.push(new decimal_js_1.default(A.get(i, j)));
|
|
36
|
+
}
|
|
37
|
+
row.push(new decimal_js_1.default(b[i]));
|
|
38
|
+
aug.push(row);
|
|
39
|
+
}
|
|
40
|
+
// Forward elimination with partial pivoting
|
|
41
|
+
for (let col = 0; col < n; col++) {
|
|
42
|
+
// Find pivot
|
|
43
|
+
let maxAbs = aug[col][col].abs();
|
|
44
|
+
let maxRow = col;
|
|
45
|
+
for (let row = col + 1; row < n; row++) {
|
|
46
|
+
const val = aug[row][col].abs();
|
|
47
|
+
if (val.greaterThan(maxAbs)) {
|
|
48
|
+
maxAbs = val;
|
|
49
|
+
maxRow = row;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (maxAbs.lessThan(new decimal_js_1.default('1e-30'))) {
|
|
53
|
+
return null; // Singular
|
|
54
|
+
}
|
|
55
|
+
// Swap rows
|
|
56
|
+
if (maxRow !== col) {
|
|
57
|
+
[aug[col], aug[maxRow]] = [aug[maxRow], aug[col]];
|
|
58
|
+
}
|
|
59
|
+
// Eliminate below
|
|
60
|
+
const pivot = aug[col][col];
|
|
61
|
+
for (let row = col + 1; row < n; row++) {
|
|
62
|
+
const factor = aug[row][col].div(pivot);
|
|
63
|
+
for (let j = col; j <= n; j++) {
|
|
64
|
+
aug[row][j] = aug[row][j].minus(factor.times(aug[col][j]));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Back substitution
|
|
69
|
+
const x = new Array(n);
|
|
70
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
71
|
+
let sum = aug[i][n];
|
|
72
|
+
for (let j = i + 1; j < n; j++) {
|
|
73
|
+
sum = sum.minus(aug[i][j].times(x[j]));
|
|
74
|
+
}
|
|
75
|
+
if (aug[i][i].abs().lessThan(new decimal_js_1.default('1e-30'))) {
|
|
76
|
+
return null; // Singular
|
|
77
|
+
}
|
|
78
|
+
x[i] = sum.div(aug[i][i]);
|
|
79
|
+
}
|
|
80
|
+
return x;
|
|
81
|
+
}
|
|
82
|
+
get(i, j) {
|
|
83
|
+
return this.data[i][j];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.DecimalMatrix = DecimalMatrix;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
import { Expression } from '../../core/classes/expression/Expression';
|
|
3
|
+
/** Numerical method used to refine a candidate interval. */
|
|
4
|
+
export type RootFindingMethod = 'Brent' | 'NewtonRaphson';
|
|
5
|
+
/** Options for numerical root searches over a fixed interval with {@link FunctionSolver}. */
|
|
6
|
+
export interface FunctionSolverOptions {
|
|
7
|
+
/** Upper endpoint of the search interval. Defaults to `100`. */
|
|
8
|
+
upperBound?: Decimal | number;
|
|
9
|
+
/** Lower endpoint of the search interval. Defaults to `-100`. */
|
|
10
|
+
lowerBound?: Decimal | number;
|
|
11
|
+
/** Central-difference step used by Newton-Raphson. Defaults to `1e-15`. */
|
|
12
|
+
derivativeStep?: Decimal | number;
|
|
13
|
+
/** Maximum refinement iterations for each candidate. Defaults to `200`. */
|
|
14
|
+
maxIterations?: number;
|
|
15
|
+
/** Spacing used to scan for candidate intervals. Defaults to `0.1`. */
|
|
16
|
+
stepSize?: number;
|
|
17
|
+
/** Residual and convergence tolerance. Defaults to `1e-14`. */
|
|
18
|
+
tolerance?: number;
|
|
19
|
+
/** Maximum number of roots to return. Defaults to `20`. */
|
|
20
|
+
maxRoots?: number;
|
|
21
|
+
/** Reserved diagnostic flag. The current implementation emits no output. */
|
|
22
|
+
verbose?: boolean;
|
|
23
|
+
/** Refinement method. Defaults to `'Brent'`. */
|
|
24
|
+
method?: RootFindingMethod;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Metadata returned by a single numerical root-refinement attempt.
|
|
28
|
+
*/
|
|
29
|
+
export interface Root {
|
|
30
|
+
/** The root found */
|
|
31
|
+
root: Decimal;
|
|
32
|
+
/** Number of iterations performed */
|
|
33
|
+
iterations: number;
|
|
34
|
+
/** Whether the algorithm converged */
|
|
35
|
+
converged: boolean;
|
|
36
|
+
/** Final error estimate */
|
|
37
|
+
error: Decimal;
|
|
38
|
+
/** The error message if any */
|
|
39
|
+
errorMsg?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Searches a fixed interval for real roots of a univariate expression.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* {@link roots} scans the configured interval from its center toward both
|
|
46
|
+
* endpoints. It refines sign-changing intervals with Brent's method or
|
|
47
|
+
* Newton-Raphson, verifies residuals, merges nearby results, and returns roots
|
|
48
|
+
* in ascending order. This is a heuristic search: an even-multiplicity root
|
|
49
|
+
* can be missed unless a scan point lands sufficiently close to it, and
|
|
50
|
+
* periodic functions are limited by both the interval and `maxRoots`.
|
|
51
|
+
*
|
|
52
|
+
* Calculations use the ambient `decimal.js` precision. An Expression supplied
|
|
53
|
+
* to the constructor is retained rather than copied, and the public settings
|
|
54
|
+
* may be adjusted before a search.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const solver = new FunctionSolver('cos(x)-x', 'x', {
|
|
59
|
+
* lowerBound: 0,
|
|
60
|
+
* upperBound: 1,
|
|
61
|
+
* });
|
|
62
|
+
* const roots = solver.roots();
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare class FunctionSolver {
|
|
66
|
+
derivativeStep: Decimal;
|
|
67
|
+
func: Expression;
|
|
68
|
+
lowerBound: Decimal;
|
|
69
|
+
maxIters: number;
|
|
70
|
+
maxRoots: number;
|
|
71
|
+
method?: RootFindingMethod;
|
|
72
|
+
stepSize: number;
|
|
73
|
+
tolerance: Decimal;
|
|
74
|
+
upperBound: Decimal;
|
|
75
|
+
variable: string;
|
|
76
|
+
verbose: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a real-root solver for the configured search interval.
|
|
79
|
+
*
|
|
80
|
+
* @param func - Expression to evaluate, or a string parsed as an Expression.
|
|
81
|
+
* @param variable - Variable to substitute. When omitted, the expression must
|
|
82
|
+
* contain at most one variable.
|
|
83
|
+
* @param options - Search interval, refinement method, and tolerances.
|
|
84
|
+
* @throws {@link core!UnsupportedOperationError} If `variable` is omitted and the
|
|
85
|
+
* expression contains more than one variable.
|
|
86
|
+
*/
|
|
87
|
+
constructor(func: Expression | string, variable?: string, options?: FunctionSolverOptions);
|
|
88
|
+
private calculateIntervals;
|
|
89
|
+
private getVariable;
|
|
90
|
+
/**
|
|
91
|
+
* Refines a bracket using Brent's combination of bisection, secant, and
|
|
92
|
+
* inverse-quadratic interpolation.
|
|
93
|
+
*
|
|
94
|
+
* @param a - First bracket endpoint.
|
|
95
|
+
* @param b - Second bracket endpoint.
|
|
96
|
+
* @returns Refinement metadata. Invalid brackets and exhausted iterations are
|
|
97
|
+
* represented in the returned {@link Root}; they are not thrown.
|
|
98
|
+
*/
|
|
99
|
+
Brent(a: Decimal, b: Decimal): Root;
|
|
100
|
+
/** Approximates the derivative with a central difference. */
|
|
101
|
+
df(x: Decimal, h: Decimal): Decimal;
|
|
102
|
+
/**
|
|
103
|
+
* Evaluates the configured expression at a real value.
|
|
104
|
+
*
|
|
105
|
+
* @throws {@link core!UnexpectedInputError} If evaluation does not produce a scalar
|
|
106
|
+
* Expression.
|
|
107
|
+
*/
|
|
108
|
+
evaluate(at: Decimal | number | string): Decimal;
|
|
109
|
+
/**
|
|
110
|
+
* Refines a root from an initial guess using Newton-Raphson and a numerical
|
|
111
|
+
* derivative.
|
|
112
|
+
*
|
|
113
|
+
* @returns Refinement metadata, including non-convergence or a zero derivative.
|
|
114
|
+
*/
|
|
115
|
+
NewtonRaphson(guess: Decimal): {
|
|
116
|
+
root: Decimal;
|
|
117
|
+
iterations: number;
|
|
118
|
+
converged: boolean;
|
|
119
|
+
error: Decimal;
|
|
120
|
+
errorMsg: string;
|
|
121
|
+
} | {
|
|
122
|
+
root: Decimal;
|
|
123
|
+
iterations: number;
|
|
124
|
+
converged: boolean;
|
|
125
|
+
error: Decimal;
|
|
126
|
+
errorMsg?: undefined;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Searches the configured interval for real roots.
|
|
130
|
+
*
|
|
131
|
+
* @returns Verified, deduplicated roots in ascending order, limited by
|
|
132
|
+
* `maxRoots`. Failed evaluations and failed refinements are skipped.
|
|
133
|
+
*/
|
|
134
|
+
roots(): Expression[];
|
|
135
|
+
}
|