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
package/output/api/structures.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Vector = exports.dot = exports.cross = exports.ValuesSet = exports.imatrix = exports.Matrix = exports.nullspace = exports.determinant = exports.Dictionary = exports.Collection = void 0;
|
|
3
|
+
exports.Vector = exports.dot = exports.cross = exports.ValuesSet = exports.imatrix = exports.Matrix = exports.nullspace = exports.invert = exports.determinant = exports.Dictionary = exports.Collection = void 0;
|
|
4
4
|
/** Public structured-value and finite-set APIs. */
|
|
5
5
|
var Collection_1 = require("../core/classes/collection/Collection");
|
|
6
6
|
Object.defineProperty(exports, "Collection", { enumerable: true, get: function () { return Collection_1.Collection; } });
|
|
@@ -8,6 +8,7 @@ var Dictionary_1 = require("../core/classes/dictionary/Dictionary");
|
|
|
8
8
|
Object.defineProperty(exports, "Dictionary", { enumerable: true, get: function () { return Dictionary_1.Dictionary; } });
|
|
9
9
|
var functions_1 = require("../core/classes/matrix/functions");
|
|
10
10
|
Object.defineProperty(exports, "determinant", { enumerable: true, get: function () { return functions_1.determinant; } });
|
|
11
|
+
Object.defineProperty(exports, "invert", { enumerable: true, get: function () { return functions_1.invert; } });
|
|
11
12
|
Object.defineProperty(exports, "nullspace", { enumerable: true, get: function () { return functions_1.nullspace; } });
|
|
12
13
|
var Matrix_1 = require("../core/classes/matrix/Matrix");
|
|
13
14
|
Object.defineProperty(exports, "Matrix", { enumerable: true, get: function () { return Matrix_1.Matrix; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Expression } from '../core/classes/expression/Expression';
|
|
2
|
+
import type { ParserEntity } from '../core/types';
|
|
3
|
+
/** Applies differentiation to both sides when the parser supplies an Equation. */
|
|
4
|
+
export declare function differentiate(expr: ParserEntity, variable?: ParserEntity, n?: ParserEntity): ParserEntity;
|
|
5
|
+
/** Applies integration to both sides when the parser supplies an Equation. */
|
|
6
|
+
export declare function integrateEquation(expr: ParserEntity, variable?: ParserEntity): ParserEntity;
|
|
7
|
+
/** Maps a symbolic direction token to the direction accepted by limit. */
|
|
8
|
+
export declare function directionalLimit(expr: Expression, x: Expression, val: Expression, dir?: Expression): Expression;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.differentiate = differentiate;
|
|
4
|
+
exports.integrateEquation = integrateEquation;
|
|
5
|
+
exports.directionalLimit = directionalLimit;
|
|
6
|
+
const Equation_1 = require("../core/classes/equation/Equation");
|
|
7
|
+
const utils_1 = require("../core/classes/expression/utils");
|
|
8
|
+
const diff_1 = require("./derivative/diff");
|
|
9
|
+
const integrate_1 = require("./integrate/integrate");
|
|
10
|
+
const limit_1 = require("./limit/limit");
|
|
11
|
+
/** Applies differentiation to both sides when the parser supplies an Equation. */
|
|
12
|
+
function differentiate(expr, variable, n) {
|
|
13
|
+
let retval;
|
|
14
|
+
if (Equation_1.Equation.isEquation(expr)) {
|
|
15
|
+
retval = expr.each(e => differentiate(e, variable, n));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
retval = (0, diff_1.diff)(expr, variable, n);
|
|
19
|
+
}
|
|
20
|
+
return retval;
|
|
21
|
+
}
|
|
22
|
+
/** Applies integration to both sides when the parser supplies an Equation. */
|
|
23
|
+
function integrateEquation(expr, variable) {
|
|
24
|
+
let retval;
|
|
25
|
+
if (Equation_1.Equation.isEquation(expr)) {
|
|
26
|
+
retval = expr.each(e => integrateEquation(e, variable));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
retval = (0, integrate_1.integrate)(expr, variable);
|
|
30
|
+
}
|
|
31
|
+
return retval;
|
|
32
|
+
}
|
|
33
|
+
/** Maps a symbolic direction token to the direction accepted by limit. */
|
|
34
|
+
function directionalLimit(expr, x, val, dir) {
|
|
35
|
+
let direction = 'both';
|
|
36
|
+
if (dir) {
|
|
37
|
+
direction = (0, utils_1.assertPlainVariableAndGetString)(dir);
|
|
38
|
+
}
|
|
39
|
+
const retval = (0, limit_1.limit)(expr, x, val, direction);
|
|
40
|
+
return retval;
|
|
41
|
+
}
|
|
@@ -72,7 +72,10 @@ function diff(x, variable, n) {
|
|
|
72
72
|
throw new errors_1.UnsupportedOperationError((0, errors_1.message)('unsupportedOperation'));
|
|
73
73
|
}
|
|
74
74
|
let retval;
|
|
75
|
-
if (
|
|
75
|
+
if (x.hasFunction(constants_1.SYMBOLIC_ACCESSOR, true)) {
|
|
76
|
+
retval = Expression_1.Expression.toFunction(constants_1.DIFF, [x, variable, nth]);
|
|
77
|
+
}
|
|
78
|
+
else if (variables.length === 0 || !x.hasVariable(variable.value) || x.isConstant()) {
|
|
76
79
|
retval = (0, shortcuts_1.zero)();
|
|
77
80
|
}
|
|
78
81
|
// If the variable is not of type VAR or nth is not an integer then return it untouched until either or both are resolved
|
|
@@ -92,9 +95,9 @@ function diff(x, variable, n) {
|
|
|
92
95
|
const n = nth ? Number(nth) - 1 : 0;
|
|
93
96
|
// Pull the derivate of the outside. At this point we've already performed all the required checks.
|
|
94
97
|
const m = x.getMultiplier().times(x.getPower());
|
|
95
|
-
const p = x.getPower().minus(
|
|
98
|
+
const p = x.getPower().minus((0, shortcuts_1.one)());
|
|
96
99
|
const f = Expression_1.Expression.create(x.value);
|
|
97
|
-
const fp = f.pow(p).times(m);
|
|
100
|
+
const fp = p.isZero() ? m : f.pow(p).times(m);
|
|
98
101
|
// Pull the derivative of the inside
|
|
99
102
|
if (f.isVAR()) {
|
|
100
103
|
retval = (0, shortcuts_1.one)();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadCalculusFunctions(): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadCalculusFunctions = loadCalculusFunctions;
|
|
4
|
+
const constants_1 = require("../core/classes/parser/constants");
|
|
5
|
+
const dispatch_1 = require("../core/dispatch");
|
|
6
|
+
const defint_1 = require("../math/defint/defint");
|
|
7
|
+
const math_1 = require("../math/math");
|
|
8
|
+
const adapters_1 = require("./adapters");
|
|
9
|
+
const fresnel_1 = require("./fresnel");
|
|
10
|
+
const ilaplace_1 = require("./laplace/ilaplace");
|
|
11
|
+
const laplace_1 = require("./laplace/laplace");
|
|
12
|
+
function loadCalculusFunctions() {
|
|
13
|
+
Object.assign(dispatch_1.mathFunctionRegistry, {
|
|
14
|
+
diff: (0, dispatch_1.systemFunction)({ fn: adapters_1.differentiate, minArgs: 1, maxArgs: 3, equationArgs: [0], distElWise: true }),
|
|
15
|
+
integrate: (0, dispatch_1.systemFunction)({ fn: adapters_1.integrateEquation, minArgs: 1, maxArgs: 2, equationArgs: [0], distElWise: true }),
|
|
16
|
+
limit: (0, dispatch_1.systemFunction)({ fn: adapters_1.directionalLimit, minArgs: 3, maxArgs: 4, distElWise: true }),
|
|
17
|
+
laplace: (0, dispatch_1.systemFunction)({ fn: laplace_1.laplace, minArgs: 3, maxArgs: 3, distElWise: true }),
|
|
18
|
+
ilaplace: (0, dispatch_1.systemFunction)({ fn: ilaplace_1.ilaplace, minArgs: 3, maxArgs: 3, distElWise: true }),
|
|
19
|
+
sum: (0, dispatch_1.systemFunction)({ fn: math_1.sum, minArgs: 4, maxArgs: 4, distElWise: true }),
|
|
20
|
+
product: (0, dispatch_1.systemFunction)({ fn: math_1.product, minArgs: 4, maxArgs: 4, distElWise: true }),
|
|
21
|
+
defint: (0, dispatch_1.systemFunction)({ fn: defint_1.defint, minArgs: 4, maxArgs: 4, distElWise: true }),
|
|
22
|
+
[constants_1.FRESNEL_S]: (0, dispatch_1.systemFunction)({ fn: fresnel_1.S, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
23
|
+
[constants_1.FRESNEL_C]: (0, dispatch_1.systemFunction)({ fn: fresnel_1.C, minArgs: 1, maxArgs: 1, distElWise: true }),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -293,7 +293,7 @@ function tryIntegrateSqrtQuadratic(expr, dx) {
|
|
|
293
293
|
return undefined;
|
|
294
294
|
}
|
|
295
295
|
if (a.lt((0, shortcuts_1.zero)()) && k.gt((0, shortcuts_1.zero)())) {
|
|
296
|
-
const sqrtNegA = a.times(
|
|
296
|
+
const sqrtNegA = a.times((0, shortcuts_1.minusOne)()).pow((0, shortcuts_1.half)());
|
|
297
297
|
const sqrtK = k.pow((0, shortcuts_1.half)());
|
|
298
298
|
const arg = sqrtNegA.times(u).div(sqrtK);
|
|
299
299
|
return leadingTerm.plus(k.div((0, shortcuts_1.two)().times(sqrtNegA)).times(Expression_1.Expression.toFunction(constants_1.ASIN, [arg])));
|
|
@@ -412,10 +412,10 @@ function tryIntegrateLinearOverQuadratic(expr, dx) {
|
|
|
412
412
|
return result;
|
|
413
413
|
}
|
|
414
414
|
const twoAxPlusB = (0, shortcuts_1.two)().times(a).times(x).plus(b);
|
|
415
|
-
const delta = (0, shortcuts_1.four)().times(a).times(c).minus(b.pow(
|
|
415
|
+
const delta = (0, shortcuts_1.four)().times(a).times(c).minus(b.pow((0, shortcuts_1.two)()));
|
|
416
416
|
let reciprocalIntegral;
|
|
417
417
|
if (delta.isZero()) {
|
|
418
|
-
reciprocalIntegral = (0, shortcuts_1.two)().times(
|
|
418
|
+
reciprocalIntegral = (0, shortcuts_1.two)().times((0, shortcuts_1.minusOne)()).div(twoAxPlusB);
|
|
419
419
|
}
|
|
420
420
|
else if (delta.gt((0, shortcuts_1.zero)())) {
|
|
421
421
|
const sqrtDelta = delta.pow((0, shortcuts_1.half)());
|
|
@@ -425,7 +425,7 @@ function tryIntegrateLinearOverQuadratic(expr, dx) {
|
|
|
425
425
|
.times(Expression_1.Expression.toFunction(constants_1.ATAN, [arg]));
|
|
426
426
|
}
|
|
427
427
|
else if (delta.lt((0, shortcuts_1.zero)())) {
|
|
428
|
-
const sqrtNegDelta = delta.times(
|
|
428
|
+
const sqrtNegDelta = delta.times((0, shortcuts_1.minusOne)()).pow((0, shortcuts_1.half)());
|
|
429
429
|
const ratio = twoAxPlusB.minus(sqrtNegDelta).div(twoAxPlusB.plus(sqrtNegDelta));
|
|
430
430
|
reciprocalIntegral = (0, math_1.log)(ratio).div(sqrtNegDelta);
|
|
431
431
|
}
|
|
@@ -407,7 +407,7 @@ const hyperbolicTrigTable = {
|
|
|
407
407
|
if (p.get('n2').isOne()) {
|
|
408
408
|
return p.fromPattern('(a1*atan(sinh(a2*x1)))/a2');
|
|
409
409
|
}
|
|
410
|
-
else if (p.get('n2').eq(
|
|
410
|
+
else if (p.get('n2').eq((0, shortcuts_1.two)())) {
|
|
411
411
|
return p.fromPattern('(a1*tanh(a2*x1))/a2');
|
|
412
412
|
}
|
|
413
413
|
}
|
|
@@ -418,7 +418,7 @@ const hyperbolicTrigTable = {
|
|
|
418
418
|
if (p.get('n2').isOne()) {
|
|
419
419
|
return p.fromPattern('(a1*log(tanh((a2*x1)/2)))/a2');
|
|
420
420
|
}
|
|
421
|
-
else if (p.get('n2').eq(
|
|
421
|
+
else if (p.get('n2').eq((0, shortcuts_1.two)())) {
|
|
422
422
|
return p.fromPattern('-(a1*coth(a2*x1))/a2');
|
|
423
423
|
}
|
|
424
424
|
}
|
|
@@ -461,7 +461,7 @@ const hyperbolicTrigTable = {
|
|
|
461
461
|
if (p.get('n3').isOne()) {
|
|
462
462
|
return p.fromPattern('(a1*atan(sinh(a2*(a3*x1+a4))))/(a2*a3)');
|
|
463
463
|
}
|
|
464
|
-
else if (p.get('n3').eq(
|
|
464
|
+
else if (p.get('n3').eq((0, shortcuts_1.two)())) {
|
|
465
465
|
return p.fromPattern('(a1*tanh(a2*(a3*x1+a4)))/(a2*a3)');
|
|
466
466
|
}
|
|
467
467
|
}
|
|
@@ -472,7 +472,7 @@ const hyperbolicTrigTable = {
|
|
|
472
472
|
if (p.get('n3').isOne()) {
|
|
473
473
|
return p.fromPattern('(a1*log(tanh((a2*(a3*x1+a4))/2)))/(a2*a3)');
|
|
474
474
|
}
|
|
475
|
-
else if (p.get('n3').eq(
|
|
475
|
+
else if (p.get('n3').eq((0, shortcuts_1.two)())) {
|
|
476
476
|
return p.fromPattern('-(a1*coth(a2*(a3*x1+a4)))/(a2*a3)');
|
|
477
477
|
}
|
|
478
478
|
}
|
|
@@ -538,7 +538,7 @@ const hyperbolicTrigTable = {
|
|
|
538
538
|
if (n4.isOne()) {
|
|
539
539
|
return p.fromPattern('-(a1*sech(a2*x1)^n2)/(a2*n2)');
|
|
540
540
|
}
|
|
541
|
-
if (n2.eq(
|
|
541
|
+
if (n2.eq((0, shortcuts_1.two)())) {
|
|
542
542
|
return p.fromPattern('(a1*tanh(a2*x1)^(n4+1))/(a2*(n4+1))');
|
|
543
543
|
}
|
|
544
544
|
if (n4.isOdd()) {
|
|
@@ -563,7 +563,7 @@ const hyperbolicTrigTable = {
|
|
|
563
563
|
if (n2.isOne()) {
|
|
564
564
|
return p.fromPattern('-(a1*csch(a2*x1)^n4)/(a2*n4)');
|
|
565
565
|
}
|
|
566
|
-
if (n4.eq(
|
|
566
|
+
if (n4.eq((0, shortcuts_1.two)())) {
|
|
567
567
|
return p.fromPattern('-(a1*coth(a2*x1)^(n2+1))/(a2*(n2+1))');
|
|
568
568
|
}
|
|
569
569
|
if (n2.isOdd()) {
|
|
@@ -847,49 +847,49 @@ const specialFunctionTable = {
|
|
|
847
847
|
const knownIntegralsTable = {
|
|
848
848
|
// sqrt(a-b*x^2)
|
|
849
849
|
'a1*(-a2*x1^n1+a3)^n2': p => {
|
|
850
|
-
if (p.get('n1').eq(
|
|
850
|
+
if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isHalf()) {
|
|
851
851
|
return p.fromPattern('(a1*x1*(-a2*x1^2+a3)^(1/2))/2+(a1*a3*asin((a2^(1/2)*x1)/(a3^(1/2))))/(2*a2^(1/2))');
|
|
852
852
|
}
|
|
853
853
|
},
|
|
854
854
|
// diff(atanh(x)) and diff(asin(x))
|
|
855
855
|
'a1/((-a2*x1^n1+a3)^n2)': p => {
|
|
856
|
-
if (p.get('n1').eq(
|
|
856
|
+
if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isOne()) {
|
|
857
857
|
return p.fromPattern('(a1/(a2^(1/2)*a3^(1/2)))*atanh((a2^(1/2)*x1)/(a3^(1/2)))');
|
|
858
858
|
}
|
|
859
|
-
else if (p.get('n1').eq(
|
|
859
|
+
else if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isHalf()) {
|
|
860
860
|
return p.fromPattern('(a1/a2^(1/2))*asin((a2^(1/2)*x1)/(a3^(1/2)))');
|
|
861
861
|
}
|
|
862
862
|
},
|
|
863
863
|
// diff(acos(x))
|
|
864
864
|
'-a1/((-a2*x1^n1+a3)^n2)': p => {
|
|
865
|
-
if (p.get('n1').eq(
|
|
865
|
+
if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isHalf()) {
|
|
866
866
|
return p.fromPattern('(a1/a2^(1/2))*acos((a2^(1/2)*x1)/(a3^(1/2)))');
|
|
867
867
|
}
|
|
868
868
|
},
|
|
869
869
|
// diff(atan(x)) and diff(asinh(x))
|
|
870
870
|
'a1/((a2*x1^n1+a3)^n2)': p => {
|
|
871
|
-
if (p.get('n1').eq(
|
|
871
|
+
if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isOne()) {
|
|
872
872
|
return p.fromPattern('(a1/(a2^(1/2)*a3^(1/2)))*atan((a2^(1/2)*x1)/(a3^(1/2)))');
|
|
873
873
|
}
|
|
874
|
-
else if (p.get('n1').eq(
|
|
874
|
+
else if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isHalf()) {
|
|
875
875
|
return p.fromPattern('(a1/a2^(1/2))*asinh((a2^(1/2)*x1)/(a3^(1/2)))');
|
|
876
876
|
}
|
|
877
877
|
},
|
|
878
878
|
// diff(acot(x))
|
|
879
879
|
'-a1/((a2*x1^n1+a3)^n2)': p => {
|
|
880
|
-
if (p.get('n1').eq(
|
|
880
|
+
if (p.get('n1').eq((0, shortcuts_1.two)()) && p.get('n2').isOne()) {
|
|
881
881
|
return p.fromPattern('(a1/(a2^(1/2)*a3^(1/2)))*acot((a2^(1/2)*x1)/(a3^(1/2)))');
|
|
882
882
|
}
|
|
883
883
|
},
|
|
884
884
|
// diff(asec(x))
|
|
885
885
|
'a1/(x1^n1*(-a2/x1^n2+a3)^n3)': p => {
|
|
886
|
-
if (p.get('n1').isOne() && p.get('n2').eq(
|
|
886
|
+
if (p.get('n1').isOne() && p.get('n2').eq((0, shortcuts_1.two)()) && p.get('n3').isHalf()) {
|
|
887
887
|
return p.fromPattern('(a1/a3^(1/2))*asec((a3^(1/2)*x1)/(a2^(1/2)))');
|
|
888
888
|
}
|
|
889
889
|
},
|
|
890
890
|
// diff(acsc(x))
|
|
891
891
|
'-a1/(x1^n1*(-a2/x1^n2+a3)^n3)': p => {
|
|
892
|
-
if (p.get('n1').isOne() && p.get('n2').eq(
|
|
892
|
+
if (p.get('n1').isOne() && p.get('n2').eq((0, shortcuts_1.two)()) && p.get('n3').isHalf()) {
|
|
893
893
|
return p.fromPattern('(a1/a3^(1/2))*acsc((a3^(1/2)*x1)/(a2^(1/2)))');
|
|
894
894
|
}
|
|
895
895
|
},
|
|
@@ -897,7 +897,7 @@ const knownIntegralsTable = {
|
|
|
897
897
|
// -1/(x*sqrt(1+1/x^2)) -> -acsch(x^-1)
|
|
898
898
|
// after constant stripping: 1/(x*sqrt(1+1/x^2))
|
|
899
899
|
'a1/(x1^n1*(a2/x1^n2+a3)^n3)': p => {
|
|
900
|
-
if (p.get('n1').isOne() && p.get('n2').eq(
|
|
900
|
+
if (p.get('n1').isOne() && p.get('n2').eq((0, shortcuts_1.two)()) && p.get('n3').eq((0, shortcuts_1.half)())) {
|
|
901
901
|
return p.fromPattern('a1*acsch((sqrt(a2/a3))/x1)/sqrt(a2*a3)');
|
|
902
902
|
}
|
|
903
903
|
},
|
|
@@ -99,7 +99,7 @@ function ilaplace(expr, s, t) {
|
|
|
99
99
|
const hasShiftedSquare = den.isSum() &&
|
|
100
100
|
den
|
|
101
101
|
.elementsArray()
|
|
102
|
-
.some(term => term.getPower().eq(
|
|
102
|
+
.some(term => term.getPower().eq((0, shortcuts_1.two)()) && term.getBase().isSum());
|
|
103
103
|
if (!h.isZero() && !hasShiftedSquare) {
|
|
104
104
|
const constant = numCoeffs.hasPower(0) ? numCoeffs.getPower(0) : (0, shortcuts_1.zero)();
|
|
105
105
|
const linear = numCoeffs.hasPower(1) ? numCoeffs.getPower(1) : (0, shortcuts_1.zero)();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tableOfInverseTransforms = void 0;
|
|
4
|
+
const shortcuts_1 = require("../../core/classes/expression/shortcuts");
|
|
4
5
|
const LookupTable_1 = require("../../core/classes/lookupTable/LookupTable");
|
|
5
6
|
const Pattern_1 = require("../../core/converters/Pattern");
|
|
6
7
|
const ilaplaceTable = {
|
|
@@ -27,10 +28,10 @@ const ilaplaceTable = {
|
|
|
27
28
|
if (n1.isOne()) {
|
|
28
29
|
return p.fromPattern('(a1*t^(n2-1)*e^((-a3/a2)*t))/(a2^n2*gamma(n2))');
|
|
29
30
|
}
|
|
30
|
-
if (n1.eq(
|
|
31
|
+
if (n1.eq((0, shortcuts_1.two)()) && n2.isOne()) {
|
|
31
32
|
return p.fromPattern('(a1*sin((a3^(1/2)*t)/(a2^(1/2))))/(a2^(1/2)*a3^(1/2))');
|
|
32
33
|
}
|
|
33
|
-
if (n1.eq(
|
|
34
|
+
if (n1.eq((0, shortcuts_1.two)()) && n2.eq((0, shortcuts_1.two)())) {
|
|
34
35
|
return p
|
|
35
36
|
.fromPattern('(a1*sin((a3^(1/2)*t)/(a2^(1/2))))/(2*a2^(1/2)*a3^(3/2))')
|
|
36
37
|
.minus(p.fromPattern('(a1*t*cos((a3^(1/2)*t)/(a2^(1/2))))/(2*a2*a3)'));
|
|
@@ -45,18 +46,18 @@ const ilaplaceTable = {
|
|
|
45
46
|
// (a1*t*sin((a3^(1/2)*t)/(a2^(1/2)))) / (2*a2^(3/2)*a3^(1/2))
|
|
46
47
|
'(a1*x1^n1)/((a2*x1^n2+a3)^n3)': p => {
|
|
47
48
|
const { n1, n2, n3 } = p.references;
|
|
48
|
-
if (!n2.eq(
|
|
49
|
+
if (!n2.eq((0, shortcuts_1.two)())) {
|
|
49
50
|
return undefined;
|
|
50
51
|
}
|
|
51
52
|
if (n1.isOne()) {
|
|
52
53
|
if (n3.isOne()) {
|
|
53
54
|
return p.fromPattern('(a1*cos((a3^(1/2)*t)/(a2^(1/2))))/a2');
|
|
54
55
|
}
|
|
55
|
-
if (n3.eq(
|
|
56
|
+
if (n3.eq((0, shortcuts_1.two)())) {
|
|
56
57
|
return p.fromPattern('(a1*t*sin((a3^(1/2)*t)/(a2^(1/2))))/(2*a2^(3/2)*a3^(1/2))');
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
if (n1.eq(
|
|
60
|
+
if (n1.eq((0, shortcuts_1.two)()) && n3.eq((0, shortcuts_1.two)())) {
|
|
60
61
|
return p
|
|
61
62
|
.fromPattern('(a1*sin((a3^(1/2)*t)/(a2^(1/2))))/(2*a2^(1/2)*a3^(1/2))')
|
|
62
63
|
.plus(p.fromPattern('(a1*t*cos((a3^(1/2)*t)/(a2^(1/2))))/(2*a2)'));
|
|
@@ -68,7 +69,7 @@ const ilaplaceTable = {
|
|
|
68
69
|
// 1 / (((s-b)^2 + c^2)^n) and 1 / (((s-b)^2 - c^2)^n)
|
|
69
70
|
'a1/((a2*(a3*x1^n1+a4)^n2+a5)^n3)': p => {
|
|
70
71
|
const { n1, n2, n3, a5 } = p.references;
|
|
71
|
-
if (!n1.isOne() || !n2.eq(
|
|
72
|
+
if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)())) {
|
|
72
73
|
return undefined;
|
|
73
74
|
}
|
|
74
75
|
// Hyperbolic branch: a5 < 0
|
|
@@ -76,7 +77,7 @@ const ilaplaceTable = {
|
|
|
76
77
|
if (n3.isOne()) {
|
|
77
78
|
return p.fromPattern('(a1*e^((-a4/a3)*t)*sinh((((-a5)^(1/2))*t)/(a2^(1/2)*a3)))/(a2^(1/2)*a3*((-a5)^(1/2)))');
|
|
78
79
|
}
|
|
79
|
-
if (n3.eq(
|
|
80
|
+
if (n3.eq((0, shortcuts_1.two)())) {
|
|
80
81
|
return p.fromPattern('(a1*e^((-a4/a3)*t)*((((-a5)^(1/2))*t*cosh((((-a5)^(1/2))*t)/(a2^(1/2)*a3)))/(a2^(1/2)*a3)-sinh((((-a5)^(1/2))*t)/(a2^(1/2)*a3))))/(2*a2^(1/2)*a3*((-a5)^(3/2)))');
|
|
81
82
|
}
|
|
82
83
|
return undefined;
|
|
@@ -85,7 +86,7 @@ const ilaplaceTable = {
|
|
|
85
86
|
if (n3.isOne()) {
|
|
86
87
|
return p.fromPattern('(a1*e^((-a4/a3)*t)*sin((a5^(1/2)*t)/(a2^(1/2)*a3)))/(a2^(1/2)*a3*a5^(1/2))');
|
|
87
88
|
}
|
|
88
|
-
if (n3.eq(
|
|
89
|
+
if (n3.eq((0, shortcuts_1.two)())) {
|
|
89
90
|
return p.fromPattern('(a1*e^((-a4/a3)*t)*(sin((a5^(1/2)*t)/(a2^(1/2)*a3))-(a5^(1/2)*t*cos((a5^(1/2)*t)/(a2^(1/2)*a3)))/(a2^(1/2)*a3)))/(2*a2^(1/2)*a3*a5^(3/2))');
|
|
90
91
|
}
|
|
91
92
|
return undefined;
|
|
@@ -98,7 +99,7 @@ const ilaplaceTable = {
|
|
|
98
99
|
// (c*(s-a)) / ((b*(d*(s-a))^2 + e)^n)
|
|
99
100
|
'(a1*((a6*x1^n4+a7)^n5))/((a2*(a3*x1^n1+a4)^n2+a5)^n3)': p => {
|
|
100
101
|
const { n1, n2, n3, n4, n5, a3, a4, a5, a6, a7 } = p.references;
|
|
101
|
-
if (!n1.isOne() || !n2.eq(
|
|
102
|
+
if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n4.isOne() || !n5.isOne()) {
|
|
102
103
|
return undefined;
|
|
103
104
|
}
|
|
104
105
|
// numerator affine term must be a scalar multiple of denominator affine term
|
|
@@ -110,7 +111,7 @@ const ilaplaceTable = {
|
|
|
110
111
|
if (n3.isOne()) {
|
|
111
112
|
return p.fromPattern('(a1*a6*e^((-a4/a3)*t)*cosh((((-a5)^(1/2))*t)/(a2^(1/2)*a3)))/(a2*a3^2)');
|
|
112
113
|
}
|
|
113
|
-
if (n3.eq(
|
|
114
|
+
if (n3.eq((0, shortcuts_1.two)())) {
|
|
114
115
|
return p.fromPattern('(a1*a6*t*e^((-a4/a3)*t)*sinh((((-a5)^(1/2))*t)/(a2^(1/2)*a3)))/(2*a2^(3/2)*a3^3*((-a5)^(1/2)))');
|
|
115
116
|
}
|
|
116
117
|
return undefined;
|
|
@@ -119,7 +120,7 @@ const ilaplaceTable = {
|
|
|
119
120
|
if (n3.isOne()) {
|
|
120
121
|
return p.fromPattern('(a1*a6*e^((-a4/a3)*t)*cos((a5^(1/2)*t)/(a2^(1/2)*a3)))/(a2*a3^2)');
|
|
121
122
|
}
|
|
122
|
-
if (n3.eq(
|
|
123
|
+
if (n3.eq((0, shortcuts_1.two)())) {
|
|
123
124
|
return p.fromPattern('(a1*a6*t*e^((-a4/a3)*t)*sin((a5^(1/2)*t)/(a2^(1/2)*a3)))/(2*a2^(3/2)*a3^3*a5^(1/2))');
|
|
124
125
|
}
|
|
125
126
|
return undefined;
|
|
@@ -127,7 +128,7 @@ const ilaplaceTable = {
|
|
|
127
128
|
// ((c*(s-a))^2) / ((b*(d*(s-a))^2 + e)^2)
|
|
128
129
|
'(a1*(a6*x1^n4+a7)^n5)/((a2*(a3*x1^n1+a4)^n2+a5)^n3)': p => {
|
|
129
130
|
const { n1, n2, n3, n4, n5, a3, a4, a5, a6, a7 } = p.references;
|
|
130
|
-
if (!n1.isOne() || !n2.eq(
|
|
131
|
+
if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n3.eq((0, shortcuts_1.two)()) || !n4.isOne() || !n5.eq((0, shortcuts_1.two)())) {
|
|
131
132
|
return undefined;
|
|
132
133
|
}
|
|
133
134
|
// numerator affine term must be a scalar multiple of denominator affine term
|
|
@@ -144,7 +145,7 @@ const ilaplaceTable = {
|
|
|
144
145
|
// a / ((s-b)^2 - c^2)
|
|
145
146
|
'a1/(a2*(a3*x1^n1+a4)^n2-a5)': p => {
|
|
146
147
|
const { n1, n2 } = p.references;
|
|
147
|
-
if (!n1.isOne() || !n2.eq(
|
|
148
|
+
if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)())) {
|
|
148
149
|
return undefined;
|
|
149
150
|
}
|
|
150
151
|
return p.fromPattern('(a1*e^((-a4/a3)*t)*sinh((a5^(1/2)*t)/(a2^(1/2)*a3)))/(a2^(1/2)*a3*a5^(1/2))');
|
|
@@ -152,7 +153,7 @@ const ilaplaceTable = {
|
|
|
152
153
|
// (s-b) / ((s-b)^2 - c^2)
|
|
153
154
|
'(a1*(a6*x1^n3+a7)^n4)/(a2*(a3*x1^n1+a4)^n2-a5)': p => {
|
|
154
155
|
const { n1, n2, n3, n4 } = p.references;
|
|
155
|
-
if (!n1.isOne() || !n2.eq(
|
|
156
|
+
if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n3.isOne() || !n4.isOne()) {
|
|
156
157
|
return undefined;
|
|
157
158
|
}
|
|
158
159
|
return p.fromPattern('(a1*e^((-a4/a3)*t)*cosh((a5^(1/2)*t)/(a2^(1/2)*a3)))/(a2*a3^2)');
|
|
@@ -160,7 +161,7 @@ const ilaplaceTable = {
|
|
|
160
161
|
// a / (((s-b)^2 - c^2)^2)
|
|
161
162
|
'a1/((a2*(a3*x1^n1+a4)^n2-a5)^n3)': p => {
|
|
162
163
|
const { n1, n2, n3 } = p.references;
|
|
163
|
-
if (!n1.isOne() || !n2.eq(
|
|
164
|
+
if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n3.eq((0, shortcuts_1.two)())) {
|
|
164
165
|
return undefined;
|
|
165
166
|
}
|
|
166
167
|
return p.fromPattern('(a1*e^((-a4/a3)*t)*(a5^(1/2)*t*cosh((a5^(1/2)*t)/(a2^(1/2)*a3))-a2^(1/2)*a3*sinh((a5^(1/2)*t)/(a2^(1/2)*a3))))/(2*a2*a3^2*a5^(3/2))');
|
|
@@ -168,7 +169,7 @@ const ilaplaceTable = {
|
|
|
168
169
|
// (s-b) / (((s-b)^2 - c^2)^2)
|
|
169
170
|
'(a1*(a6*x1^n3+a7)^n4)/((a2*(a3*x1^n1+a4)^n2-a5)^n5)': p => {
|
|
170
171
|
const { n1, n2, n3, n4, n5 } = p.references;
|
|
171
|
-
if (!n1.isOne() || !n2.eq(
|
|
172
|
+
if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n3.isOne() || !n4.isOne() || !n5.eq((0, shortcuts_1.two)())) {
|
|
172
173
|
return undefined;
|
|
173
174
|
}
|
|
174
175
|
return p.fromPattern('(a1*t*e^((-a4/a3)*t)*sinh((a5^(1/2)*t)/(a2^(1/2)*a3)))/(2*a2^(1/2)*a3*a5^(1/2))');
|
|
@@ -176,7 +177,7 @@ const ilaplaceTable = {
|
|
|
176
177
|
// (A*(B*(s-a)^2+C)) / ((D*(s-a)^2+E)^2)
|
|
177
178
|
'(a1*((a2*(a3*x1^n1+a4)^n2+a5)^n3))/((a6*(a7*x1^n4+a8)^n5+a9)^n6)': p => {
|
|
178
179
|
const { n1, n2, n3, n4, n5, n6, _a2, a3, a4, _a6, a7, a8, _a9 } = p.references;
|
|
179
|
-
if (!n1.isOne() || !n2.eq(
|
|
180
|
+
if (!n1.isOne() || !n2.eq((0, shortcuts_1.two)()) || !n3.isOne() || !n4.isOne() || !n5.eq((0, shortcuts_1.two)()) || !n6.eq((0, shortcuts_1.two)())) {
|
|
180
181
|
return undefined;
|
|
181
182
|
}
|
|
182
183
|
if (!a3.eq(a7) || !a4.eq(a8)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tableOfTransforms = void 0;
|
|
4
|
+
const shortcuts_1 = require("../../core/classes/expression/shortcuts");
|
|
4
5
|
const LookupTable_1 = require("../../core/classes/lookupTable/LookupTable");
|
|
5
6
|
const diff_1 = require("../derivative/diff");
|
|
6
7
|
const laplaceTable = {
|
|
@@ -12,7 +13,7 @@ const laplaceTable = {
|
|
|
12
13
|
'a1*x1^n1': p => {
|
|
13
14
|
const { n1 } = p.references;
|
|
14
15
|
// Reject Gamma poles: n1 = -1, -2, -3, ...
|
|
15
|
-
if (n1.isNegative() && n1.plus(
|
|
16
|
+
if (n1.isNegative() && n1.plus((0, shortcuts_1.one)()).isInteger()) {
|
|
16
17
|
return undefined;
|
|
17
18
|
}
|
|
18
19
|
return p.fromPattern('a1*gamma(n1+1)/s^(n1+1)');
|
|
@@ -45,7 +46,7 @@ const laplaceTable = {
|
|
|
45
46
|
return undefined;
|
|
46
47
|
}
|
|
47
48
|
// Reject the pole at Gamma(0), Gamma(-1), ...
|
|
48
|
-
if (n2.isNegative() && n2.plus(
|
|
49
|
+
if (n2.isNegative() && n2.plus((0, shortcuts_1.one)()).isInteger()) {
|
|
49
50
|
return undefined;
|
|
50
51
|
}
|
|
51
52
|
return p.fromPattern('a1*gamma(n2+1)/(s-log(a2)*a3)^(n2+1)');
|
|
@@ -923,7 +923,7 @@ function tryComposition(expr, x, val, dir, depth) {
|
|
|
923
923
|
const gPrime = (0, diff_1.diff)(g, x);
|
|
924
924
|
if (!gPrime.isZero()) {
|
|
925
925
|
// L'Hôpital on f/(1/g): result = -f'·g²/g'
|
|
926
|
-
let lhopitalExpr = (0, simplify_1.simplify)(fPrime.times(g.pow(
|
|
926
|
+
let lhopitalExpr = (0, simplify_1.simplify)(fPrime.times(g.pow((0, shortcuts_1.two)())).div(gPrime).neg());
|
|
927
927
|
// Multiply back any remaining factors
|
|
928
928
|
for (let i = 0; i < factors.length; i++) {
|
|
929
929
|
if (i !== zeroIdx && i !== infIdx) {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Assumption = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const common_1 = require("../../common/common");
|
|
9
|
+
const errors_1 = require("../../errors");
|
|
9
10
|
const Expression_1 = require("../expression/Expression");
|
|
10
11
|
const constants_1 = require("../parser/constants");
|
|
11
12
|
const Rational_1 = require("../rational/Rational");
|
|
@@ -19,7 +20,7 @@ function normalizeAssumptionValue(value) {
|
|
|
19
20
|
let decimal;
|
|
20
21
|
let exact;
|
|
21
22
|
if (Rational_1.Rational.isRational(value)) {
|
|
22
|
-
exact =
|
|
23
|
+
exact = value.copy();
|
|
23
24
|
decimal = exact.toDecimal();
|
|
24
25
|
}
|
|
25
26
|
else {
|
|
@@ -63,7 +64,7 @@ function parseNumber(value) {
|
|
|
63
64
|
}
|
|
64
65
|
const n = new decimal_js_1.default(v);
|
|
65
66
|
if (n.isNaN()) {
|
|
66
|
-
throw new Error(
|
|
67
|
+
throw new Error((0, errors_1.message)('invalidDecimal', { value: String(value) }));
|
|
67
68
|
}
|
|
68
69
|
return n;
|
|
69
70
|
}
|
|
@@ -158,7 +159,10 @@ class Assumption {
|
|
|
158
159
|
if (boundComparison === undefined ||
|
|
159
160
|
boundComparison > 0 ||
|
|
160
161
|
(boundComparison === 0 && !(normalizedStartInclusive && normalizedEndInclusive))) {
|
|
161
|
-
throw new Error(
|
|
162
|
+
throw new Error((0, errors_1.message)('invalidInterval', {
|
|
163
|
+
start: startValue.toString(),
|
|
164
|
+
end: endValue.toString(),
|
|
165
|
+
}));
|
|
162
166
|
}
|
|
163
167
|
this.start = Object.freeze({
|
|
164
168
|
value: startValue,
|
|
@@ -226,21 +230,21 @@ class Assumption {
|
|
|
226
230
|
*/
|
|
227
231
|
static parse(expr) {
|
|
228
232
|
if (typeof expr !== 'string') {
|
|
229
|
-
throw new Error(
|
|
233
|
+
throw new Error((0, errors_1.message)('invalidAssumption', { input: String(expr) }));
|
|
230
234
|
}
|
|
231
235
|
const s = expr.replace(/\s+/g, '');
|
|
232
236
|
if (!s) {
|
|
233
|
-
throw new Error(
|
|
237
|
+
throw new Error((0, errors_1.message)('invalidAssumption', { input: expr }));
|
|
234
238
|
}
|
|
235
239
|
// Must have at least a one-character identifier, operator, and value.
|
|
236
240
|
if (s.length < 3) {
|
|
237
|
-
throw new Error(
|
|
241
|
+
throw new Error((0, errors_1.message)('invalidAssumption', { input: expr }));
|
|
238
242
|
}
|
|
239
243
|
let i = 0;
|
|
240
244
|
// Parse the variable identifier first. Assumptions are attached to plain
|
|
241
245
|
// variables rather than arbitrary symbolic expressions.
|
|
242
246
|
if (!isIdentStart(s[i])) {
|
|
243
|
-
throw new Error(
|
|
247
|
+
throw new Error((0, errors_1.message)('assumptionIdentifierExpected'));
|
|
244
248
|
}
|
|
245
249
|
let j = i + 1;
|
|
246
250
|
while (j < s.length && isIdentChar(s[j])) {
|
|
@@ -262,11 +266,11 @@ class Assumption {
|
|
|
262
266
|
}
|
|
263
267
|
}
|
|
264
268
|
if (!op) {
|
|
265
|
-
throw new Error(
|
|
269
|
+
throw new Error((0, errors_1.message)('assumptionOperatorMissing'));
|
|
266
270
|
}
|
|
267
271
|
const valueStr = s.slice(i);
|
|
268
272
|
if (!valueStr) {
|
|
269
|
-
throw new Error(
|
|
273
|
+
throw new Error((0, errors_1.message)('assumptionValueMissing'));
|
|
270
274
|
}
|
|
271
275
|
const value = parseNumber(valueStr);
|
|
272
276
|
let retval;
|
|
@@ -288,7 +292,7 @@ class Assumption {
|
|
|
288
292
|
retval = { symbol, assumption: Assumption.exactly(value) };
|
|
289
293
|
break;
|
|
290
294
|
default:
|
|
291
|
-
throw new Error(
|
|
295
|
+
throw new Error((0, errors_1.message)('assumptionOperatorUnsupported', { operator: op }));
|
|
292
296
|
}
|
|
293
297
|
return retval;
|
|
294
298
|
}
|
|
@@ -74,6 +74,12 @@ export declare function forgetAssumptionFor(x: Expression | string): void;
|
|
|
74
74
|
* @param x - Plain variable expression or variable name.
|
|
75
75
|
* @returns The registered interval, or `undefined` when no assumption is available.
|
|
76
76
|
*/
|
|
77
|
+
/**
|
|
78
|
+
* Returns a snapshot of all currently registered assumptions.
|
|
79
|
+
*
|
|
80
|
+
* Changing the returned Map does not change Nerdamer's active assumptions.
|
|
81
|
+
*/
|
|
82
|
+
export declare function getAssumptions(): Map<string, Assumption>;
|
|
77
83
|
export declare function getAssumptionFor(x: Expression | string): Assumption | undefined;
|
|
78
84
|
/**
|
|
79
85
|
* Parser marker used by `assume(...)` so comparison operators register constraints
|
|
@@ -4,6 +4,7 @@ exports.hasAssumptions = hasAssumptions;
|
|
|
4
4
|
exports.assume = assume;
|
|
5
5
|
exports.clearAssumptions = clearAssumptions;
|
|
6
6
|
exports.forgetAssumptionFor = forgetAssumptionFor;
|
|
7
|
+
exports.getAssumptions = getAssumptions;
|
|
7
8
|
exports.getAssumptionFor = getAssumptionFor;
|
|
8
9
|
exports.assuming = assuming;
|
|
9
10
|
exports.forget = forget;
|
|
@@ -110,6 +111,14 @@ function forgetAssumptionFor(x) {
|
|
|
110
111
|
* @param x - Plain variable expression or variable name.
|
|
111
112
|
* @returns The registered interval, or `undefined` when no assumption is available.
|
|
112
113
|
*/
|
|
114
|
+
/**
|
|
115
|
+
* Returns a snapshot of all currently registered assumptions.
|
|
116
|
+
*
|
|
117
|
+
* Changing the returned Map does not change Nerdamer's active assumptions.
|
|
118
|
+
*/
|
|
119
|
+
function getAssumptions() {
|
|
120
|
+
return new Map(ASSUMPTIONS);
|
|
121
|
+
}
|
|
113
122
|
function getAssumptionFor(x) {
|
|
114
123
|
let symbol;
|
|
115
124
|
if (Expression_1.Expression.isExpression(x) && x.isPlainVariable()) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadAssumptionFunctions(): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadAssumptionFunctions = loadAssumptionFunctions;
|
|
4
|
+
const dispatch_1 = require("../../dispatch");
|
|
5
|
+
const assume_1 = require("./assume");
|
|
6
|
+
function loadAssumptionFunctions() {
|
|
7
|
+
Object.assign(dispatch_1.mathFunctionRegistry, {
|
|
8
|
+
assume: (0, dispatch_1.systemFunction)({ fn: assume_1.assuming, minArgs: 1, maxArgs: 1, distElWise: false }),
|
|
9
|
+
forget: (0, dispatch_1.systemFunction)({ fn: assume_1.forget, minArgs: 1, maxArgs: 1, distElWise: false }),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Collection = void 0;
|
|
4
4
|
const StructuredEntity_1 = require("../../common/classes/StructuredEntity");
|
|
5
5
|
const common_1 = require("../../common/common");
|
|
6
|
+
const errors_1 = require("../../errors");
|
|
6
7
|
const constants_1 = require("../parser/constants");
|
|
7
8
|
/**
|
|
8
9
|
* An ordered heterogeneous collection of parser entities.
|
|
@@ -56,7 +57,11 @@ class Collection extends StructuredEntity_1.StructuredEntity {
|
|
|
56
57
|
__get__(indices) {
|
|
57
58
|
const index = indices[0];
|
|
58
59
|
if (index < 0 || index >= this.elements.length) {
|
|
59
|
-
throw new RangeError(
|
|
60
|
+
throw new RangeError((0, errors_1.message)('indexOutOfBounds', {
|
|
61
|
+
index: String(index),
|
|
62
|
+
type: 'Collection',
|
|
63
|
+
length: String(this.elements.length),
|
|
64
|
+
}));
|
|
60
65
|
}
|
|
61
66
|
return this.elements[index];
|
|
62
67
|
}
|
|
@@ -68,7 +73,11 @@ class Collection extends StructuredEntity_1.StructuredEntity {
|
|
|
68
73
|
__set__(indices, value) {
|
|
69
74
|
const index = indices[0];
|
|
70
75
|
if (index < 0 || index >= this.elements.length) {
|
|
71
|
-
throw new RangeError(
|
|
76
|
+
throw new RangeError((0, errors_1.message)('indexOutOfBounds', {
|
|
77
|
+
index: String(index),
|
|
78
|
+
type: 'Collection',
|
|
79
|
+
length: String(this.elements.length),
|
|
80
|
+
}));
|
|
72
81
|
}
|
|
73
82
|
this.elements[index] = value;
|
|
74
83
|
}
|