nerdamer 2.0.0-rc.2 → 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/README.md +11 -5
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.LICENSE.txt +6 -6
- package/output/algebra/dispatch.js +1 -1
- package/output/algebra/partfrac.js +1 -1
- package/output/algebra/simplify/funcsimp.js +1 -1
- package/output/algebra/simplify/ratsimp.js +1 -1
- package/output/algebra/utils.d.ts +1 -1
- package/output/algebra/utils.js +3 -3
- package/output/api/algebra.d.ts +19 -2
- package/output/api/algebra.js +18 -2
- package/output/api/assumptions.d.ts +1 -1
- package/output/api/assumptions.js +2 -1
- package/output/api/core.d.ts +28 -7
- package/output/api/core.js +28 -2
- package/output/calculus/derivative/diff.js +1 -1
- package/output/calculus/dispatch.js +2 -2
- 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/assume.d.ts +6 -0
- package/output/core/classes/assumption/assume.js +9 -0
- package/output/core/classes/expression/CoeffObject.d.ts +1 -1
- package/output/core/classes/expression/Expression.d.ts +8 -16
- package/output/core/classes/expression/Expression.js +11 -33
- package/output/core/classes/matrix/Matrix.d.ts +2 -3
- package/output/core/classes/matrix/Matrix.js +7 -16
- package/output/core/classes/matrix/dispatch.js +1 -1
- package/output/core/classes/parser/Parser.d.ts +17 -4
- package/output/core/classes/parser/Parser.js +312 -450
- package/output/core/classes/parser/operations/functions.d.ts +3 -4
- package/output/core/classes/parser/operations/functions.js +35 -97
- package/output/core/classes/parser/operations/power.js +2 -2
- package/output/core/classes/parser/preprocess.js +14 -7
- package/output/core/classes/parser/scripting/controlFlow.js +49 -25
- package/output/core/classes/parser/scripting/deferred.d.ts +1 -1
- package/output/core/classes/parser/scripting/deferred.js +1 -1
- package/output/core/classes/parser/scripting/scope.js +38 -19
- package/output/core/classes/parser/types.d.ts +0 -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.js +1 -1
- package/output/core/classes/polynomial/SparsePolynomial.d.ts +11 -11
- package/output/core/classes/polynomial/SparsePolynomial.js +65 -65
- package/output/core/classes/vector/Vector.d.ts +2 -3
- package/output/core/classes/vector/Vector.js +6 -14
- package/output/core/common/classes/StructuredEntity.d.ts +0 -17
- package/output/core/common/classes/StructuredEntity.js +3 -64
- package/output/core/converters/BaseConverter.js +2 -1
- package/output/core/fullFunctions.js +14 -14
- package/output/core/functions/bigint/bigint.d.ts +1 -1
- package/output/core/functions/numeric.d.ts +1 -1
- package/output/core/parserFunctions.js +10 -10
- package/output/index.d.ts +29 -29
- package/output/index.js +124 -20
- package/output/math/dispatch.js +1 -1
- package/output/math/math.js +21 -21
- package/output/math/trig.js +4 -4
- package/output/solve/solve.js +1 -1
- package/package.json +34 -15
- package/dist/parser.js +0 -2
- package/dist/parser.js.LICENSE.txt +0 -7
- package/docs-data/parser-functions.json +0 -2248
- 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';
|
|
@@ -13,9 +12,8 @@ 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
14
|
import * as errors from './core/errors';
|
|
16
|
-
import { build } from './core/functions/build';
|
|
17
15
|
import { imagPart, polarForm, realPart, rectForm } from './core/functions/complex';
|
|
18
|
-
import {
|
|
16
|
+
import { gammaIncomplete, gammaIncompleteLower } from './math/math';
|
|
19
17
|
import { continuedFraction, isprime } from './math/utils';
|
|
20
18
|
import { SolutionSet } from './solve/classes/SolutionSet';
|
|
21
19
|
import type { OptionsObject, ParserConstants, ParserValuesObject, TextOptions } from './core/classes/parser/types';
|
|
@@ -179,10 +177,10 @@ declare namespace nerdamer {
|
|
|
179
177
|
user: string[];
|
|
180
178
|
system: string[];
|
|
181
179
|
};
|
|
182
|
-
var symbols: typeof import("./core
|
|
180
|
+
var symbols: typeof import("./api/core").symbols;
|
|
183
181
|
var version: () => string;
|
|
184
182
|
var errors: typeof import("./core/errors");
|
|
185
|
-
var buildFunction:
|
|
183
|
+
var buildFunction: (x: ExpressionInput, argsArray?: string[]) => (...args: number[]) => number;
|
|
186
184
|
var classes: {
|
|
187
185
|
Expression: typeof Expression;
|
|
188
186
|
Rational: typeof Rational;
|
|
@@ -204,8 +202,9 @@ declare namespace nerdamer {
|
|
|
204
202
|
VALUE_SETS: string[];
|
|
205
203
|
WHITE_SPACE: string[];
|
|
206
204
|
KNOWN_VALUES: Record<string, ParserEntity>;
|
|
205
|
+
extractDictionaryKey(scope: import("./core/common/classes/Scope").Scope, values?: ParserValuesObject, assertive?: boolean): string;
|
|
207
206
|
extractIndices(scope: import("./core/common/classes/Scope").Scope, values?: ParserValuesObject, assertive?: boolean): number[] | Expression[];
|
|
208
|
-
|
|
207
|
+
resolveSymbolicAccess(symbolicTarget: Expression, resolvedTarget: ParserEntity, indices: Expression[]): ParserEntity;
|
|
209
208
|
aliasOperator(symbol: string, alias: string): /*elided*/ any;
|
|
210
209
|
create(): /*elided*/ any;
|
|
211
210
|
evaluate(str: string, values?: ParserValuesObject): ParserEntity;
|
|
@@ -235,9 +234,9 @@ declare namespace nerdamer {
|
|
|
235
234
|
var acos: typeof import("./math/trig").acos;
|
|
236
235
|
var asin: typeof import("./math/trig").asin;
|
|
237
236
|
var atan: typeof import("./math/trig").atan;
|
|
238
|
-
var arccos:
|
|
239
|
-
var arcsin:
|
|
240
|
-
var arctan:
|
|
237
|
+
var arccos: (x: ExpressionInput) => Expression;
|
|
238
|
+
var arcsin: (x: ExpressionInput) => Expression;
|
|
239
|
+
var arctan: (x: ExpressionInput) => Expression;
|
|
241
240
|
var atan2: typeof import("./math/trig").atan2;
|
|
242
241
|
var sec: typeof import("./math/trig").sec;
|
|
243
242
|
var csc: typeof import("./math/trig").csc;
|
|
@@ -272,14 +271,14 @@ declare namespace nerdamer {
|
|
|
272
271
|
var max: typeof import("./math/math").max;
|
|
273
272
|
var round: typeof import("./math/math").round;
|
|
274
273
|
var floor: typeof import("./math/math").floor;
|
|
275
|
-
var ceil:
|
|
274
|
+
var ceil: (x: ExpressionInput) => Expression;
|
|
276
275
|
var trunc: typeof import("./math/trunc").trunc;
|
|
277
276
|
var hypot: typeof import("./math/geometry").hypot;
|
|
278
|
-
var fact:
|
|
277
|
+
var fact: (x: Expression) => Expression;
|
|
279
278
|
var factorial: typeof import("./math/math").factorial;
|
|
280
|
-
var dfact:
|
|
281
|
-
var dfactorial:
|
|
282
|
-
var fib:
|
|
279
|
+
var dfact: (x: Expression) => Expression;
|
|
280
|
+
var dfactorial: (x: Expression) => Expression;
|
|
281
|
+
var fib: (x: ExpressionInput) => Expression;
|
|
283
282
|
var mod: typeof import("./math/math").mod;
|
|
284
283
|
var modInv: typeof import("./math/math").modInv;
|
|
285
284
|
var isPrime: typeof isprime;
|
|
@@ -299,7 +298,7 @@ declare namespace nerdamer {
|
|
|
299
298
|
var step: typeof import("./math/math").step;
|
|
300
299
|
var rect: typeof import("./math/math").rect;
|
|
301
300
|
var tri: typeof import("./math/math").tri;
|
|
302
|
-
var delta:
|
|
301
|
+
var delta: (x: Expression) => Expression;
|
|
303
302
|
var Ci: typeof import("./math/math").Ci;
|
|
304
303
|
var Chi: typeof import("./math/math").Chi;
|
|
305
304
|
var Si: typeof import("./math/math").Si;
|
|
@@ -312,20 +311,20 @@ declare namespace nerdamer {
|
|
|
312
311
|
var scientific: typeof import("./math/math").scientific;
|
|
313
312
|
var contains: typeof import("./math/math").contains;
|
|
314
313
|
var subst: typeof import("./core/functions/subst").subst;
|
|
315
|
-
var uSub: typeof import("./
|
|
316
|
-
var uUnSub: typeof import("./
|
|
314
|
+
var uSub: typeof import("./api/algebra").uSub;
|
|
315
|
+
var uUnSub: typeof import("./api/algebra").uUnSub;
|
|
317
316
|
var expand: typeof import("./core/functions/expand/expand").expand;
|
|
318
|
-
var factor: typeof import("./algebra
|
|
319
|
-
var pfactor: typeof import("./algebra
|
|
320
|
-
var pfactord: typeof import("./algebra
|
|
321
|
-
var polyFactors: typeof import("./algebra
|
|
322
|
-
var completeSquare:
|
|
323
|
-
var gcd: typeof import("./algebra
|
|
324
|
-
var lcm: typeof import("./algebra
|
|
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;
|
|
325
324
|
var partfrac: typeof import("./algebra/partfrac").partfrac;
|
|
326
325
|
var div: typeof polynomialDiv;
|
|
327
326
|
var divide: typeof polynomialDivide;
|
|
328
|
-
var simplify: typeof import("./algebra
|
|
327
|
+
var simplify: typeof import("./api/algebra").simplify;
|
|
329
328
|
var groebner: typeof import("./algebra/groebner").groebner;
|
|
330
329
|
var solve: typeof import("./solve/solve").solve;
|
|
331
330
|
var roots: typeof import("./solve/solve").roots;
|
|
@@ -335,7 +334,7 @@ declare namespace nerdamer {
|
|
|
335
334
|
var integrate: typeof import("./calculus/integrate/integrate").integrate;
|
|
336
335
|
var laplace: typeof import("./calculus/laplace/laplace").laplace;
|
|
337
336
|
var ilaplace: typeof import("./calculus/laplace/ilaplace").ilaplace;
|
|
338
|
-
var ilt:
|
|
337
|
+
var ilt: (expr: ExpressionInput, s: ExpressionInput, t: ExpressionInput) => Expression;
|
|
339
338
|
var sum: typeof import("./math/math").sum;
|
|
340
339
|
var product: typeof import("./math/math").product;
|
|
341
340
|
var limit: typeof import("./calculus/limit/limit").limit;
|
|
@@ -350,10 +349,11 @@ declare namespace nerdamer {
|
|
|
350
349
|
var dot: typeof import("./core/classes/vector/functions").dot;
|
|
351
350
|
var cross: typeof import("./core/classes/vector/functions").cross;
|
|
352
351
|
var line: typeof import("./math/geometry").line;
|
|
353
|
-
var deg: typeof import("./
|
|
354
|
-
var content: typeof import("./
|
|
355
|
-
var coeffs: typeof import("./
|
|
352
|
+
var deg: typeof import("./api/algebra").deg;
|
|
353
|
+
var content: typeof import("./api/algebra").content;
|
|
354
|
+
var coeffs: typeof import("./api/algebra").coeffs;
|
|
356
355
|
var assume: typeof import("./core/classes/assumption/assume").assume;
|
|
356
|
+
var getAssumptions: typeof import("./core/classes/assumption/assume").getAssumptions;
|
|
357
357
|
var updateAPI: () => typeof nerdamer;
|
|
358
358
|
}
|
|
359
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");
|
|
@@ -70,9 +71,8 @@ const functions_3 = require("./core/classes/vector/functions");
|
|
|
70
71
|
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
|
-
const fullFunctions_1 = require("./core/fullFunctions");
|
|
74
74
|
const errors = __importStar(require("./core/errors"));
|
|
75
|
-
const
|
|
75
|
+
const fullFunctions_1 = require("./core/fullFunctions");
|
|
76
76
|
const complex_1 = require("./core/functions/complex");
|
|
77
77
|
const expand_1 = require("./core/functions/expand/expand");
|
|
78
78
|
const setFunction_1 = require("./core/functions/setFunction");
|
|
@@ -82,7 +82,7 @@ const geometry_1 = require("./math/geometry");
|
|
|
82
82
|
const math_1 = require("./math/math");
|
|
83
83
|
const trig_1 = require("./math/trig");
|
|
84
84
|
const trunc_1 = require("./math/trunc");
|
|
85
|
-
const
|
|
85
|
+
const utils_2 = require("./math/utils");
|
|
86
86
|
const SolutionSet_1 = require("./solve/classes/SolutionSet");
|
|
87
87
|
const solve_1 = require("./solve/solve");
|
|
88
88
|
const solveSystem_1 = require("./solve/solveSystem");
|
|
@@ -536,7 +536,7 @@ nerdamer.errors = errors;
|
|
|
536
536
|
* nerdamer('cos(x)').buildFunction(['x'])(0); // 1
|
|
537
537
|
* ```
|
|
538
538
|
*/
|
|
539
|
-
nerdamer.buildFunction =
|
|
539
|
+
nerdamer.buildFunction = core_1.buildFunction;
|
|
540
540
|
/**
|
|
541
541
|
* Compatibility registry of selected Nerdamer constructors and the shared Parser instance.
|
|
542
542
|
*
|
|
@@ -572,9 +572,36 @@ nerdamer.tan = trig_1.tan;
|
|
|
572
572
|
nerdamer.acos = trig_1.acos;
|
|
573
573
|
nerdamer.asin = trig_1.asin;
|
|
574
574
|
nerdamer.atan = trig_1.atan;
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
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;
|
|
578
605
|
nerdamer.atan2 = trig_1.atan2;
|
|
579
606
|
nerdamer.sec = trig_1.sec;
|
|
580
607
|
nerdamer.csc = trig_1.csc;
|
|
@@ -611,18 +638,63 @@ nerdamer.min = math_1.min;
|
|
|
611
638
|
nerdamer.max = math_1.max;
|
|
612
639
|
nerdamer.round = math_1.round;
|
|
613
640
|
nerdamer.floor = math_1.floor;
|
|
614
|
-
|
|
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;
|
|
615
651
|
nerdamer.trunc = trunc_1.trunc;
|
|
616
652
|
nerdamer.hypot = geometry_1.hypot;
|
|
617
653
|
// Discrete and number-theoretic functions
|
|
618
|
-
|
|
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;
|
|
619
664
|
nerdamer.factorial = math_1.factorial;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
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;
|
|
623
695
|
nerdamer.mod = math_1.mod;
|
|
624
696
|
nerdamer.modInv = math_1.modInv;
|
|
625
|
-
nerdamer.isPrime =
|
|
697
|
+
nerdamer.isPrime = utils_2.isprime;
|
|
626
698
|
// Complex functions
|
|
627
699
|
nerdamer.imagpart = complex_1.imagPart;
|
|
628
700
|
nerdamer.realpart = complex_1.realPart;
|
|
@@ -641,7 +713,16 @@ nerdamer.heaviside = math_1.heaviside;
|
|
|
641
713
|
nerdamer.step = math_1.step;
|
|
642
714
|
nerdamer.rect = math_1.rect;
|
|
643
715
|
nerdamer.tri = math_1.tri;
|
|
644
|
-
|
|
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;
|
|
645
726
|
nerdamer.Ci = math_1.Ci;
|
|
646
727
|
nerdamer.Chi = math_1.Chi;
|
|
647
728
|
nerdamer.Si = math_1.Si;
|
|
@@ -651,7 +732,7 @@ nerdamer.Ei = math_1.Ei;
|
|
|
651
732
|
nerdamer.sinc = math_1.sinc;
|
|
652
733
|
// Symbolic utilities
|
|
653
734
|
nerdamer.parens = math_1.parens;
|
|
654
|
-
nerdamer.continued_fraction =
|
|
735
|
+
nerdamer.continued_fraction = utils_2.continuedFraction;
|
|
655
736
|
nerdamer.scientific = math_1.scientific;
|
|
656
737
|
nerdamer.contains = math_1.contains;
|
|
657
738
|
nerdamer.subst = subst_1.subst;
|
|
@@ -663,7 +744,15 @@ nerdamer.factor = factor_1.factor;
|
|
|
663
744
|
nerdamer.pfactor = factor_1.pfactor;
|
|
664
745
|
nerdamer.pfactord = factor_1.pfactord;
|
|
665
746
|
nerdamer.polyFactors = factor_1.polyFactors;
|
|
666
|
-
|
|
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;
|
|
667
756
|
nerdamer.gcd = gcd_1.gcd;
|
|
668
757
|
nerdamer.lcm = gcd_1.lcm;
|
|
669
758
|
nerdamer.partfrac = partfrac_1.partfrac;
|
|
@@ -681,7 +770,16 @@ nerdamer.diff = diff_1.diff;
|
|
|
681
770
|
nerdamer.integrate = integrate_1.integrate;
|
|
682
771
|
nerdamer.laplace = laplace_1.laplace;
|
|
683
772
|
nerdamer.ilaplace = ilaplace_1.ilaplace;
|
|
684
|
-
|
|
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;
|
|
685
783
|
nerdamer.sum = math_1.sum;
|
|
686
784
|
nerdamer.product = math_1.product;
|
|
687
785
|
nerdamer.limit = limit_1.limit;
|
|
@@ -690,7 +788,7 @@ nerdamer.S = fresnel_1.S;
|
|
|
690
788
|
nerdamer.C = fresnel_1.C;
|
|
691
789
|
// Matrix operations
|
|
692
790
|
nerdamer.matrix = math_1.matrix;
|
|
693
|
-
nerdamer.imatrix =
|
|
791
|
+
nerdamer.imatrix = utils_1.imatrix;
|
|
694
792
|
nerdamer.determinant = functions_1.determinant;
|
|
695
793
|
nerdamer.invert = functions_1.invert;
|
|
696
794
|
nerdamer.nullspace = functions_1.nullspace;
|
|
@@ -713,6 +811,12 @@ nerdamer.coeffs = functions_2.coeffs;
|
|
|
713
811
|
* directly can use the documented assumption-domain functions.
|
|
714
812
|
*/
|
|
715
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;
|
|
716
820
|
// -----------------------------------------------------------------------------
|
|
717
821
|
// Complete the full-package instance API
|
|
718
822
|
// -----------------------------------------------------------------------------
|
package/output/math/dispatch.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadMathFunctions = loadMathFunctions;
|
|
4
|
-
const dispatch_1 = require("../core/dispatch");
|
|
5
4
|
const constants_1 = require("../core/classes/parser/constants");
|
|
6
5
|
const evaluate_1 = require("../core/classes/parser/scripting/evaluate");
|
|
6
|
+
const dispatch_1 = require("../core/dispatch");
|
|
7
7
|
const expand_1 = require("../core/functions/expand/expand");
|
|
8
8
|
const subst_1 = require("../core/functions/subst");
|
|
9
9
|
const geometry_1 = require("./geometry");
|
package/output/math/math.js
CHANGED
|
@@ -146,11 +146,11 @@ function nthroot(x, n) {
|
|
|
146
146
|
}
|
|
147
147
|
/** Converts degrees to radians exactly. */
|
|
148
148
|
function radians(x) {
|
|
149
|
-
return Expression_1.Expression.create(x).times(Expression_1.Expression.Pi()).div(180);
|
|
149
|
+
return Expression_1.Expression.create(x).times(Expression_1.Expression.Pi()).div(Expression_1.Expression.create(180));
|
|
150
150
|
}
|
|
151
151
|
/** Converts radians to degrees exactly. */
|
|
152
152
|
function degrees(x) {
|
|
153
|
-
return Expression_1.Expression.create(x).times(180).div(Expression_1.Expression.Pi());
|
|
153
|
+
return Expression_1.Expression.create(x).times(Expression_1.Expression.create(180)).div(Expression_1.Expression.Pi());
|
|
154
154
|
}
|
|
155
155
|
/** Returns the base-10 logarithm using the ordinary logarithm implementation. */
|
|
156
156
|
function log10(x) {
|
|
@@ -366,7 +366,7 @@ function doubleFactorial(x) {
|
|
|
366
366
|
for (let i = 1; i <= n; i++) {
|
|
367
367
|
let q = (0, shortcuts_1.two)().times(i);
|
|
368
368
|
if (!even) {
|
|
369
|
-
q = q.minus(
|
|
369
|
+
q = q.minus((0, shortcuts_1.one)());
|
|
370
370
|
}
|
|
371
371
|
r = r.times(q);
|
|
372
372
|
}
|
|
@@ -380,7 +380,7 @@ function doubleFactorial(x) {
|
|
|
380
380
|
.minus((0, trig_1.cos)(pi.times(x)))
|
|
381
381
|
.div((0, shortcuts_1.four)()));
|
|
382
382
|
const b = pi.pow((0, trig_1.cos)(pi.times(x)).minus((0, shortcuts_1.one)()).div((0, shortcuts_1.four)()));
|
|
383
|
-
const c = gamma(x.div((0, shortcuts_1.two)()).plus(
|
|
383
|
+
const c = gamma(x.div((0, shortcuts_1.two)()).plus((0, shortcuts_1.one)()));
|
|
384
384
|
retval = a.times(b).times(c);
|
|
385
385
|
}
|
|
386
386
|
}
|
|
@@ -429,13 +429,13 @@ function heaviside(x) {
|
|
|
429
429
|
retval = (0, shortcuts_1.half)();
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
else if (useAssumptions && x.gt(0)) {
|
|
432
|
+
else if (useAssumptions && x.gt((0, shortcuts_1.zero)())) {
|
|
433
433
|
retval = (0, shortcuts_1.one)();
|
|
434
434
|
}
|
|
435
|
-
else if (useAssumptions && x.lt(0)) {
|
|
435
|
+
else if (useAssumptions && x.lt((0, shortcuts_1.zero)())) {
|
|
436
436
|
retval = (0, shortcuts_1.zero)();
|
|
437
437
|
}
|
|
438
|
-
else if (useAssumptions && x.gte(0) && x.lte(0)) {
|
|
438
|
+
else if (useAssumptions && x.gte((0, shortcuts_1.zero)()) && x.lte((0, shortcuts_1.zero)())) {
|
|
439
439
|
retval = (0, shortcuts_1.half)();
|
|
440
440
|
}
|
|
441
441
|
else {
|
|
@@ -528,7 +528,7 @@ function dirac(x) {
|
|
|
528
528
|
retval = (0, shortcuts_1.zero)();
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
|
-
else if (useAssumptions && (x.gt(0) || x.lt(0))) {
|
|
531
|
+
else if (useAssumptions && (x.gt((0, shortcuts_1.zero)()) || x.lt((0, shortcuts_1.zero)()))) {
|
|
532
532
|
retval = (0, shortcuts_1.zero)();
|
|
533
533
|
}
|
|
534
534
|
else {
|
|
@@ -672,13 +672,13 @@ function sign(x) {
|
|
|
672
672
|
else if (!(0, assume_1.hasAssumptions)()) {
|
|
673
673
|
retval = Expression_1.Expression.toFunction(constants_1.SGN, [x]);
|
|
674
674
|
}
|
|
675
|
-
else if (x.gt(0)) {
|
|
675
|
+
else if (x.gt((0, shortcuts_1.zero)())) {
|
|
676
676
|
retval = (0, shortcuts_1.one)();
|
|
677
677
|
}
|
|
678
|
-
else if (x.lt(0)) {
|
|
678
|
+
else if (x.lt((0, shortcuts_1.zero)())) {
|
|
679
679
|
retval = (0, shortcuts_1.one)().neg();
|
|
680
680
|
}
|
|
681
|
-
else if (x.eq(0)) {
|
|
681
|
+
else if (x.eq((0, shortcuts_1.zero)())) {
|
|
682
682
|
retval = (0, shortcuts_1.zero)();
|
|
683
683
|
}
|
|
684
684
|
else {
|
|
@@ -784,11 +784,11 @@ function abs(x) {
|
|
|
784
784
|
else if (x.isComplex()) {
|
|
785
785
|
retval = (0, geometry_1.hypot)(x.realPart(), x.imagPart());
|
|
786
786
|
}
|
|
787
|
-
else if (useAssumptions && x.gte(0)) {
|
|
787
|
+
else if (useAssumptions && x.gte((0, shortcuts_1.zero)())) {
|
|
788
788
|
retval = x;
|
|
789
789
|
wrap = false;
|
|
790
790
|
}
|
|
791
|
-
else if (useAssumptions && x.lte(0)) {
|
|
791
|
+
else if (useAssumptions && x.lte((0, shortcuts_1.zero)())) {
|
|
792
792
|
retval = x.neg();
|
|
793
793
|
wrap = false;
|
|
794
794
|
}
|
|
@@ -874,7 +874,7 @@ function modInv(a, p) {
|
|
|
874
874
|
[t, tp] = [tp, t.minus(q.times(tp))];
|
|
875
875
|
[r, rp] = [rp, r.minus(q.times(rp))];
|
|
876
876
|
}
|
|
877
|
-
if (r.gt(
|
|
877
|
+
if (r.gt((0, shortcuts_1.one)())) {
|
|
878
878
|
throw new errors_1.MathError((0, errors_1.message)('noInverse'));
|
|
879
879
|
}
|
|
880
880
|
return mod(t, p);
|
|
@@ -1443,8 +1443,8 @@ function log(x, base, expandPrimes = false) {
|
|
|
1443
1443
|
if (baseExpr &&
|
|
1444
1444
|
x.isInteger() &&
|
|
1445
1445
|
baseExpr.isInteger() &&
|
|
1446
|
-
x.gt(0) &&
|
|
1447
|
-
baseExpr.gt(
|
|
1446
|
+
x.gt((0, shortcuts_1.zero)()) &&
|
|
1447
|
+
baseExpr.gt((0, shortcuts_1.one)())) {
|
|
1448
1448
|
const target = x.getMultiplier().numerator;
|
|
1449
1449
|
const radix = baseExpr.getMultiplier().numerator;
|
|
1450
1450
|
let value = 1n;
|
|
@@ -1481,7 +1481,7 @@ function log(x, base, expandPrimes = false) {
|
|
|
1481
1481
|
retval = Expression_1.Expression.toFunction(Expression_1.Expression.LOG, [Expression_1.Expression.create(x)]);
|
|
1482
1482
|
}
|
|
1483
1483
|
}
|
|
1484
|
-
else if (!x.isComplex() && x.lt(0)) {
|
|
1484
|
+
else if (!x.isComplex() && x.lt((0, shortcuts_1.zero)())) {
|
|
1485
1485
|
retval = Expression_1.Expression.Pi().times(Expression_1.Expression.Img()).plus(log(x.abs()));
|
|
1486
1486
|
}
|
|
1487
1487
|
// Handle complex numbers regardless of EVALUATE setting
|
|
@@ -1551,7 +1551,7 @@ function log(x, base, expandPrimes = false) {
|
|
|
1551
1551
|
for (const element of elements) {
|
|
1552
1552
|
let elementIsPositive = false;
|
|
1553
1553
|
if (element.isNUM()) {
|
|
1554
|
-
elementIsPositive = element.gt(0);
|
|
1554
|
+
elementIsPositive = element.gt((0, shortcuts_1.zero)());
|
|
1555
1555
|
}
|
|
1556
1556
|
else {
|
|
1557
1557
|
const elementPower = element.getPower();
|
|
@@ -1561,7 +1561,7 @@ function log(x, base, expandPrimes = false) {
|
|
|
1561
1561
|
elementIsPositive =
|
|
1562
1562
|
!elementPower.isComplex() &&
|
|
1563
1563
|
!elementBase.isComplex() &&
|
|
1564
|
-
elementBase.gt(0);
|
|
1564
|
+
elementBase.gt((0, shortcuts_1.zero)());
|
|
1565
1565
|
}
|
|
1566
1566
|
if (!elementIsPositive) {
|
|
1567
1567
|
canSplitProduct = false;
|
|
@@ -1582,11 +1582,11 @@ function log(x, base, expandPrimes = false) {
|
|
|
1582
1582
|
const baseExpr = mFree.isEXP() ? mFree.getBase() : (0, utils_3.stripPower)(mFree);
|
|
1583
1583
|
if (pow.isOne()) {
|
|
1584
1584
|
logExpr = Expression_1.Expression.toFunction(Expression_1.Expression.LOG, [mFree]);
|
|
1585
|
-
mFreeIsPositive = !mFree.isComplex() && mFree.gt(0);
|
|
1585
|
+
mFreeIsPositive = !mFree.isComplex() && mFree.gt((0, shortcuts_1.zero)());
|
|
1586
1586
|
}
|
|
1587
1587
|
// log(a^p) → p*log(a) is branch-safe for a positive real base
|
|
1588
1588
|
// and a real exponent. Unknown-sign bases remain attached.
|
|
1589
|
-
else if (!pow.isComplex() && !baseExpr.isComplex() && baseExpr.gt(0)) {
|
|
1589
|
+
else if (!pow.isComplex() && !baseExpr.isComplex() && baseExpr.gt((0, shortcuts_1.zero)())) {
|
|
1590
1590
|
logExpr = log(baseExpr).times(pow);
|
|
1591
1591
|
mFreeIsPositive = true;
|
|
1592
1592
|
}
|
package/output/math/trig.js
CHANGED
|
@@ -402,8 +402,8 @@ function tan(x) {
|
|
|
402
402
|
retval = Expression_1.Expression.Number(x.getMultiplier().toDecimal().tan());
|
|
403
403
|
}
|
|
404
404
|
else if (Settings_1.Settings.EVALUATE && x.isComplex()) {
|
|
405
|
-
const dblRe = x.realPart().times(
|
|
406
|
-
const dblIm = x.imagPart().times(
|
|
405
|
+
const dblRe = x.realPart().times((0, shortcuts_1.two)());
|
|
406
|
+
const dblIm = x.imagPart().times((0, shortcuts_1.two)());
|
|
407
407
|
const d = cos(dblRe).plus(cosh(dblIm));
|
|
408
408
|
retval = sin(dblRe).div(d).plus(sinh(dblIm).div(d).i());
|
|
409
409
|
}
|
|
@@ -599,7 +599,7 @@ function acos(x) {
|
|
|
599
599
|
let retval;
|
|
600
600
|
if (Settings_1.Settings.EVALUATE && x.isNUM()) {
|
|
601
601
|
// Becomes complex between [-1, 1]
|
|
602
|
-
if (x.lt(
|
|
602
|
+
if (x.lt((0, shortcuts_1.minusOne)()) || x.gt((0, shortcuts_1.one)())) {
|
|
603
603
|
const sgn = x.sign();
|
|
604
604
|
const halfPi = Expression_1.Expression.Pi().div((0, shortcuts_1.two)());
|
|
605
605
|
let asinX = asin(x.abs());
|
|
@@ -1225,7 +1225,7 @@ function acosh(x) {
|
|
|
1225
1225
|
retval = Expression_1.Expression.Pi().div((0, shortcuts_1.two)()).times(Expression_1.Expression.Img());
|
|
1226
1226
|
}
|
|
1227
1227
|
else if (Settings_1.Settings.EVALUATE) {
|
|
1228
|
-
if (x.isComplex() || x.lt(
|
|
1228
|
+
if (x.isComplex() || x.lt((0, shortcuts_1.one)())) {
|
|
1229
1229
|
const a = (0, math_1.sqrt)(x.plus((0, shortcuts_1.one)()));
|
|
1230
1230
|
const b = (0, math_1.sqrt)(x.minus((0, shortcuts_1.one)()));
|
|
1231
1231
|
const c = x.plus(a.times(b));
|
package/output/solve/solve.js
CHANGED
|
@@ -55,7 +55,7 @@ function calculateSolutions(factors, variable, disjointPolynomialFactors = false
|
|
|
55
55
|
else if (fn.hasVariable(variable)) {
|
|
56
56
|
// First Symbolically
|
|
57
57
|
let solutions = new SymbolicSolver_1.SymbolicSolver(fn, variable).solve();
|
|
58
|
-
if (solutions.unsolved && fn.isPolynomialLike() && fn.getPower().gt(
|
|
58
|
+
if (solutions.unsolved && fn.isPolynomialLike() && fn.getPower().gt((0, shortcuts_1.four)())) {
|
|
59
59
|
const linearPoly = fn.toLinearAndUnitMultiplier();
|
|
60
60
|
// See if you can solve the linear polynomial
|
|
61
61
|
solutions = new SymbolicSolver_1.SymbolicSolver(linearPoly, variable).solve();
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nerdamer",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
|
-
"tag": "
|
|
5
|
+
"tag": "latest"
|
|
6
6
|
},
|
|
7
7
|
"description": "A symbolic math library and computer algebra system for JavaScript and TypeScript.",
|
|
8
8
|
"directory": {
|
|
@@ -29,13 +29,14 @@
|
|
|
29
29
|
"build:types": "npm run clean:modules && tsc -p tsconfig.build.json",
|
|
30
30
|
"build:modules": "npm run build:types",
|
|
31
31
|
"build:bundle": "npm run clean:dist && webpack --mode=production --env target=full",
|
|
32
|
+
"build:bundle:all-languages": "npm run clean:dist && webpack --mode=production --env target=full --env language=all",
|
|
32
33
|
"build:parser": "webpack --mode=production --env target=parser && node tools/smoke-build.cjs parser",
|
|
33
34
|
"build:full": "npm run build:modules && npm run build:bundle && node tools/smoke-build.cjs full",
|
|
35
|
+
"build:all-languages": "npm run build:modules && npm run build:bundle:all-languages && node tools/smoke-build.cjs full",
|
|
34
36
|
"build": "npm run build:full",
|
|
35
37
|
"docs:parser": "ts-node tools/generate-parser-docs.ts",
|
|
36
|
-
"docs:check": "typedoc --options typedoc.json --emit none",
|
|
37
38
|
"validate:package": "ts-node tools/validate-package.ts",
|
|
38
|
-
"prepublishOnly": "npm run typecheck && npm run test && npm run test:coverage && npm run build && npm run
|
|
39
|
+
"prepublishOnly": "npm run typecheck && npm run test && npm run test:coverage && npm run build && npm run validate:package",
|
|
39
40
|
"clean:modules": "node -e \"require('node:fs').rmSync('output', { recursive: true, force: true })\"",
|
|
40
41
|
"clean:dist": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\""
|
|
41
42
|
},
|
|
@@ -160,21 +161,39 @@
|
|
|
160
161
|
"default": "./output/api/debug.js"
|
|
161
162
|
},
|
|
162
163
|
"./docs-data/parser-functions.json": "./docs-data/parser-functions.json",
|
|
164
|
+
"./docs-data/typedoc.json": "./docs-data/typedoc.json",
|
|
163
165
|
"./dist/bundle.js": "./dist/bundle.js",
|
|
164
|
-
"./dist/parser.js": "./dist/parser.js",
|
|
165
166
|
"./package.json": "./package.json"
|
|
166
167
|
},
|
|
167
168
|
"typesVersions": {
|
|
168
169
|
"*": {
|
|
169
|
-
"core": [
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
"
|
|
176
|
-
|
|
177
|
-
|
|
170
|
+
"core": [
|
|
171
|
+
"output/api/core.d.ts"
|
|
172
|
+
],
|
|
173
|
+
"algebra": [
|
|
174
|
+
"output/api/algebra.d.ts"
|
|
175
|
+
],
|
|
176
|
+
"calculus": [
|
|
177
|
+
"output/api/calculus.d.ts"
|
|
178
|
+
],
|
|
179
|
+
"solve": [
|
|
180
|
+
"output/api/solve.d.ts"
|
|
181
|
+
],
|
|
182
|
+
"structures": [
|
|
183
|
+
"output/api/structures.d.ts"
|
|
184
|
+
],
|
|
185
|
+
"assumptions": [
|
|
186
|
+
"output/api/assumptions.d.ts"
|
|
187
|
+
],
|
|
188
|
+
"parser": [
|
|
189
|
+
"output/api/parser.d.ts"
|
|
190
|
+
],
|
|
191
|
+
"advanced": [
|
|
192
|
+
"output/api/advanced.d.ts"
|
|
193
|
+
],
|
|
194
|
+
"debug": [
|
|
195
|
+
"output/api/debug.d.ts"
|
|
196
|
+
]
|
|
178
197
|
}
|
|
179
198
|
}
|
|
180
|
-
}
|
|
199
|
+
}
|