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/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { sqcomp } from './algebra/utils';
|
|
2
1
|
import { Assumption } from './core/classes/assumption/Assumption';
|
|
3
2
|
import { Collection } from './core/classes/collection/Collection';
|
|
4
3
|
import { Dictionary } from './core/classes/dictionary/Dictionary';
|
|
@@ -12,10 +11,10 @@ import { Rational } from './core/classes/rational/Rational';
|
|
|
12
11
|
import { ValuesSet } from './core/classes/valuesSet/ValuesSet';
|
|
13
12
|
import { Vector } from './core/classes/vector/Vector';
|
|
14
13
|
import { Converter } from './core/converters/Converter';
|
|
15
|
-
import
|
|
14
|
+
import * as errors from './core/errors';
|
|
16
15
|
import { imagPart, polarForm, realPart, rectForm } from './core/functions/complex';
|
|
17
|
-
import {
|
|
18
|
-
import { isprime } from './math/utils';
|
|
16
|
+
import { gammaIncomplete, gammaIncompleteLower } from './math/math';
|
|
17
|
+
import { continuedFraction, isprime } from './math/utils';
|
|
19
18
|
import { SolutionSet } from './solve/classes/SolutionSet';
|
|
20
19
|
import type { OptionsObject, ParserConstants, ParserValuesObject, TextOptions } from './core/classes/parser/types';
|
|
21
20
|
import type { ExpressionInput, ParserEntity } from './core/types';
|
|
@@ -166,8 +165,9 @@ declare namespace nerdamer {
|
|
|
166
165
|
var setConstant: (name: string, value: number | string) => typeof nerdamer;
|
|
167
166
|
var getConstant: (name: string) => string;
|
|
168
167
|
var set: (setting: string | OptionsObject, value?: boolean | string | number | bigint) => typeof nerdamer;
|
|
169
|
-
var get: (setting: Parameters<typeof Parser.get>[0] | "PRECISION") => number | bigint | boolean |
|
|
168
|
+
var get: (setting: Parameters<typeof Parser.get>[0] | "PRECISION") => number | bigint | boolean | errors.Language;
|
|
170
169
|
var getOperator: (symbol: string) => import("./api/parser").Operator | undefined;
|
|
170
|
+
var isReserved: (name: string) => boolean;
|
|
171
171
|
var setOperator: (operator: Parameters<typeof Parser.setOperator>[0], action?: Parameters<typeof Parser.setOperator>[1]) => typeof nerdamer;
|
|
172
172
|
var aliasOperator: (symbol: string, alias: string) => typeof nerdamer;
|
|
173
173
|
var setVar: (name: string, value: number | string | "delete") => void;
|
|
@@ -177,10 +177,10 @@ declare namespace nerdamer {
|
|
|
177
177
|
user: string[];
|
|
178
178
|
system: string[];
|
|
179
179
|
};
|
|
180
|
-
var symbols: typeof import("./core
|
|
180
|
+
var symbols: typeof import("./api/core").symbols;
|
|
181
181
|
var version: () => string;
|
|
182
182
|
var errors: typeof import("./core/errors");
|
|
183
|
-
var buildFunction:
|
|
183
|
+
var buildFunction: (x: ExpressionInput, argsArray?: string[]) => (...args: number[]) => number;
|
|
184
184
|
var classes: {
|
|
185
185
|
Expression: typeof Expression;
|
|
186
186
|
Rational: typeof Rational;
|
|
@@ -202,15 +202,17 @@ declare namespace nerdamer {
|
|
|
202
202
|
VALUE_SETS: string[];
|
|
203
203
|
WHITE_SPACE: string[];
|
|
204
204
|
KNOWN_VALUES: Record<string, ParserEntity>;
|
|
205
|
+
extractDictionaryKey(scope: import("./core/common/classes/Scope").Scope, values?: ParserValuesObject, assertive?: boolean): string;
|
|
205
206
|
extractIndices(scope: import("./core/common/classes/Scope").Scope, values?: ParserValuesObject, assertive?: boolean): number[] | Expression[];
|
|
206
|
-
|
|
207
|
+
resolveSymbolicAccess(symbolicTarget: Expression, resolvedTarget: ParserEntity, indices: Expression[]): ParserEntity;
|
|
207
208
|
aliasOperator(symbol: string, alias: string): /*elided*/ any;
|
|
208
209
|
create(): /*elided*/ any;
|
|
209
210
|
evaluate(str: string, values?: ParserValuesObject): ParserEntity;
|
|
210
|
-
get(setting: keyof typeof import("./core/Settings").Settings): number | bigint | boolean |
|
|
211
|
+
get(setting: keyof typeof import("./core/Settings").Settings): number | bigint | boolean | errors.Language;
|
|
211
212
|
getI(): string;
|
|
212
213
|
getOperator(symbol: string): import("./api/parser").Operator | undefined;
|
|
213
214
|
getPrecision(): number;
|
|
215
|
+
isReserved(name: string): boolean;
|
|
214
216
|
parse(str: ExpressionInput, values?: ParserValuesObject): ParserEntity;
|
|
215
217
|
parseRPN(rpn: import("./core/common/classes/Scope").Scope, values?: ParserValuesObject, assertive?: boolean): ParserEntity;
|
|
216
218
|
parseTeXRPN(rpn: import("./core/common/classes/Scope").Scope): string;
|
|
@@ -232,9 +234,9 @@ declare namespace nerdamer {
|
|
|
232
234
|
var acos: typeof import("./math/trig").acos;
|
|
233
235
|
var asin: typeof import("./math/trig").asin;
|
|
234
236
|
var atan: typeof import("./math/trig").atan;
|
|
235
|
-
var arccos:
|
|
236
|
-
var arcsin:
|
|
237
|
-
var arctan:
|
|
237
|
+
var arccos: (x: ExpressionInput) => Expression;
|
|
238
|
+
var arcsin: (x: ExpressionInput) => Expression;
|
|
239
|
+
var arctan: (x: ExpressionInput) => Expression;
|
|
238
240
|
var atan2: typeof import("./math/trig").atan2;
|
|
239
241
|
var sec: typeof import("./math/trig").sec;
|
|
240
242
|
var csc: typeof import("./math/trig").csc;
|
|
@@ -255,6 +257,9 @@ declare namespace nerdamer {
|
|
|
255
257
|
var acsch: typeof import("./math/trig").acsch;
|
|
256
258
|
var acoth: typeof import("./math/trig").acoth;
|
|
257
259
|
var log: typeof import("./math/math").log;
|
|
260
|
+
var log10: typeof import("./math/math").log10;
|
|
261
|
+
var radians: typeof import("./math/math").radians;
|
|
262
|
+
var degrees: typeof import("./math/math").degrees;
|
|
258
263
|
var exp: typeof import("./math/math").exp;
|
|
259
264
|
var sqrt: typeof import("./math/math").sqrt;
|
|
260
265
|
var cbrt: typeof import("./math/math").cbrt;
|
|
@@ -266,14 +271,14 @@ declare namespace nerdamer {
|
|
|
266
271
|
var max: typeof import("./math/math").max;
|
|
267
272
|
var round: typeof import("./math/math").round;
|
|
268
273
|
var floor: typeof import("./math/math").floor;
|
|
269
|
-
var ceil:
|
|
274
|
+
var ceil: (x: ExpressionInput) => Expression;
|
|
270
275
|
var trunc: typeof import("./math/trunc").trunc;
|
|
271
276
|
var hypot: typeof import("./math/geometry").hypot;
|
|
272
|
-
var fact:
|
|
277
|
+
var fact: (x: Expression) => Expression;
|
|
273
278
|
var factorial: typeof import("./math/math").factorial;
|
|
274
|
-
var dfact:
|
|
275
|
-
var dfactorial:
|
|
276
|
-
var fib:
|
|
279
|
+
var dfact: (x: Expression) => Expression;
|
|
280
|
+
var dfactorial: (x: Expression) => Expression;
|
|
281
|
+
var fib: (x: ExpressionInput) => Expression;
|
|
277
282
|
var mod: typeof import("./math/math").mod;
|
|
278
283
|
var modInv: typeof import("./math/math").modInv;
|
|
279
284
|
var isPrime: typeof isprime;
|
|
@@ -285,10 +290,15 @@ declare namespace nerdamer {
|
|
|
285
290
|
var conjugate: typeof import("./core/functions/complex").conjugate;
|
|
286
291
|
var csgn: typeof import("./core/functions/complex").csgn;
|
|
287
292
|
var gamma: typeof import("./math/math").gamma;
|
|
293
|
+
var gamma_incomplete: typeof gammaIncomplete;
|
|
294
|
+
var gamma_incomplete_lower: typeof gammaIncompleteLower;
|
|
288
295
|
var erf: typeof import("./math/math").erf;
|
|
289
296
|
var erfc: typeof import("./math/math").erfc;
|
|
290
297
|
var heaviside: typeof import("./math/math").heaviside;
|
|
291
|
-
var
|
|
298
|
+
var step: typeof import("./math/math").step;
|
|
299
|
+
var rect: typeof import("./math/math").rect;
|
|
300
|
+
var tri: typeof import("./math/math").tri;
|
|
301
|
+
var delta: (x: Expression) => Expression;
|
|
292
302
|
var Ci: typeof import("./math/math").Ci;
|
|
293
303
|
var Chi: typeof import("./math/math").Chi;
|
|
294
304
|
var Si: typeof import("./math/math").Si;
|
|
@@ -296,44 +306,54 @@ declare namespace nerdamer {
|
|
|
296
306
|
var Li: typeof import("./math/math").Li;
|
|
297
307
|
var Ei: typeof import("./math/math").Ei;
|
|
298
308
|
var sinc: typeof import("./math/math").sinc;
|
|
309
|
+
var parens: typeof import("./math/math").parens;
|
|
310
|
+
var continued_fraction: typeof continuedFraction;
|
|
311
|
+
var scientific: typeof import("./math/math").scientific;
|
|
299
312
|
var contains: typeof import("./math/math").contains;
|
|
300
313
|
var subst: typeof import("./core/functions/subst").subst;
|
|
301
|
-
var uSub: typeof import("./
|
|
302
|
-
var uUnSub: typeof import("./
|
|
314
|
+
var uSub: typeof import("./api/algebra").uSub;
|
|
315
|
+
var uUnSub: typeof import("./api/algebra").uUnSub;
|
|
303
316
|
var expand: typeof import("./core/functions/expand/expand").expand;
|
|
304
|
-
var factor: typeof import("./algebra
|
|
305
|
-
var
|
|
306
|
-
var
|
|
307
|
-
var
|
|
308
|
-
var
|
|
317
|
+
var factor: typeof import("./api/algebra").factor;
|
|
318
|
+
var pfactor: typeof import("./api/algebra").pfactor;
|
|
319
|
+
var pfactord: typeof import("./api/algebra").pfactord;
|
|
320
|
+
var polyFactors: typeof import("./api/algebra").polyFactors;
|
|
321
|
+
var completeSquare: (expr: ExpressionInput, variable?: string) => import("./algebra/utils").CompleteSquareResult;
|
|
322
|
+
var gcd: typeof import("./api/algebra").gcd;
|
|
323
|
+
var lcm: typeof import("./api/algebra").lcm;
|
|
309
324
|
var partfrac: typeof import("./algebra/partfrac").partfrac;
|
|
310
325
|
var div: typeof polynomialDiv;
|
|
311
326
|
var divide: typeof polynomialDivide;
|
|
312
|
-
var simplify: typeof import("./algebra
|
|
327
|
+
var simplify: typeof import("./api/algebra").simplify;
|
|
313
328
|
var groebner: typeof import("./algebra/groebner").groebner;
|
|
314
329
|
var solve: typeof import("./solve/solve").solve;
|
|
330
|
+
var roots: typeof import("./solve/solve").roots;
|
|
315
331
|
var solveSystem: typeof import("./solve/solveSystem").solveSystem;
|
|
316
332
|
var solveeqs: typeof import("./solve/solveSystem").solveSystem;
|
|
317
333
|
var diff: typeof import("./calculus/derivative/diff").diff;
|
|
318
334
|
var integrate: typeof import("./calculus/integrate/integrate").integrate;
|
|
319
335
|
var laplace: typeof import("./calculus/laplace/laplace").laplace;
|
|
320
336
|
var ilaplace: typeof import("./calculus/laplace/ilaplace").ilaplace;
|
|
321
|
-
var ilt:
|
|
337
|
+
var ilt: (expr: ExpressionInput, s: ExpressionInput, t: ExpressionInput) => Expression;
|
|
322
338
|
var sum: typeof import("./math/math").sum;
|
|
323
339
|
var product: typeof import("./math/math").product;
|
|
324
340
|
var limit: typeof import("./calculus/limit/limit").limit;
|
|
325
|
-
var defint: typeof import("./math/
|
|
341
|
+
var defint: typeof import("./math/defint/defint").defint;
|
|
326
342
|
var S: typeof import("./calculus/fresnel").S;
|
|
327
343
|
var C: typeof import("./calculus/fresnel").C;
|
|
328
344
|
var matrix: typeof import("./math/math").matrix;
|
|
329
345
|
var imatrix: typeof import("./core/classes/matrix/utils").imatrix;
|
|
330
346
|
var determinant: typeof import("./core/classes/matrix/functions").determinant;
|
|
347
|
+
var invert: typeof import("./core/classes/matrix/functions").invert;
|
|
331
348
|
var nullspace: typeof import("./core/classes/matrix/functions").nullspace;
|
|
332
349
|
var dot: typeof import("./core/classes/vector/functions").dot;
|
|
333
350
|
var cross: typeof import("./core/classes/vector/functions").cross;
|
|
334
|
-
var
|
|
335
|
-
var
|
|
351
|
+
var line: typeof import("./math/geometry").line;
|
|
352
|
+
var deg: typeof import("./api/algebra").deg;
|
|
353
|
+
var content: typeof import("./api/algebra").content;
|
|
354
|
+
var coeffs: typeof import("./api/algebra").coeffs;
|
|
336
355
|
var assume: typeof import("./core/classes/assumption/assume").assume;
|
|
356
|
+
var getAssumptions: typeof import("./core/classes/assumption/assume").getAssumptions;
|
|
337
357
|
var updateAPI: () => typeof nerdamer;
|
|
338
358
|
}
|
|
339
359
|
export default nerdamer;
|
package/output/index.js
CHANGED
|
@@ -42,7 +42,8 @@ const gcd_1 = require("./algebra/gcd/gcd");
|
|
|
42
42
|
const groebner_1 = require("./algebra/groebner");
|
|
43
43
|
const partfrac_1 = require("./algebra/partfrac");
|
|
44
44
|
const simplify_1 = require("./algebra/simplify/simplify");
|
|
45
|
-
const
|
|
45
|
+
const algebra_1 = require("./api/algebra");
|
|
46
|
+
const core_1 = require("./api/core");
|
|
46
47
|
const diff_1 = require("./calculus/derivative/diff");
|
|
47
48
|
const fresnel_1 = require("./calculus/fresnel");
|
|
48
49
|
const integrate_1 = require("./calculus/integrate/integrate");
|
|
@@ -58,7 +59,7 @@ const Expression_1 = require("./core/classes/expression/Expression");
|
|
|
58
59
|
const shortcuts_1 = require("./core/classes/expression/shortcuts");
|
|
59
60
|
const functions_1 = require("./core/classes/matrix/functions");
|
|
60
61
|
const Matrix_1 = require("./core/classes/matrix/Matrix");
|
|
61
|
-
const
|
|
62
|
+
const utils_1 = require("./core/classes/matrix/utils");
|
|
62
63
|
const constants_1 = require("./core/classes/parser/constants");
|
|
63
64
|
const Parser_1 = require("./core/classes/parser/Parser");
|
|
64
65
|
const scope_1 = require("./core/classes/parser/scripting/scope");
|
|
@@ -71,19 +72,21 @@ const Vector_1 = require("./core/classes/vector/Vector");
|
|
|
71
72
|
const Converter_1 = require("./core/converters/Converter");
|
|
72
73
|
const dispatch_1 = require("./core/dispatch");
|
|
73
74
|
const errors = __importStar(require("./core/errors"));
|
|
74
|
-
const
|
|
75
|
+
const fullFunctions_1 = require("./core/fullFunctions");
|
|
75
76
|
const complex_1 = require("./core/functions/complex");
|
|
76
77
|
const expand_1 = require("./core/functions/expand/expand");
|
|
77
78
|
const setFunction_1 = require("./core/functions/setFunction");
|
|
78
79
|
const subst_1 = require("./core/functions/subst");
|
|
80
|
+
const defint_1 = require("./math/defint/defint");
|
|
79
81
|
const geometry_1 = require("./math/geometry");
|
|
80
82
|
const math_1 = require("./math/math");
|
|
81
83
|
const trig_1 = require("./math/trig");
|
|
82
84
|
const trunc_1 = require("./math/trunc");
|
|
83
|
-
const
|
|
85
|
+
const utils_2 = require("./math/utils");
|
|
84
86
|
const SolutionSet_1 = require("./solve/classes/SolutionSet");
|
|
85
87
|
const solve_1 = require("./solve/solve");
|
|
86
88
|
const solveSystem_1 = require("./solve/solveSystem");
|
|
89
|
+
(0, fullFunctions_1.registerNerdamerFunctions)();
|
|
87
90
|
/**
|
|
88
91
|
* Adds selected root functions as instance methods without changing the source classes.
|
|
89
92
|
* Existing class methods win, so a class can keep a more specific implementation.
|
|
@@ -412,6 +415,10 @@ nerdamer.get = function (setting) {
|
|
|
412
415
|
nerdamer.getOperator = function (symbol) {
|
|
413
416
|
return Parser_1.Parser.getOperator(symbol);
|
|
414
417
|
};
|
|
418
|
+
/** Returns whether Nerdamer currently reserves a variable or symbol name. */
|
|
419
|
+
nerdamer.isReserved = function (name) {
|
|
420
|
+
return Parser_1.Parser.isReserved(name);
|
|
421
|
+
};
|
|
415
422
|
/** Registers or updates a parser operator and returns the root API for chaining. */
|
|
416
423
|
nerdamer.setOperator = function (operator, action) {
|
|
417
424
|
Parser_1.Parser.setOperator(operator, action);
|
|
@@ -529,7 +536,7 @@ nerdamer.errors = errors;
|
|
|
529
536
|
* nerdamer('cos(x)').buildFunction(['x'])(0); // 1
|
|
530
537
|
* ```
|
|
531
538
|
*/
|
|
532
|
-
nerdamer.buildFunction =
|
|
539
|
+
nerdamer.buildFunction = core_1.buildFunction;
|
|
533
540
|
/**
|
|
534
541
|
* Compatibility registry of selected Nerdamer constructors and the shared Parser instance.
|
|
535
542
|
*
|
|
@@ -565,9 +572,36 @@ nerdamer.tan = trig_1.tan;
|
|
|
565
572
|
nerdamer.acos = trig_1.acos;
|
|
566
573
|
nerdamer.asin = trig_1.asin;
|
|
567
574
|
nerdamer.atan = trig_1.atan;
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
575
|
+
const arccos = trig_1.acos;
|
|
576
|
+
/**
|
|
577
|
+
* Alias for `nerdamer.acos`.
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
* ```ts
|
|
581
|
+
* nerdamer.arccos('1/2').text(); // "1/3*pi"
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
nerdamer.arccos = arccos;
|
|
585
|
+
const arcsin = trig_1.asin;
|
|
586
|
+
/**
|
|
587
|
+
* Alias for `nerdamer.asin`.
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* ```ts
|
|
591
|
+
* nerdamer.arcsin('1/2').text(); // "1/6*pi"
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
nerdamer.arcsin = arcsin;
|
|
595
|
+
const arctan = trig_1.atan;
|
|
596
|
+
/**
|
|
597
|
+
* Alias for `nerdamer.atan`.
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```ts
|
|
601
|
+
* nerdamer.arctan(1).text(); // "1/4*pi"
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
604
|
+
nerdamer.arctan = arctan;
|
|
571
605
|
nerdamer.atan2 = trig_1.atan2;
|
|
572
606
|
nerdamer.sec = trig_1.sec;
|
|
573
607
|
nerdamer.csc = trig_1.csc;
|
|
@@ -590,6 +624,9 @@ nerdamer.acsch = trig_1.acsch;
|
|
|
590
624
|
nerdamer.acoth = trig_1.acoth;
|
|
591
625
|
// Elementary and numeric functions
|
|
592
626
|
nerdamer.log = math_1.log;
|
|
627
|
+
nerdamer.log10 = math_1.log10;
|
|
628
|
+
nerdamer.radians = math_1.radians;
|
|
629
|
+
nerdamer.degrees = math_1.degrees;
|
|
593
630
|
nerdamer.exp = math_1.exp;
|
|
594
631
|
nerdamer.sqrt = math_1.sqrt;
|
|
595
632
|
nerdamer.cbrt = math_1.cbrt;
|
|
@@ -601,18 +638,63 @@ nerdamer.min = math_1.min;
|
|
|
601
638
|
nerdamer.max = math_1.max;
|
|
602
639
|
nerdamer.round = math_1.round;
|
|
603
640
|
nerdamer.floor = math_1.floor;
|
|
604
|
-
|
|
641
|
+
const ceil = math_1.ceiling;
|
|
642
|
+
/**
|
|
643
|
+
* Rounds a value up to the nearest integer.
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* ```ts
|
|
647
|
+
* nerdamer.ceil('3.2').text(); // "4"
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
nerdamer.ceil = ceil;
|
|
605
651
|
nerdamer.trunc = trunc_1.trunc;
|
|
606
652
|
nerdamer.hypot = geometry_1.hypot;
|
|
607
653
|
// Discrete and number-theoretic functions
|
|
608
|
-
|
|
654
|
+
const fact = math_1.factorial;
|
|
655
|
+
/**
|
|
656
|
+
* Alias for `nerdamer.factorial`.
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* ```ts
|
|
660
|
+
* nerdamer.fact(5).text(); // "120"
|
|
661
|
+
* ```
|
|
662
|
+
*/
|
|
663
|
+
nerdamer.fact = fact;
|
|
609
664
|
nerdamer.factorial = math_1.factorial;
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
665
|
+
const dfact = math_1.doubleFactorial;
|
|
666
|
+
/**
|
|
667
|
+
* Computes the double factorial of an expression.
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* ```ts
|
|
671
|
+
* nerdamer.dfact(6).text(); // "48"
|
|
672
|
+
* ```
|
|
673
|
+
*/
|
|
674
|
+
nerdamer.dfact = dfact;
|
|
675
|
+
const dfactorial = math_1.doubleFactorial;
|
|
676
|
+
/**
|
|
677
|
+
* Computes the double factorial of an expression.
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* ```ts
|
|
681
|
+
* nerdamer.dfactorial(7).text(); // "105"
|
|
682
|
+
* ```
|
|
683
|
+
*/
|
|
684
|
+
nerdamer.dfactorial = dfactorial;
|
|
685
|
+
const fib = math_1.fibonacci;
|
|
686
|
+
/**
|
|
687
|
+
* Computes the Fibonacci number for an integer index.
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```ts
|
|
691
|
+
* nerdamer.fib(10).text(); // "55"
|
|
692
|
+
* ```
|
|
693
|
+
*/
|
|
694
|
+
nerdamer.fib = fib;
|
|
613
695
|
nerdamer.mod = math_1.mod;
|
|
614
696
|
nerdamer.modInv = math_1.modInv;
|
|
615
|
-
nerdamer.isPrime =
|
|
697
|
+
nerdamer.isPrime = utils_2.isprime;
|
|
616
698
|
// Complex functions
|
|
617
699
|
nerdamer.imagpart = complex_1.imagPart;
|
|
618
700
|
nerdamer.realpart = complex_1.realPart;
|
|
@@ -623,10 +705,24 @@ nerdamer.conjugate = complex_1.conjugate;
|
|
|
623
705
|
nerdamer.csgn = complex_1.csgn;
|
|
624
706
|
// Special functions
|
|
625
707
|
nerdamer.gamma = math_1.gamma;
|
|
708
|
+
nerdamer.gamma_incomplete = math_1.gammaIncomplete;
|
|
709
|
+
nerdamer.gamma_incomplete_lower = math_1.gammaIncompleteLower;
|
|
626
710
|
nerdamer.erf = math_1.erf;
|
|
627
711
|
nerdamer.erfc = math_1.erfc;
|
|
628
712
|
nerdamer.heaviside = math_1.heaviside;
|
|
629
|
-
nerdamer.
|
|
713
|
+
nerdamer.step = math_1.step;
|
|
714
|
+
nerdamer.rect = math_1.rect;
|
|
715
|
+
nerdamer.tri = math_1.tri;
|
|
716
|
+
const delta = math_1.dirac;
|
|
717
|
+
/**
|
|
718
|
+
* Evaluates the Dirac delta function when the input is known to be nonzero.
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* ```ts
|
|
722
|
+
* nerdamer.delta(5).text(); // "0"
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
nerdamer.delta = delta;
|
|
630
726
|
nerdamer.Ci = math_1.Ci;
|
|
631
727
|
nerdamer.Chi = math_1.Chi;
|
|
632
728
|
nerdamer.Si = math_1.Si;
|
|
@@ -635,6 +731,9 @@ nerdamer.Li = math_1.Li;
|
|
|
635
731
|
nerdamer.Ei = math_1.Ei;
|
|
636
732
|
nerdamer.sinc = math_1.sinc;
|
|
637
733
|
// Symbolic utilities
|
|
734
|
+
nerdamer.parens = math_1.parens;
|
|
735
|
+
nerdamer.continued_fraction = utils_2.continuedFraction;
|
|
736
|
+
nerdamer.scientific = math_1.scientific;
|
|
638
737
|
nerdamer.contains = math_1.contains;
|
|
639
738
|
nerdamer.subst = subst_1.subst;
|
|
640
739
|
nerdamer.uSub = subst_1.uSub;
|
|
@@ -642,8 +741,18 @@ nerdamer.uUnSub = subst_1.uUnSub;
|
|
|
642
741
|
// Algebra
|
|
643
742
|
nerdamer.expand = expand_1.expand;
|
|
644
743
|
nerdamer.factor = factor_1.factor;
|
|
744
|
+
nerdamer.pfactor = factor_1.pfactor;
|
|
745
|
+
nerdamer.pfactord = factor_1.pfactord;
|
|
645
746
|
nerdamer.polyFactors = factor_1.polyFactors;
|
|
646
|
-
|
|
747
|
+
/**
|
|
748
|
+
* Completes the square for a quadratic expression.
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* ```ts
|
|
752
|
+
* nerdamer.completeSquare('x^2+6*x+1').expression.text({ sort: true }); // "(3+x)^2-8"
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
755
|
+
nerdamer.completeSquare = algebra_1.completeSquare;
|
|
647
756
|
nerdamer.gcd = gcd_1.gcd;
|
|
648
757
|
nerdamer.lcm = gcd_1.lcm;
|
|
649
758
|
nerdamer.partfrac = partfrac_1.partfrac;
|
|
@@ -653,6 +762,7 @@ nerdamer.simplify = simplify_1.simplify;
|
|
|
653
762
|
nerdamer.groebner = groebner_1.groebner;
|
|
654
763
|
// Solvers
|
|
655
764
|
nerdamer.solve = solve_1.solve;
|
|
765
|
+
nerdamer.roots = solve_1.roots;
|
|
656
766
|
nerdamer.solveSystem = solveSystem_1.solveSystem;
|
|
657
767
|
nerdamer.solveeqs = solveSystem_1.solveSystem;
|
|
658
768
|
// Calculus
|
|
@@ -660,24 +770,36 @@ nerdamer.diff = diff_1.diff;
|
|
|
660
770
|
nerdamer.integrate = integrate_1.integrate;
|
|
661
771
|
nerdamer.laplace = laplace_1.laplace;
|
|
662
772
|
nerdamer.ilaplace = ilaplace_1.ilaplace;
|
|
663
|
-
|
|
773
|
+
const ilt = ilaplace_1.ilaplace;
|
|
774
|
+
/**
|
|
775
|
+
* Alias for `nerdamer.ilaplace`.
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* ```ts
|
|
779
|
+
* nerdamer.ilt('1/(s^2+1)', 's', 't').text();
|
|
780
|
+
* ```
|
|
781
|
+
*/
|
|
782
|
+
nerdamer.ilt = ilt;
|
|
664
783
|
nerdamer.sum = math_1.sum;
|
|
665
784
|
nerdamer.product = math_1.product;
|
|
666
785
|
nerdamer.limit = limit_1.limit;
|
|
667
|
-
nerdamer.defint =
|
|
786
|
+
nerdamer.defint = defint_1.defint;
|
|
668
787
|
nerdamer.S = fresnel_1.S;
|
|
669
788
|
nerdamer.C = fresnel_1.C;
|
|
670
789
|
// Matrix operations
|
|
671
790
|
nerdamer.matrix = math_1.matrix;
|
|
672
|
-
nerdamer.imatrix =
|
|
791
|
+
nerdamer.imatrix = utils_1.imatrix;
|
|
673
792
|
nerdamer.determinant = functions_1.determinant;
|
|
793
|
+
nerdamer.invert = functions_1.invert;
|
|
674
794
|
nerdamer.nullspace = functions_1.nullspace;
|
|
675
795
|
// Vector operations
|
|
676
796
|
nerdamer.dot = functions_3.dot;
|
|
677
797
|
nerdamer.cross = functions_3.cross;
|
|
798
|
+
nerdamer.line = geometry_1.line;
|
|
678
799
|
// Polynomial operations
|
|
679
800
|
nerdamer.deg = functions_2.deg;
|
|
680
801
|
nerdamer.content = functions_2.content;
|
|
802
|
+
nerdamer.coeffs = functions_2.coeffs;
|
|
681
803
|
// Assumptions
|
|
682
804
|
/**
|
|
683
805
|
* Registers a process-wide numeric interval assumption.
|
|
@@ -689,6 +811,12 @@ nerdamer.content = functions_2.content;
|
|
|
689
811
|
* directly can use the documented assumption-domain functions.
|
|
690
812
|
*/
|
|
691
813
|
nerdamer.assume = assume_1.assume;
|
|
814
|
+
/**
|
|
815
|
+
* Returns a snapshot of all process-wide assumptions currently registered by symbol.
|
|
816
|
+
*
|
|
817
|
+
* Changing the returned Map does not change Nerdamer's active assumptions.
|
|
818
|
+
*/
|
|
819
|
+
nerdamer.getAssumptions = assume_1.getAssumptions;
|
|
692
820
|
// -----------------------------------------------------------------------------
|
|
693
821
|
// Complete the full-package instance API
|
|
694
822
|
// -----------------------------------------------------------------------------
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Expression } from '../../core/classes/expression/Expression';
|
|
2
|
+
import type { ExpressionInput } from '../../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* Calculates the definite integral using Adaptive Simpson. Note that this function uses
|
|
5
|
+
* native JS number due to severe computational overhead when implemented with Decimal.js.
|
|
6
|
+
*
|
|
7
|
+
* @param f The function being integrated
|
|
8
|
+
* @param dx The variable of integration
|
|
9
|
+
* @param from The lower limit of the integral
|
|
10
|
+
* @param to The upper limit of the integral
|
|
11
|
+
* @returns The numeric value if possible else a symbolic function
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* defint('cos(x)-x^2+6', 'x', 1, 6); // -42.787553149673464
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function defint(f: ExpressionInput, dx: ExpressionInput, from: ExpressionInput, to: ExpressionInput): Expression;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defint = defint;
|
|
4
|
+
const Expression_1 = require("../../core/classes/expression/Expression");
|
|
5
|
+
const utils_1 = require("../../core/classes/expression/utils");
|
|
6
|
+
const constants_1 = require("../../core/classes/parser/constants");
|
|
7
|
+
const defintNative_1 = require("./defintNative");
|
|
8
|
+
const NATIVE_DEFINITE_INTEGRATION_PRECISION = 17;
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the definite integral using Adaptive Simpson. Note that this function uses
|
|
11
|
+
* native JS number due to severe computational overhead when implemented with Decimal.js.
|
|
12
|
+
*
|
|
13
|
+
* @param f The function being integrated
|
|
14
|
+
* @param dx The variable of integration
|
|
15
|
+
* @param from The lower limit of the integral
|
|
16
|
+
* @param to The upper limit of the integral
|
|
17
|
+
* @returns The numeric value if possible else a symbolic function
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* defint('cos(x)-x^2+6', 'x', 1, 6); // -42.787553149673464
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function defint(f, dx, from, to) {
|
|
25
|
+
let retval;
|
|
26
|
+
f = Expression_1.Expression.create(f);
|
|
27
|
+
dx = Expression_1.Expression.create(dx);
|
|
28
|
+
from = Expression_1.Expression.create(from);
|
|
29
|
+
to = Expression_1.Expression.create(to);
|
|
30
|
+
const inputVars = f.variables();
|
|
31
|
+
// Get the variable
|
|
32
|
+
const v = (0, utils_1.assertPlainVariableAndGetString)(dx);
|
|
33
|
+
// Pull factors that are constant with respect to the integration variable across the bounds.
|
|
34
|
+
if (!inputVars.includes(v)) {
|
|
35
|
+
retval = f.times(to.minus(from));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
let numericFrom = from;
|
|
39
|
+
let numericTo = to;
|
|
40
|
+
if (!numericFrom.isNUM() && numericFrom.isConstant()) {
|
|
41
|
+
numericFrom = numericFrom.evaluate();
|
|
42
|
+
}
|
|
43
|
+
if (!numericTo.isNUM() && numericTo.isConstant()) {
|
|
44
|
+
numericTo = numericTo.evaluate();
|
|
45
|
+
}
|
|
46
|
+
if (inputVars.length === 1 &&
|
|
47
|
+
inputVars[0] === v &&
|
|
48
|
+
numericFrom.isNUM() &&
|
|
49
|
+
numericTo.isNUM()) {
|
|
50
|
+
const a = Number(numericFrom.getMultiplier().toDecimal());
|
|
51
|
+
const b = Number(numericTo.getMultiplier().toDecimal());
|
|
52
|
+
retval = Expression_1.Expression.create((0, defintNative_1.definiteIntegrateNative)(f.buildFunction(), a, b));
|
|
53
|
+
retval.precision = NATIVE_DEFINITE_INTEGRATION_PRECISION; // Mark it as limited precision
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
retval = Expression_1.Expression.toFunction(constants_1.DEFINT, [f, dx, from, to]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return retval;
|
|
60
|
+
}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.definiteIntegrate = definiteIntegrate;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
|
+
const errors_1 = require("../../core/errors");
|
|
8
9
|
const TWO = new decimal_js_1.default(2);
|
|
9
10
|
const FOUR = new decimal_js_1.default(4);
|
|
10
11
|
const SIX = new decimal_js_1.default(6);
|
|
@@ -58,12 +59,12 @@ function withFiniteBounds(f, aIn, bIn, opts) {
|
|
|
58
59
|
let evals = 0;
|
|
59
60
|
const evalF = (x) => {
|
|
60
61
|
if (evals++ > opts.maxEvals) {
|
|
61
|
-
throw new Error(
|
|
62
|
+
throw new Error((0, errors_1.message)('defintMaxEvals', { max: String(opts.maxEvals) }));
|
|
62
63
|
}
|
|
63
64
|
const y = f(x);
|
|
64
65
|
if (opts.singular === 'strict') {
|
|
65
66
|
if (!isFiniteDecimal(y)) {
|
|
66
|
-
throw new Error(
|
|
67
|
+
throw new Error((0, errors_1.message)('defintNonFiniteValue', { x: x.toString() }));
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
return y;
|
|
@@ -127,7 +128,7 @@ function withFiniteBounds(f, aIn, bIn, opts) {
|
|
|
127
128
|
!isFiniteDecimal(fr.fm) ||
|
|
128
129
|
!isFiniteDecimal(fr.fb)) {
|
|
129
130
|
if (fr.depth >= opts.maxDepth || fr.singularTries >= MAX_SINGULAR_REFINEMENT_ATTEMPTS) {
|
|
130
|
-
throw new Error(
|
|
131
|
+
throw new Error((0, errors_1.message)('defintSingularity', { a: a0.toString(), b: b0.toString() }));
|
|
131
132
|
}
|
|
132
133
|
// Push children without using Simpson error test; just refine around the issue.
|
|
133
134
|
const nextDepth = fr.depth + 1;
|
|
@@ -251,7 +252,7 @@ function definiteIntegrate(f, a, b, options = {}) {
|
|
|
251
252
|
const isInfA = !A.isFinite() && !A.isNaN();
|
|
252
253
|
const isInfB = !B.isFinite() && !B.isNaN();
|
|
253
254
|
if ((isInfA || isInfB) && !allowInfinite) {
|
|
254
|
-
throw new Error(
|
|
255
|
+
throw new Error((0, errors_1.message)('defintInfiniteBoundsDecimal'));
|
|
255
256
|
}
|
|
256
257
|
const coreOpts = { tolAbs, tolRel, maxDepth, maxEvals, singular };
|
|
257
258
|
// Handle infinite bounds with standard substitutions:
|
|
@@ -299,7 +300,7 @@ function definiteIntegrate(f, a, b, options = {}) {
|
|
|
299
300
|
const eps = new decimal_js_1.default(10).pow(-(decimal_js_1.default.precision ?? DEFAULT_DECIMAL_PRECISION) + INFINITE_BOUND_PRECISION_SLACK);
|
|
300
301
|
return withFiniteBounds(g, eps, ONE.sub(eps), coreOpts);
|
|
301
302
|
}
|
|
302
|
-
throw new Error(
|
|
303
|
+
throw new Error((0, errors_1.message)('defintUnsupportedInfiniteBounds'));
|
|
303
304
|
}
|
|
304
305
|
// Finite-bounds path, with optional segmentation by breakpoints
|
|
305
306
|
if (bps.length === 0) {
|