nerdamer 2.0.0-rc.1 → 2.0.0
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 -0
- package/README.md +168 -229
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.LICENSE.txt +6 -6
- package/output/algebra/adapters.d.ts +3 -33
- package/output/algebra/adapters.js +7 -105
- package/output/algebra/algorithms/arith.js +10 -9
- package/output/algebra/algorithms/groebnerBase.d.ts +24 -20
- package/output/algebra/algorithms/groebnerBase.js +486 -723
- package/output/algebra/dispatch.d.ts +1 -0
- package/output/algebra/dispatch.js +25 -0
- package/output/algebra/factor/factor.d.ts +15 -0
- package/output/algebra/factor/factor.js +99 -12
- package/output/algebra/gcd/gcd.d.ts +8 -7
- package/output/algebra/gcd/gcd.js +32 -78
- package/output/algebra/groebner.d.ts +2 -2
- package/output/algebra/groebner.js +6 -12
- package/output/algebra/partfrac.d.ts +3 -3
- package/output/algebra/partfrac.js +28 -61
- 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.js +4 -2
- package/output/algebra/simplify/funcsimp.js +1 -1
- package/output/algebra/simplify/ratsimp.js +1 -1
- package/output/algebra/simplify/simplify.js +11 -2
- package/output/algebra/utils.d.ts +1 -1
- package/output/algebra/utils.js +3 -3
- package/output/api/advanced.d.ts +2 -1
- package/output/api/advanced.js +3 -3
- package/output/api/algebra.d.ts +21 -4
- package/output/api/algebra.js +22 -3
- package/output/api/assumptions.d.ts +1 -1
- package/output/api/assumptions.js +2 -1
- package/output/api/calculus.d.ts +2 -1
- package/output/api/calculus.js +2 -1
- package/output/api/core.d.ts +28 -7
- package/output/api/core.js +28 -2
- 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 +10 -2
- package/output/api/parser.js +2 -0
- package/output/api/solve.d.ts +1 -1
- package/output/api/solve.js +2 -1
- package/output/api/structures.d.ts +1 -1
- package/output/api/structures.js +2 -1
- package/output/calculus/adapters.d.ts +8 -0
- package/output/calculus/adapters.js +41 -0
- package/output/calculus/derivative/diff.js +6 -3
- package/output/calculus/dispatch.d.ts +1 -0
- package/output/calculus/dispatch.js +25 -0
- package/output/calculus/integrate/integrate.js +4 -4
- package/output/calculus/integrate/integrationTable.js +16 -16
- package/output/calculus/laplace/ilaplace.js +1 -1
- package/output/calculus/laplace/ilaplaceTable.js +18 -17
- package/output/calculus/laplace/laplaceTable.js +3 -2
- package/output/calculus/limit/limit.js +1 -1
- package/output/core/classes/assumption/Assumption.js +14 -10
- package/output/core/classes/assumption/assume.d.ts +6 -0
- package/output/core/classes/assumption/assume.js +9 -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.js +11 -2
- package/output/core/classes/complex/Complex.d.ts +10 -0
- package/output/core/classes/complex/Complex.js +19 -1
- package/output/core/classes/decimalSet/DecimalSet.js +5 -4
- package/output/core/classes/dictionary/Dictionary.js +4 -1
- package/output/core/classes/expression/CoeffObject.d.ts +1 -1
- package/output/core/classes/expression/CoeffObject.js +1 -2
- package/output/core/classes/expression/Expression.d.ts +35 -26
- package/output/core/classes/expression/Expression.js +77 -50
- package/output/core/classes/expression/analysis.d.ts +1 -1
- package/output/core/classes/expression/analysis.js +7 -7
- package/output/core/classes/expression/format.d.ts +9 -0
- package/output/core/classes/expression/format.js +130 -7
- package/output/core/classes/expression/utils.d.ts +9 -0
- package/output/core/classes/expression/utils.js +52 -6
- package/output/core/classes/matrix/Matrix.d.ts +2 -3
- package/output/core/classes/matrix/Matrix.js +26 -23
- 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 +2 -0
- package/output/core/classes/matrix/functions.js +5 -0
- package/output/core/classes/parser/Parser.d.ts +31 -5
- package/output/core/classes/parser/Parser.js +357 -444
- package/output/core/classes/parser/constants.d.ts +2 -0
- package/output/core/classes/parser/constants.js +4 -2
- package/output/core/classes/parser/controlFlowSignals.d.ts +38 -0
- package/output/core/classes/parser/controlFlowSignals.js +60 -0
- package/output/core/classes/parser/operations/add.js +14 -16
- package/output/core/classes/parser/operations/compare.js +13 -0
- package/output/core/classes/parser/operations/functions.d.ts +3 -4
- package/output/core/classes/parser/operations/functions.js +48 -102
- package/output/core/classes/parser/operations/multiply.js +22 -15
- package/output/core/classes/parser/operations/power.js +11 -11
- package/output/core/classes/parser/operations/subtract.js +2 -1
- package/output/core/classes/parser/preprocess.d.ts +0 -7
- package/output/core/classes/parser/preprocess.js +33 -39
- package/output/core/classes/parser/scripting/controlFlow.d.ts +4 -102
- package/output/core/classes/parser/scripting/controlFlow.js +134 -186
- 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 +13 -0
- package/output/core/classes/parser/scripting/evaluate.js +17 -1
- package/output/core/classes/parser/scripting/scope.d.ts +1 -28
- package/output/core/classes/parser/scripting/scope.js +36 -40
- package/output/core/classes/parser/types.d.ts +5 -5
- package/output/core/classes/parser/wrappers/IndexedReference.d.ts +4 -3
- package/output/core/classes/parser/wrappers/IndexedReference.js +8 -0
- package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +2 -2
- package/output/core/classes/polynomial/Polynomial.d.ts +5 -1
- package/output/core/classes/polynomial/Polynomial.js +53 -7
- 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.js +2 -2
- package/output/core/{adapters.d.ts → classes/polynomial/adapters.d.ts} +2 -2
- 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 +8 -0
- package/output/core/classes/polynomial/functions.js +71 -8
- package/output/core/classes/polynomial/utils.js +2 -1
- package/output/core/classes/rational/Rational.d.ts +8 -11
- package/output/core/classes/rational/Rational.js +70 -20
- package/output/core/classes/seq/SEQ.js +4 -4
- package/output/core/classes/valuesSet/ValuesSet.d.ts +9 -1
- package/output/core/classes/valuesSet/ValuesSet.js +22 -4
- package/output/core/classes/vector/Vector.d.ts +2 -3
- package/output/core/classes/vector/Vector.js +11 -15
- package/output/core/classes/vector/dispatch.d.ts +1 -0
- package/output/core/classes/vector/dispatch.js +11 -0
- package/output/core/common/classes/MathematicalAggregate.js +11 -2
- package/output/core/common/classes/StructuredEntity.d.ts +0 -17
- package/output/core/common/classes/StructuredEntity.js +3 -64
- package/output/core/common/common.d.ts +0 -1
- package/output/core/common/common.js +29 -234
- package/output/core/converters/BaseConverter.js +3 -2
- package/output/core/converters/Converter.js +9 -5
- package/output/core/converters/Pattern.js +1 -1
- package/output/core/dispatch.d.ts +18 -0
- package/output/core/dispatch.js +3 -281
- package/output/core/errors.d.ts +259 -474
- package/output/core/errors.js +270 -542
- package/output/core/fullFunctions.d.ts +7 -0
- package/output/core/fullFunctions.js +31 -0
- package/output/core/functions/bigint/bigint.d.ts +13 -1
- package/output/core/functions/bigint/bigint.js +56 -4
- package/output/core/functions/bigint/primeFactor.d.ts +2 -0
- package/output/core/functions/bigint/primeFactor.js +13 -13
- package/output/core/functions/build/definitions.js +6 -0
- package/output/core/functions/complex.d.ts +2 -2
- 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 +7 -7
- package/output/core/functions/decimal.js +2 -1
- package/output/core/functions/expand/expand.js +2 -2
- package/output/core/functions/numeric.d.ts +1 -1
- package/output/core/functions/string.js +2 -1
- package/output/core/functions/subst.js +21 -13
- package/output/core/parserFunctions.d.ts +7 -0
- package/output/core/parserFunctions.js +25 -0
- package/output/index.d.ts +50 -30
- package/output/index.js +147 -19
- package/output/math/defint/defint.d.ts +18 -0
- package/output/math/defint/defint.js +60 -0
- package/output/math/defint/defintDecimal.js +6 -5
- package/output/math/defint/defintNative.js +7 -18
- package/output/math/dispatch.d.ts +1 -0
- package/output/math/dispatch.js +101 -0
- package/output/math/geometry.d.ts +4 -0
- package/output/math/geometry.js +23 -0
- package/output/math/math.d.ts +59 -19
- package/output/math/math.js +244 -100
- package/output/math/trig.js +4 -4
- package/output/math/utils.d.ts +6 -0
- package/output/math/utils.js +39 -0
- package/output/solve/classes/PolynomialSolver.d.ts +33 -14
- package/output/solve/classes/PolynomialSolver.js +267 -67
- package/output/solve/classes/SolutionSet.d.ts +20 -1
- package/output/solve/classes/SolutionSet.js +82 -5
- package/output/solve/dispatch.d.ts +1 -0
- package/output/solve/dispatch.js +13 -0
- package/output/solve/linsolve.d.ts +2 -0
- package/output/solve/linsolve.js +13 -5
- package/output/solve/solve.d.ts +10 -0
- package/output/solve/solve.js +128 -20
- package/output/solve/solveSystem.d.ts +1 -1
- package/output/solve/solveSystem.js +8 -32
- package/output/solve/utils.d.ts +2 -1
- package/output/solve/utils.js +18 -22
- package/output/utils/array.d.ts +1 -1
- package/output/utils/debug.js +2 -1
- package/package.json +22 -38
- package/dist/parser.js +0 -2
- package/dist/parser.js.LICENSE.txt +0 -7
- package/docs-data/parser-functions.json +0 -1960
- package/output/algebra/algorithms/factor.d.ts +0 -3
- package/output/algebra/algorithms/factor.js +0 -5
- package/output/algebra/algorithms/factorMultivariate.d.ts +0 -23
- package/output/algebra/algorithms/factorMultivariate.js +0 -2393
- package/output/algebra/algorithms/factorUnivariate.d.ts +0 -72
- package/output/algebra/algorithms/factorUnivariate.js +0 -1072
- package/output/algebra/algorithms/gcd.d.ts +0 -22
- package/output/algebra/algorithms/gcd.js +0 -690
- package/output/algebra/algorithms/multiPoly/MultiPoly.d.ts +0 -137
- package/output/algebra/algorithms/multiPoly/MultiPoly.js +0 -346
- package/output/algebra/algorithms/poly.d.ts +0 -228
- package/output/algebra/algorithms/poly.js +0 -1299
- package/output/algebra/algorithms/rational.d.ts +0 -17
- package/output/algebra/algorithms/rational.js +0 -115
- package/output/core/adapters.js +0 -40
- package/output/core/classes/parser/operations/comma.d.ts +0 -7
- package/output/core/classes/parser/operations/comma.js +0 -11
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Adaptive Simpson definite integration using native `number` arithmetic.
|
|
4
|
-
*
|
|
5
|
-
* Same algorithm as the Decimal.js version (adaptive Simpson with Richardson
|
|
6
|
-
* extrapolation, iterative stack) but 50-100x faster for typical integrands.
|
|
7
|
-
*
|
|
8
|
-
* Features:
|
|
9
|
-
* - Adaptive error control with combined absolute + relative tolerance
|
|
10
|
-
* - Breakpoint segmentation for piecewise/abs/kink functions
|
|
11
|
-
* - Infinite bounds via variable substitution
|
|
12
|
-
* - Best-effort singularity handling
|
|
13
|
-
*/
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.definiteIntegrateNative = definiteIntegrateNative;
|
|
4
|
+
const errors_1 = require("../../core/errors");
|
|
16
5
|
const DEFAULT_TOL = 1e-12;
|
|
17
6
|
const DEFAULT_MAX_DEPTH = 50;
|
|
18
7
|
const DEFAULT_MAX_EVALUATIONS = 100_000;
|
|
@@ -39,11 +28,11 @@ function withFiniteBounds(f, aIn, bIn, tolAbs, tolRel, maxDepth, maxEvals, singu
|
|
|
39
28
|
let evals = 0;
|
|
40
29
|
const evalF = (x) => {
|
|
41
30
|
if (++evals > maxEvals) {
|
|
42
|
-
throw new Error(
|
|
31
|
+
throw new Error((0, errors_1.message)('defintMaxEvals', { max: String(maxEvals) }));
|
|
43
32
|
}
|
|
44
33
|
const y = f(x);
|
|
45
34
|
if (singular === 'strict' && !isFinite(y)) {
|
|
46
|
-
throw new Error(
|
|
35
|
+
throw new Error((0, errors_1.message)('defintNonFiniteValue', { x: String(x) }));
|
|
47
36
|
}
|
|
48
37
|
return y;
|
|
49
38
|
};
|
|
@@ -70,7 +59,7 @@ function withFiniteBounds(f, aIn, bIn, tolAbs, tolRel, maxDepth, maxEvals, singu
|
|
|
70
59
|
const x = singularAtLeft ? a + span * u * u : b - span * u * u;
|
|
71
60
|
const y = f(x) * 2 * span * u;
|
|
72
61
|
if (!isFinite(y)) {
|
|
73
|
-
throw new Error(
|
|
62
|
+
throw new Error((0, errors_1.message)('defintEndpointSingularity', { x: String(x) }));
|
|
74
63
|
}
|
|
75
64
|
return y;
|
|
76
65
|
};
|
|
@@ -118,7 +107,7 @@ function withFiniteBounds(f, aIn, bIn, tolAbs, tolRel, maxDepth, maxEvals, singu
|
|
|
118
107
|
!isFinite(fr.fm) ||
|
|
119
108
|
!isFinite(fr.fb))) {
|
|
120
109
|
if (fr.depth >= maxDepth || fr.singularTries >= MAX_SINGULAR_TRIES) {
|
|
121
|
-
throw new Error(
|
|
110
|
+
throw new Error((0, errors_1.message)('defintSingularity', { a: String(a0), b: String(b0) }));
|
|
122
111
|
}
|
|
123
112
|
const nextDepth = fr.depth + 1;
|
|
124
113
|
const childTolAbs = fr.tolAbs / 2;
|
|
@@ -233,7 +222,7 @@ function definiteIntegrateNative(f, a, b, options = {}) {
|
|
|
233
222
|
const isInfA = !isFinite(a) && !isNaN(a);
|
|
234
223
|
const isInfB = !isFinite(b) && !isNaN(b);
|
|
235
224
|
if ((isInfA || isInfB) && !allowInfinite) {
|
|
236
|
-
throw new Error(
|
|
225
|
+
throw new Error((0, errors_1.message)('defintInfiniteBounds'));
|
|
237
226
|
}
|
|
238
227
|
// ── Infinite-bound substitutions ─────────────────────────────
|
|
239
228
|
if (allowInfinite && (isInfA || isInfB)) {
|
|
@@ -269,7 +258,7 @@ function definiteIntegrateNative(f, a, b, options = {}) {
|
|
|
269
258
|
};
|
|
270
259
|
return withFiniteBounds(g, eps, 1 - eps, tolAbs, tolRel, maxDepth, maxEvals, singular);
|
|
271
260
|
}
|
|
272
|
-
throw new Error(
|
|
261
|
+
throw new Error((0, errors_1.message)('defintUnsupportedInfiniteBounds'));
|
|
273
262
|
}
|
|
274
263
|
// ── Finite bounds with optional breakpoints ──────────────────
|
|
275
264
|
const lo = Math.min(a, b);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadMathFunctions(): void;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadMathFunctions = loadMathFunctions;
|
|
4
|
+
const constants_1 = require("../core/classes/parser/constants");
|
|
5
|
+
const evaluate_1 = require("../core/classes/parser/scripting/evaluate");
|
|
6
|
+
const dispatch_1 = require("../core/dispatch");
|
|
7
|
+
const expand_1 = require("../core/functions/expand/expand");
|
|
8
|
+
const subst_1 = require("../core/functions/subst");
|
|
9
|
+
const geometry_1 = require("./geometry");
|
|
10
|
+
const math_1 = require("./math");
|
|
11
|
+
const trig_1 = require("./trig");
|
|
12
|
+
const trunc_1 = require("./trunc");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
function loadMathFunctions() {
|
|
15
|
+
Object.assign(dispatch_1.mathFunctionRegistry, {
|
|
16
|
+
cos: (0, dispatch_1.systemFunction)({ fn: trig_1.cos, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
17
|
+
sin: (0, dispatch_1.systemFunction)({ fn: trig_1.sin, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
18
|
+
tan: (0, dispatch_1.systemFunction)({ fn: trig_1.tan, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
19
|
+
sec: (0, dispatch_1.systemFunction)({ fn: trig_1.sec, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
20
|
+
csc: (0, dispatch_1.systemFunction)({ fn: trig_1.csc, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
21
|
+
cot: (0, dispatch_1.systemFunction)({ fn: trig_1.cot, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
22
|
+
acos: (0, dispatch_1.systemFunction)({ fn: trig_1.acos, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
23
|
+
asin: (0, dispatch_1.systemFunction)({ fn: trig_1.asin, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
24
|
+
atan: (0, dispatch_1.systemFunction)({ fn: trig_1.atan, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
25
|
+
asec: (0, dispatch_1.systemFunction)({ fn: trig_1.asec, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
26
|
+
acsc: (0, dispatch_1.systemFunction)({ fn: trig_1.acsc, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
27
|
+
acot: (0, dispatch_1.systemFunction)({ fn: trig_1.acot, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
28
|
+
atan2: (0, dispatch_1.systemFunction)({ fn: trig_1.atan2, minArgs: 2, maxArgs: 2, distElWise: true }),
|
|
29
|
+
cosh: (0, dispatch_1.systemFunction)({ fn: trig_1.cosh, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
30
|
+
sinh: (0, dispatch_1.systemFunction)({ fn: trig_1.sinh, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
31
|
+
tanh: (0, dispatch_1.systemFunction)({ fn: trig_1.tanh, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
32
|
+
sech: (0, dispatch_1.systemFunction)({ fn: trig_1.sech, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
33
|
+
csch: (0, dispatch_1.systemFunction)({ fn: trig_1.csch, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
34
|
+
coth: (0, dispatch_1.systemFunction)({ fn: trig_1.coth, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
35
|
+
acosh: (0, dispatch_1.systemFunction)({ fn: trig_1.acosh, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
36
|
+
asinh: (0, dispatch_1.systemFunction)({ fn: trig_1.asinh, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
37
|
+
atanh: (0, dispatch_1.systemFunction)({ fn: trig_1.atanh, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
38
|
+
asech: (0, dispatch_1.systemFunction)({ fn: trig_1.asech, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
39
|
+
acsch: (0, dispatch_1.systemFunction)({ fn: trig_1.acsch, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
40
|
+
acoth: (0, dispatch_1.systemFunction)({ fn: trig_1.acoth, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
41
|
+
line: (0, dispatch_1.systemFunction)({ fn: geometry_1.line, minArgs: 2, maxArgs: 3, distElWise: false }),
|
|
42
|
+
abs: (0, dispatch_1.systemFunction)({ fn: math_1.abs, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
43
|
+
sqrt: (0, dispatch_1.systemFunction)({ fn: math_1.sqrt, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
44
|
+
nthroot: (0, dispatch_1.systemFunction)({ fn: math_1.nthroot, minArgs: 2, maxArgs: 2, distElWise: true }),
|
|
45
|
+
cbrt: (0, dispatch_1.systemFunction)({ fn: math_1.cbrt, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
46
|
+
subst: (0, dispatch_1.systemFunction)({ fn: subst_1.subst, minArgs: 3, maxArgs: 3, distElWise: true }),
|
|
47
|
+
log: (0, dispatch_1.systemFunction)({ fn: math_1.log, minArgs: 1, maxArgs: 2, distElWise: true }),
|
|
48
|
+
log10: (0, dispatch_1.systemFunction)({ fn: math_1.log10, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
49
|
+
radians: (0, dispatch_1.systemFunction)({ fn: math_1.radians, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
50
|
+
degrees: (0, dispatch_1.systemFunction)({ fn: math_1.degrees, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
51
|
+
exp: (0, dispatch_1.systemFunction)({ fn: math_1.exp, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
52
|
+
erf: (0, dispatch_1.systemFunction)({ fn: math_1.erf, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
53
|
+
erfc: (0, dispatch_1.systemFunction)({ fn: math_1.erfc, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
54
|
+
gamma: (0, dispatch_1.systemFunction)({ fn: math_1.gamma, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
55
|
+
gamma_incomplete: (0, dispatch_1.systemFunction)({ fn: math_1.gammaIncomplete, minArgs: 2, maxArgs: 2, distElWise: true }),
|
|
56
|
+
gamma_incomplete_lower: (0, dispatch_1.systemFunction)({ fn: math_1.gammaIncompleteLower, minArgs: 2, maxArgs: 2, distElWise: true }),
|
|
57
|
+
[constants_1.DIRAC]: (0, dispatch_1.systemFunction)({ fn: math_1.dirac, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
58
|
+
[constants_1.HEAVISIDE]: (0, dispatch_1.systemFunction)({ fn: math_1.heaviside, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
59
|
+
step: (0, dispatch_1.systemFunction)({ fn: math_1.step, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
60
|
+
rect: (0, dispatch_1.systemFunction)({ fn: math_1.rect, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
61
|
+
tri: (0, dispatch_1.systemFunction)({ fn: math_1.tri, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
62
|
+
continued_fraction: (0, dispatch_1.systemFunction)({ fn: utils_1.continuedFraction, minArgs: 1, maxArgs: 2, distElWise: false }),
|
|
63
|
+
scientific: (0, dispatch_1.systemFunction)({ fn: math_1.scientific, minArgs: 1, maxArgs: 2, distElWise: true }),
|
|
64
|
+
hypot: (0, dispatch_1.systemFunction)({ fn: geometry_1.hypot, minArgs: 2, maxArgs: 2, distElWise: true }),
|
|
65
|
+
[constants_1.FACTORIAL]: (0, dispatch_1.systemFunction)({ fn: math_1.factorial, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
66
|
+
factorial: (0, dispatch_1.systemFunction)({ fn: math_1.factorial, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
67
|
+
[constants_1.DOUBLE_FACTORIAL]: (0, dispatch_1.systemFunction)({ fn: math_1.doubleFactorial, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
68
|
+
expand: (0, dispatch_1.systemFunction)({ fn: expand_1.expand, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
69
|
+
numeric: (0, dispatch_1.systemFunction)({
|
|
70
|
+
fn: evaluate_1.numeric,
|
|
71
|
+
minArgs: 1,
|
|
72
|
+
maxArgs: 2,
|
|
73
|
+
equationArgs: [0],
|
|
74
|
+
distElWise: false,
|
|
75
|
+
deferArguments: true,
|
|
76
|
+
}),
|
|
77
|
+
round: (0, dispatch_1.systemFunction)({ fn: math_1.round, minArgs: 1, maxArgs: 2, distElWise: true }),
|
|
78
|
+
sign: (0, dispatch_1.systemFunction)({ fn: math_1.sign, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
79
|
+
floor: (0, dispatch_1.systemFunction)({ fn: math_1.floor, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
80
|
+
ceil: (0, dispatch_1.systemFunction)({ fn: math_1.ceiling, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
81
|
+
ceiling: (0, dispatch_1.systemFunction)({ fn: math_1.ceiling, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
82
|
+
trunc: (0, dispatch_1.systemFunction)({ fn: trunc_1.trunc, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
83
|
+
mod: (0, dispatch_1.systemFunction)({ fn: math_1.mod, minArgs: 2, maxArgs: 2, distElWise: true }),
|
|
84
|
+
modinv: (0, dispatch_1.systemFunction)({ fn: math_1.modInv, minArgs: 2, maxArgs: 2, distElWise: true }),
|
|
85
|
+
parens: (0, dispatch_1.systemFunction)({ fn: math_1.parens, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
86
|
+
count: (0, dispatch_1.systemFunction)({ fn: utils_1.count, minArgs: 1, maxArgs: 1, distElWise: false }),
|
|
87
|
+
size: (0, dispatch_1.systemFunction)({ fn: utils_1.size, minArgs: 1, maxArgs: 1, distElWise: false }),
|
|
88
|
+
contains: (0, dispatch_1.systemFunction)({ fn: math_1.contains, minArgs: 2, maxArgs: 2, distElWise: false }),
|
|
89
|
+
max: (0, dispatch_1.systemFunction)({ fn: math_1.max, minArgs: 2, maxArgs: -1, distElWise: true }),
|
|
90
|
+
min: (0, dispatch_1.systemFunction)({ fn: math_1.min, minArgs: 2, maxArgs: -1, distElWise: true }),
|
|
91
|
+
isprime: (0, dispatch_1.systemFunction)({ fn: utils_1.isprime, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
92
|
+
fib: (0, dispatch_1.systemFunction)({ fn: math_1.fibonacci, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
93
|
+
sinc: (0, dispatch_1.systemFunction)({ fn: math_1.sinc, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
94
|
+
Shi: (0, dispatch_1.systemFunction)({ fn: math_1.Shi, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
95
|
+
Si: (0, dispatch_1.systemFunction)({ fn: math_1.Si, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
96
|
+
Chi: (0, dispatch_1.systemFunction)({ fn: math_1.Chi, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
97
|
+
Ci: (0, dispatch_1.systemFunction)({ fn: math_1.Ci, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
98
|
+
Ei: (0, dispatch_1.systemFunction)({ fn: math_1.Ei, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
99
|
+
[constants_1.LI]: (0, dispatch_1.systemFunction)({ fn: math_1.Li, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Expression } from '../core/classes/expression/Expression';
|
|
2
|
+
import type { Vector } from '../core/classes/vector/Vector';
|
|
3
|
+
import type { ExpressionInput } from '../core/types';
|
|
2
4
|
/**
|
|
3
5
|
* Returns the symbolic hypotenuse of two expressions.
|
|
4
6
|
*
|
|
@@ -6,3 +8,5 @@ import { Expression } from '../core/classes/expression/Expression';
|
|
|
6
8
|
* otherwise the result is the principal square root of the sum of squares.
|
|
7
9
|
*/
|
|
8
10
|
export declare function hypot(a: Expression, b: Expression): Expression;
|
|
11
|
+
/** Returns the line through two two-dimensional points, evaluated at `dimension`. */
|
|
12
|
+
export declare function line(p1: Vector, p2: Vector, dimension?: ExpressionInput): Expression;
|
package/output/math/geometry.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hypot = hypot;
|
|
4
|
+
exports.line = line;
|
|
4
5
|
const Expression_1 = require("../core/classes/expression/Expression");
|
|
5
6
|
const shortcuts_1 = require("../core/classes/expression/shortcuts");
|
|
6
7
|
const constants_1 = require("../core/classes/parser/constants");
|
|
7
8
|
const add_1 = require("../core/classes/parser/operations/add");
|
|
8
9
|
const power_1 = require("../core/classes/parser/operations/power");
|
|
10
|
+
const errors_1 = require("../core/errors");
|
|
9
11
|
/**
|
|
10
12
|
* Returns the symbolic hypotenuse of two expressions.
|
|
11
13
|
*
|
|
@@ -30,3 +32,24 @@ function hypot(a, b) {
|
|
|
30
32
|
}
|
|
31
33
|
return retval;
|
|
32
34
|
}
|
|
35
|
+
/** Returns the line through two two-dimensional points, evaluated at `dimension`. */
|
|
36
|
+
function line(p1, p2, dimension = 'x') {
|
|
37
|
+
if (!p1 || !p2 || p1.dataType !== constants_1.VECTOR || p2.dataType !== constants_1.VECTOR || p1.count() !== 2 || p2.count() !== 2) {
|
|
38
|
+
throw new errors_1.DimensionError((0, errors_1.message)('mismatchedDimensions', { function: 'line' }));
|
|
39
|
+
}
|
|
40
|
+
const x1 = p1.elements[0];
|
|
41
|
+
const y1 = p1.elements[1];
|
|
42
|
+
const x2 = p2.elements[0];
|
|
43
|
+
const y2 = p2.elements[1];
|
|
44
|
+
if (!Expression_1.Expression.isExpression(x1) ||
|
|
45
|
+
!Expression_1.Expression.isExpression(y1) ||
|
|
46
|
+
!Expression_1.Expression.isExpression(x2) ||
|
|
47
|
+
!Expression_1.Expression.isExpression(y2)) {
|
|
48
|
+
throw new errors_1.UnexpectedInputError((0, errors_1.message)('wrongInput', {
|
|
49
|
+
expected: 'two-dimensional vectors of scalar expressions',
|
|
50
|
+
received: `${p1.text()}, ${p2.text()}`,
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
const variable = Expression_1.Expression.create(dimension);
|
|
54
|
+
return y1.plus(y2.minus(y1).div(x2.minus(x1)).times(variable.minus(x1)));
|
|
55
|
+
}
|
package/output/math/math.d.ts
CHANGED
|
@@ -26,6 +26,15 @@ import type { SolutionSet } from '../solve/classes/SolutionSet';
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
export declare function sqrt(x: ExpressionInput): Expression;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a copy that renders numeric values in scientific notation.
|
|
31
|
+
*
|
|
32
|
+
* The legacy implementation stored a formatting flag that its formatter did not
|
|
33
|
+
* consume. Nerdamer 2.0 keeps the expression exact and records the requested number
|
|
34
|
+
* of significant digits for formatting. Precision validation follows decimal.js and accepts
|
|
35
|
+
* integer values from 1 through 1e9.
|
|
36
|
+
*/
|
|
37
|
+
export declare function scientific(x: ExpressionInput, significantDigits?: ExpressionInput): Expression;
|
|
29
38
|
/**
|
|
30
39
|
* Computes the nth root of an expression as its principal power.
|
|
31
40
|
*
|
|
@@ -34,6 +43,12 @@ export declare function sqrt(x: ExpressionInput): Expression;
|
|
|
34
43
|
* @returns `x^(1/n)`.
|
|
35
44
|
*/
|
|
36
45
|
export declare function nthroot(x: ExpressionInput, n: ExpressionInput): Expression;
|
|
46
|
+
/** Converts degrees to radians exactly. */
|
|
47
|
+
export declare function radians(x: ExpressionInput): Expression;
|
|
48
|
+
/** Converts radians to degrees exactly. */
|
|
49
|
+
export declare function degrees(x: ExpressionInput): Expression;
|
|
50
|
+
/** Returns the base-10 logarithm using the ordinary logarithm implementation. */
|
|
51
|
+
export declare function log10(x: ExpressionInput): Expression;
|
|
37
52
|
/**
|
|
38
53
|
* Computes the cube root of an expression.
|
|
39
54
|
*
|
|
@@ -67,7 +82,7 @@ export declare function cbrt(x: ExpressionInput): Expression;
|
|
|
67
82
|
* parens(Expression.create('x+1')).text() // "(x+1)"
|
|
68
83
|
* ```
|
|
69
84
|
*/
|
|
70
|
-
export declare function parens(x:
|
|
85
|
+
export declare function parens(x: ExpressionInput): Expression;
|
|
71
86
|
/**
|
|
72
87
|
* Computes the Fibonacci number for an integer index.
|
|
73
88
|
*
|
|
@@ -150,6 +165,18 @@ export declare function doubleFactorial(x: Expression): Expression;
|
|
|
150
165
|
* ```
|
|
151
166
|
*/
|
|
152
167
|
export declare function heaviside(x: Expression): Expression;
|
|
168
|
+
/**
|
|
169
|
+
* Legacy unit-step function. Unlike {@link heaviside}, the value at zero is 1.
|
|
170
|
+
*/
|
|
171
|
+
export declare function step(x: ExpressionInput): Expression;
|
|
172
|
+
/**
|
|
173
|
+
* Rectangular pulse with unit width centered at zero.
|
|
174
|
+
*
|
|
175
|
+
* Returns 1 for |x| < 1/2, 1/2 at |x| = 1/2, and 0 for |x| > 1/2.
|
|
176
|
+
*/
|
|
177
|
+
export declare function rect(x: ExpressionInput): Expression;
|
|
178
|
+
/** Triangular pulse: max(1 - |x|, 0) when the comparison can be resolved. */
|
|
179
|
+
export declare function tri(x: ExpressionInput): Expression;
|
|
153
180
|
/**
|
|
154
181
|
* Computes the Dirac delta function (distribution).
|
|
155
182
|
*
|
|
@@ -284,6 +311,17 @@ export declare function modInv(a: Expression, p: Expression): Expression;
|
|
|
284
311
|
/**
|
|
285
312
|
* Computes the modulo (remainder) of `x` divided by `y`.
|
|
286
313
|
*
|
|
314
|
+
* Exact Gaussian integers use the same quotient rule as Wolfram Language:
|
|
315
|
+
* divide, round the real and imaginary quotient components independently to
|
|
316
|
+
* the nearest integers with midpoint ties going to even, then subtract
|
|
317
|
+
* `y * quotient` from `x`.
|
|
318
|
+
*
|
|
319
|
+
* Complex values outside the Gaussian integers remain symbolic.
|
|
320
|
+
*
|
|
321
|
+
* @see https://reference.wolfram.com/language/ref/Mod.html
|
|
322
|
+
* @see https://reference.wolfram.com/language/ref/Quotient.html
|
|
323
|
+
* @see https://reference.wolfram.com/language/ref/Round.html
|
|
324
|
+
*
|
|
287
325
|
* @param x - The dividend.
|
|
288
326
|
* @param y - The divisor.
|
|
289
327
|
* @returns The remainder of `x / y`.
|
|
@@ -291,11 +329,29 @@ export declare function modInv(a: Expression, p: Expression): Expression;
|
|
|
291
329
|
*
|
|
292
330
|
* @example
|
|
293
331
|
* ```ts
|
|
294
|
-
* mod(Expression.create(10), Expression.create(3)).text()
|
|
295
|
-
* mod(Expression.create(
|
|
332
|
+
* mod(Expression.create(10), Expression.create(3)).text() // "1"
|
|
333
|
+
* mod(Expression.create('5+3*i'), Expression.create('2+i')).text() // "-1"
|
|
296
334
|
* ```
|
|
297
335
|
*/
|
|
298
336
|
export declare function mod(x: Expression, y: Expression): Expression;
|
|
337
|
+
/**
|
|
338
|
+
* Upper incomplete gamma Γ(a, z).
|
|
339
|
+
*
|
|
340
|
+
* Positive integer first arguments are expanded exactly using the finite-sum formula.
|
|
341
|
+
* Other inputs remain symbolic.
|
|
342
|
+
*
|
|
343
|
+
* @see https://dlmf.nist.gov/8.4.E8
|
|
344
|
+
*/
|
|
345
|
+
export declare function gammaIncomplete(a: ExpressionInput, z: ExpressionInput): Expression;
|
|
346
|
+
/**
|
|
347
|
+
* Lower incomplete gamma γ(a, z).
|
|
348
|
+
*
|
|
349
|
+
* Positive integer first arguments use γ(a,z) = Γ(a) - Γ(a,z).
|
|
350
|
+
* Other inputs remain symbolic.
|
|
351
|
+
*
|
|
352
|
+
* @see https://dlmf.nist.gov/8.2.E3
|
|
353
|
+
*/
|
|
354
|
+
export declare function gammaIncompleteLower(a: ExpressionInput, z: ExpressionInput): Expression;
|
|
299
355
|
/**
|
|
300
356
|
* Computes the gamma function Γ(x).
|
|
301
357
|
*
|
|
@@ -615,22 +671,6 @@ export declare function sum(expr: Expression, index: Expression, lower: Expressi
|
|
|
615
671
|
* ```
|
|
616
672
|
*/
|
|
617
673
|
export declare function product(expr: Expression, index: Expression, lower: Expression, upper: Expression): Expression;
|
|
618
|
-
/**
|
|
619
|
-
* Calculates the definite integral using Adaptive Simpson. Note that this function uses
|
|
620
|
-
* native JS number due to severe computational overhead when implemented with Decimal.js.
|
|
621
|
-
*
|
|
622
|
-
* @param f The function being integrated
|
|
623
|
-
* @param dx The variable of integration
|
|
624
|
-
* @param from The lower limit of the integral
|
|
625
|
-
* @param to The upper limit of the integral
|
|
626
|
-
* @returns The numeric value if possible else a symbolic function
|
|
627
|
-
*
|
|
628
|
-
* @example
|
|
629
|
-
* ```ts
|
|
630
|
-
* defint('cos(x)-x^2+6', 'x', 1, 6); // -42.787553149673464
|
|
631
|
-
* ```
|
|
632
|
-
*/
|
|
633
|
-
export declare function defint(f: ExpressionInput, dx: ExpressionInput, from: ExpressionInput, to: ExpressionInput): Expression;
|
|
634
674
|
/**
|
|
635
675
|
* Tests whether a value is present in a supported finite container.
|
|
636
676
|
*
|