@cortex-js/compute-engine 0.8.0 → 0.9.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/dist/compute-engine.esm.js +7800 -6891
- package/dist/compute-engine.min.esm.js +2 -2
- package/dist/compute-engine.min.js +2 -2
- package/dist/math-json.esm.js +41 -88
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -5
- package/dist/types/common/utils.d.ts +1 -0
- package/dist/types/compute-engine/assume.d.ts +6 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +10 -14
- package/dist/types/compute-engine/boxed-expression/box.d.ts +74 -16
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +10 -5
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +3 -4
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +16 -14
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +20 -19
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +8 -7
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +18 -12
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +7 -7
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +18 -0
- package/dist/types/compute-engine/compute-engine.d.ts +64 -33
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +2 -8
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +25 -9
- package/dist/types/compute-engine/latex-syntax/public.d.ts +14 -6
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +3 -3
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +5 -6
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +3 -2
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/numerics/{numeric-decimal.d.ts → numeric-bignum.d.ts} +10 -6
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +10 -6
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +56 -0
- package/dist/types/compute-engine/public.d.ts +200 -247
- package/dist/types/compute-engine/rules.d.ts +7 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +17 -0
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +2 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +30 -12
- package/dist/types/compute-engine/symbolic/sum.d.ts +13 -7
- package/dist/types/compute-engine/symbolic/utils.d.ts +7 -29
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +2 -2
- package/dist/types/math-json/utils.d.ts +11 -41
- package/dist/types/math-json.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.9.0 */
|
|
2
2
|
* The most important classes are {@link ComputeEngine} and
|
|
3
3
|
* {@link BoxedExpression}.
|
|
4
4
|
*
|
|
@@ -13,6 +13,7 @@ import type { SignalMessage, WarningSignal, WarningSignalHandler } from '../comm
|
|
|
13
13
|
import type { Expression, MathJsonDictionary, MathJsonFunction, MathJsonNumber, MathJsonString, MathJsonSymbol } from '../math-json/math-json-format';
|
|
14
14
|
import type { NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
|
|
15
15
|
export * from './latex-syntax/public';
|
|
16
|
+
export declare type Rational = [number, number] | [Decimal, Decimal];
|
|
16
17
|
/**
|
|
17
18
|
* Metadata that can be associated with a `BoxedExpression`
|
|
18
19
|
*/
|
|
@@ -23,18 +24,19 @@ export declare type Metadata = {
|
|
|
23
24
|
/**
|
|
24
25
|
* The numeric evaluation mode:
|
|
25
26
|
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
27
|
+
<div class=symbols-table>
|
|
28
|
+
|
|
29
|
+
| Mode | |
|
|
30
|
+
| :--- | :----- |
|
|
31
|
+
| `"auto"`| Use bignum or complex numbers. |
|
|
32
|
+
| `"machine"` | **IEEE 754-2008**, 64-bit floating point numbers: 52-bit mantissa, about 15 digits of precision |
|
|
33
|
+
| `"bignum"` | Arbitrary precision floating point numbers, as provided by the "decimal.js" library |
|
|
34
|
+
| `"complex"` | Complex number represented by two machine numbers, a real and an imaginary part, as provided by the "complex.js" library |
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
37
|
*/
|
|
38
|
+
export declare type NumericMode = 'auto' | 'machine' | 'bignum' | 'complex';
|
|
39
|
+
/** Options for `BoxedExpression.simplify()` */
|
|
38
40
|
export declare type SimplifyOptions = EvaluateOptions & {
|
|
39
41
|
recursive?: boolean;
|
|
40
42
|
rules?: BoxedRuleSet;
|
|
@@ -207,7 +209,14 @@ export declare type JsonSerializationOptions = {
|
|
|
207
209
|
*
|
|
208
210
|
* **Default**: `true`
|
|
209
211
|
*/
|
|
210
|
-
|
|
212
|
+
repeatingDecimals: boolean;
|
|
213
|
+
/** Number literals are serialized with this precision.
|
|
214
|
+
* If `"auto"`, the same precision as the compute engine calculations is used
|
|
215
|
+
* If `"max"`, all available digits are serialized
|
|
216
|
+
*
|
|
217
|
+
* **Default**: `"auto"`
|
|
218
|
+
*/
|
|
219
|
+
precision: 'auto' | 'max' | number;
|
|
211
220
|
};
|
|
212
221
|
/**
|
|
213
222
|
* **Theory of Operations**
|
|
@@ -231,7 +240,7 @@ export interface BoxedExpression {
|
|
|
231
240
|
readonly engine: IComputeEngine;
|
|
232
241
|
/** From `Object.valueOf()`, return a primitive value for the expression.
|
|
233
242
|
*
|
|
234
|
-
* If the expression is a machine number, or
|
|
243
|
+
* If the expression is a machine number, or bignum or rational that can be
|
|
235
244
|
* converted to a machine number, return a `number`.
|
|
236
245
|
*
|
|
237
246
|
* If the expression is a symbol, return the name of the symbol as a `string`.
|
|
@@ -275,6 +284,11 @@ export interface BoxedExpression {
|
|
|
275
284
|
*
|
|
276
285
|
*/
|
|
277
286
|
readonly json: Expression;
|
|
287
|
+
/**
|
|
288
|
+
* The scope in which this expression has been defined.
|
|
289
|
+
* Is null when the expression is not canonical.
|
|
290
|
+
*/
|
|
291
|
+
readonly scope: RuntimeScope | null;
|
|
278
292
|
/** From `Object.is()`. Equivalent to `BoxedExpression.isSame()`
|
|
279
293
|
*
|
|
280
294
|
* @category Primitive Methods
|
|
@@ -427,6 +441,16 @@ export interface BoxedExpression {
|
|
|
427
441
|
* **Note** applicable to canonical and non-canonical expressions.
|
|
428
442
|
*/
|
|
429
443
|
readonly isLiteral: boolean;
|
|
444
|
+
/**
|
|
445
|
+
* An exact value is not further transformed when evaluated. To get an
|
|
446
|
+
* approximate evaluation of an exact value, use `.N()`.
|
|
447
|
+
*
|
|
448
|
+
* Non-exact values includes:
|
|
449
|
+
* - numbers with a fractional part
|
|
450
|
+
* - complex numbers with a real or imaginary fractional part
|
|
451
|
+
*
|
|
452
|
+
*/
|
|
453
|
+
readonly isExact: boolean;
|
|
430
454
|
/** If true, the value of the expression never changes and evaluating it has
|
|
431
455
|
* no side-effects.
|
|
432
456
|
* If false, the value of the expression may change, if the
|
|
@@ -447,28 +471,18 @@ export interface BoxedExpression {
|
|
|
447
471
|
/**
|
|
448
472
|
* Return the canonical form of this expression.
|
|
449
473
|
*
|
|
450
|
-
* If a function,
|
|
451
|
-
*
|
|
474
|
+
* If this is a function expressin, a definition is associated with the
|
|
475
|
+
* canonical expression.
|
|
452
476
|
*
|
|
453
|
-
*
|
|
477
|
+
* When determining the canonical form the following function definition
|
|
478
|
+
* flags are applied:
|
|
454
479
|
* - `associative`: \\( f(a, f(b), c) \longrightarrow f(a, b, c) \\)
|
|
455
480
|
* - `idempotent`: \\( f(f(a)) \longrightarrow f(a) \\)
|
|
456
481
|
* - `involution`: \\( f(f(a)) \longrightarrow a \\)
|
|
457
482
|
* - `commutative`: sort the arguments.
|
|
458
483
|
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
* For example:
|
|
463
|
-
* - \\( 2 + x + 1 \longrightarrow x + 3 \\)
|
|
464
|
-
* - \\( \sqrt{4} \longrightarrow 2 \\)
|
|
465
|
-
* - \\(\frac{4}{10} \longrightarrow \frac{2}{5} \\).
|
|
466
|
-
*
|
|
467
|
-
* However, no calculation is performed involving floating point numbers, so
|
|
468
|
-
* \\( \sqrt(2) \longrightarrow \sqrt(2) \\).
|
|
469
|
-
*
|
|
470
|
-
* **Note** applicable to canonical and non-canonical expressions.
|
|
471
|
-
* Expressions that are already canonical return themselves.
|
|
484
|
+
* If his expression is already canonical, the value of canonical is
|
|
485
|
+
* `this`.
|
|
472
486
|
*
|
|
473
487
|
*/
|
|
474
488
|
get canonical(): BoxedExpression;
|
|
@@ -496,7 +510,9 @@ export interface BoxedExpression {
|
|
|
496
510
|
* **Note** applicable to canonical and non-canonical expressions.
|
|
497
511
|
*
|
|
498
512
|
*/
|
|
499
|
-
subs(sub: Substitution
|
|
513
|
+
subs(sub: Substitution, options?: {
|
|
514
|
+
canonical?: boolean;
|
|
515
|
+
}): BoxedExpression;
|
|
500
516
|
/**
|
|
501
517
|
* Transform the expression by applying the rules:
|
|
502
518
|
* if the `lhs` of a rule matches, it is replaced by its `rhs`.
|
|
@@ -541,7 +557,7 @@ export interface BoxedExpression {
|
|
|
541
557
|
* **Note** applicable to canonical and non-canonical expressions.
|
|
542
558
|
*
|
|
543
559
|
*/
|
|
544
|
-
match(rhs: BoxedExpression, options?:
|
|
560
|
+
match(rhs: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
545
561
|
/**
|
|
546
562
|
* "Not a Number".
|
|
547
563
|
*
|
|
@@ -603,94 +619,15 @@ export interface BoxedExpression {
|
|
|
603
619
|
*/
|
|
604
620
|
readonly isComposite: boolean | undefined;
|
|
605
621
|
/**
|
|
606
|
-
* Return the value of this expression, if
|
|
607
|
-
* number.
|
|
622
|
+
* Return the value of this expression, if a number literal.
|
|
608
623
|
*
|
|
609
|
-
* Note it is possible for `
|
|
624
|
+
* Note it is possible for `numericValue` to be `null`, and for `isNotZero`
|
|
610
625
|
* to be true. For example, when a symbol has been defined with an assumption.
|
|
611
626
|
*
|
|
612
|
-
* If `machineValue` is not `null`, then `decimalValue`, `rationalValue`
|
|
613
|
-
* and `complexValue` are `null.
|
|
614
|
-
*
|
|
615
|
-
* @category Numeric Expression
|
|
616
|
-
*
|
|
617
|
-
*/
|
|
618
|
-
readonly machineValue: number | null;
|
|
619
|
-
/** If the value of this expression is a rational number, return it.
|
|
620
|
-
* Otherwise, return `[null, null]`.
|
|
621
|
-
*
|
|
622
|
-
* If `rationalValue` is not `[null, null]`, then `machineValue`, `decimalValue`
|
|
623
|
-
* and `complexValue` are `null.
|
|
624
|
-
*
|
|
625
|
-
* @category Numeric Expression
|
|
626
|
-
*
|
|
627
|
-
*/
|
|
628
|
-
readonly rationalValue: [numer: number, denom: number] | [null, null];
|
|
629
|
-
/** If the value of this expression is a `Decimal` number, return it.
|
|
630
|
-
* Otherwise, return `null`.
|
|
631
|
-
*
|
|
632
|
-
* A `Decimal` number is an arbitrarily long floating point number.
|
|
633
|
-
*
|
|
634
|
-
* If `decimalValue` is not `null`, then `machineValue`
|
|
635
|
-
* and `complexValue` are `null` and `rationalValue` is `[null, null]`.
|
|
636
|
-
*
|
|
637
627
|
* @category Numeric Expression
|
|
638
628
|
*
|
|
639
629
|
*/
|
|
640
|
-
readonly
|
|
641
|
-
/** If the value of this expression is a `Complex` number, return it.
|
|
642
|
-
* Otherwise, return `null`.
|
|
643
|
-
*
|
|
644
|
-
* If `complexValue` is not `null`, then `machineValue`, `rationalValue`
|
|
645
|
-
* and `decimalValue` are `null.
|
|
646
|
-
*
|
|
647
|
-
* @category Numeric Expression
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
*/
|
|
651
|
-
readonly complexValue: Complex | null;
|
|
652
|
-
/** Return an approximation of the numeric value of this expression as
|
|
653
|
-
* a 64-bit floating point number.
|
|
654
|
-
*
|
|
655
|
-
* If the value is a machine number, return it exactly.
|
|
656
|
-
*
|
|
657
|
-
* If the value is a rational number, return the numerator divided by the
|
|
658
|
-
* denominator.
|
|
659
|
-
*
|
|
660
|
-
* If the value is a Decimal number return an approximation of the decimal
|
|
661
|
-
* number to a machine number. There might be a loss of precision or a
|
|
662
|
-
* round to 0 or Infinity, depending on the value.
|
|
663
|
-
*
|
|
664
|
-
* If the value of this expression cannot be represented by a float,
|
|
665
|
-
* return `null`.
|
|
666
|
-
*
|
|
667
|
-
* @category Numeric Expression
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
*/
|
|
671
|
-
readonly asFloat: number | null;
|
|
672
|
-
/**
|
|
673
|
-
* If the value of this expression is an integer with a 'small' absolute
|
|
674
|
-
* value, return this value. Otherwise, return `null`.
|
|
675
|
-
*
|
|
676
|
-
* Some calculations, for example to put in canonical forms, are only
|
|
677
|
-
* performed if they are safe from overflow. This method makes it easy
|
|
678
|
-
* to check for this, whether the value is a Decimal or a number.
|
|
679
|
-
*
|
|
680
|
-
* By default, "small" is less than 1,000,000.
|
|
681
|
-
*
|
|
682
|
-
* @category Numeric Expression
|
|
683
|
-
*
|
|
684
|
-
*/
|
|
685
|
-
readonly asSmallInteger: number | null;
|
|
686
|
-
/**
|
|
687
|
-
* If the value of this an expression is a small integer or a rational,
|
|
688
|
-
* return this value. Otherwise, return `[null, null]`.
|
|
689
|
-
*
|
|
690
|
-
* @category Numeric Expression
|
|
691
|
-
*
|
|
692
|
-
*/
|
|
693
|
-
readonly asRational: [number, number] | [null, null];
|
|
630
|
+
readonly numericValue: number | Decimal | Complex | Rational | null;
|
|
694
631
|
/**
|
|
695
632
|
* Return the following, depending on the value of this expression:
|
|
696
633
|
*
|
|
@@ -864,19 +801,21 @@ export interface BoxedExpression {
|
|
|
864
801
|
*/
|
|
865
802
|
unbind(): void;
|
|
866
803
|
/**
|
|
867
|
-
* Return a simpler form of this expression.
|
|
804
|
+
* Return a simpler form of the canonical form of this expression.
|
|
868
805
|
*
|
|
869
|
-
*
|
|
870
|
-
*
|
|
806
|
+
* A series of rewriting rules are applied repeatedly, until no more rules
|
|
807
|
+
* apply.
|
|
871
808
|
*
|
|
872
|
-
* If a custom `simplify` handler is associated with this function
|
|
873
|
-
* it is invoked.
|
|
809
|
+
* If a custom `simplify` handler is associated with this function
|
|
810
|
+
* definition, it is invoked.
|
|
874
811
|
*
|
|
875
812
|
* The values assigned to symbols and the assumptions about symbols may be
|
|
876
813
|
* used, for example `arg.isInteger` or `arg.isPositive`.
|
|
877
814
|
*
|
|
878
|
-
* No calculations involving
|
|
879
|
-
* calculations may be performed,
|
|
815
|
+
* No calculations involving decimal numbers (numbers that are not
|
|
816
|
+
* integers) are performed but exact calculations may be performed,
|
|
817
|
+
* for example:
|
|
818
|
+
*
|
|
880
819
|
* \\( \sin(\frac{\pi}{4}) \longrightarrow \frac{\sqrt{2}}{2} \\).
|
|
881
820
|
*
|
|
882
821
|
* The result is in canonical form.
|
|
@@ -884,33 +823,37 @@ export interface BoxedExpression {
|
|
|
884
823
|
*/
|
|
885
824
|
simplify(options?: SimplifyOptions): BoxedExpression;
|
|
886
825
|
/**
|
|
887
|
-
* Return the value of this expression.
|
|
888
|
-
*
|
|
889
|
-
* The expression is first converted to canonical form.
|
|
826
|
+
* Return the value of the canonical form of this expression.
|
|
890
827
|
*
|
|
891
828
|
* A pure expression always return the same value and has no side effects.
|
|
892
|
-
* If `
|
|
893
|
-
*
|
|
829
|
+
* If `expr.isPure` is `true`, `expr.value` and `expr.evaluate()` are
|
|
830
|
+
* synonyms.
|
|
831
|
+
*
|
|
832
|
+
* For an impure expression, `expr.value` is undefined.
|
|
894
833
|
*
|
|
895
834
|
* Evaluating an impure expression may have some side effects, for
|
|
896
|
-
* example modifying the `ComputeEngine` environment, such as its set of
|
|
835
|
+
* example modifying the `ComputeEngine` environment, such as its set of
|
|
836
|
+
* assumptions.
|
|
837
|
+
*
|
|
838
|
+
* Only exact calculations are performed, no approximate calculations on
|
|
839
|
+
* decimal numbers (non-integer numbers). Constants, rational numbers and
|
|
840
|
+
* square root of rational numbers are preserved.
|
|
897
841
|
*
|
|
898
|
-
*
|
|
899
|
-
* To perform approximate floating point calculations, use `this.N()` instead.
|
|
842
|
+
* To perform approximate calculations, use `expr.N()` instead.
|
|
900
843
|
*
|
|
901
|
-
* The result of `
|
|
844
|
+
* The result of `expr.evaluate()` may be the same as `expr.simplify()`.
|
|
902
845
|
*
|
|
903
846
|
* The result is in canonical form.
|
|
904
847
|
*
|
|
905
848
|
*/
|
|
906
849
|
evaluate(options?: EvaluateOptions): BoxedExpression;
|
|
907
|
-
/** Return a numeric approximation of this expression.
|
|
850
|
+
/** Return a numeric approximation of the canonical form of this expression.
|
|
908
851
|
*
|
|
909
|
-
*
|
|
852
|
+
* Any necessary calculations, including on decimal numbers (non-integers),
|
|
853
|
+
* are performed.
|
|
910
854
|
*
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
* to the `numericMode` and `precision` properties of the `ComputeEngine`.
|
|
855
|
+
* The calculations are performed according to the `numericMode` and
|
|
856
|
+
* `precision` properties of the `ComputeEngine`.
|
|
914
857
|
*
|
|
915
858
|
* To only perform exact calculations, use `this.evaluate()` instead.
|
|
916
859
|
*
|
|
@@ -938,16 +881,6 @@ export interface BoxedExpression {
|
|
|
938
881
|
*
|
|
939
882
|
*/
|
|
940
883
|
set value(value: BoxedExpression | number | undefined);
|
|
941
|
-
/** An approximation of the value of this expression. Floating-point
|
|
942
|
-
* operations may be performed.
|
|
943
|
-
*
|
|
944
|
-
* Just like `this.value`, it returns `undefined` for expressions that are
|
|
945
|
-
* not pure.
|
|
946
|
-
*
|
|
947
|
-
* **Note**: If non-canonical, return the numeric value of its canonical
|
|
948
|
-
* counterpart
|
|
949
|
-
*/
|
|
950
|
-
readonly numericValue: BoxedExpression | undefined;
|
|
951
884
|
/** The domain of the value of this expression.
|
|
952
885
|
*
|
|
953
886
|
* If a function expression, the domain of the value of the function (the codomain of the function).
|
|
@@ -966,7 +899,7 @@ export interface BoxedExpression {
|
|
|
966
899
|
* **Note**: If non-canonical, does nothing.
|
|
967
900
|
*
|
|
968
901
|
*/
|
|
969
|
-
set domain(domain:
|
|
902
|
+
set domain(domain: BoxedExpression | DomainExpression | BoxedDomain);
|
|
970
903
|
/** `true` if the value of this expression is a number.
|
|
971
904
|
*
|
|
972
905
|
* `isExtendedComplex || isNaN` = `isReal || isImaginary || isInfinity || isNaN`
|
|
@@ -1064,29 +997,18 @@ export interface BoxedExpression {
|
|
|
1064
997
|
* This is convenient when creating new expressions from portions
|
|
1065
998
|
* of an existing `BoxedExpression` while avoiding unboxing and reboxing.
|
|
1066
999
|
*/
|
|
1067
|
-
export declare type SemiBoxedExpression =
|
|
1068
|
-
export declare type
|
|
1069
|
-
|
|
1070
|
-
export declare type PatternMatchOption = {
|
|
1000
|
+
export declare type SemiBoxedExpression = number | string | Decimal | Complex | MathJsonNumber | MathJsonString | MathJsonSymbol | MathJsonFunction | MathJsonDictionary | SemiBoxedExpression[] | BoxedExpression;
|
|
1001
|
+
export declare type PatternMatchOptions = {
|
|
1002
|
+
substitution?: BoxedSubstitution;
|
|
1071
1003
|
recursive?: boolean;
|
|
1072
1004
|
numericTolerance?: number;
|
|
1073
1005
|
exact?: boolean;
|
|
1074
1006
|
};
|
|
1075
1007
|
export interface Pattern extends BoxedExpression {
|
|
1076
|
-
/**
|
|
1077
|
-
* If `expr` does not match the pattern, return `null`.
|
|
1078
|
-
*
|
|
1079
|
-
* Otherwise, return a substitution describing the values that the named
|
|
1080
|
-
* wildcard in the pattern should be changed to in order for the pattern to be
|
|
1081
|
-
* equal to the expression. If there are no named wildcards and the expression
|
|
1082
|
-
* matches the pattern, and empty object literal `{}` is returned.
|
|
1083
|
-
*/
|
|
1084
|
-
match(expr: BoxedExpression, options?: PatternMatchOption): BoxedSubstitution | null;
|
|
1085
1008
|
/** If `expr` matches the pattern, return `true`, otherwise `false` */
|
|
1086
|
-
test(expr: BoxedExpression, options?:
|
|
1009
|
+
test(expr: BoxedExpression, options?: PatternMatchOptions): boolean;
|
|
1087
1010
|
/** Return the number of exprs that matched the pattern */
|
|
1088
|
-
count(exprs: Iterable<BoxedExpression>, options?:
|
|
1089
|
-
subs(sub: Substitution): Pattern;
|
|
1011
|
+
count(exprs: Iterable<BoxedExpression>, options?: PatternMatchOptions): number;
|
|
1090
1012
|
}
|
|
1091
1013
|
export interface ExpressionMapInterface<U> {
|
|
1092
1014
|
has(expr: BoxedExpression): boolean;
|
|
@@ -1163,7 +1085,7 @@ export declare type Scope = {
|
|
|
1163
1085
|
iterationLimit?: number;
|
|
1164
1086
|
};
|
|
1165
1087
|
export declare type RuntimeScope = Scope & {
|
|
1166
|
-
parentScope
|
|
1088
|
+
parentScope?: RuntimeScope;
|
|
1167
1089
|
symbolTable?: RuntimeSymbolTable;
|
|
1168
1090
|
assumptions: undefined | ExpressionMapInterface<boolean>;
|
|
1169
1091
|
/** The location of the call site that created this scope */
|
|
@@ -1304,12 +1226,6 @@ export declare type FunctionDefinitionFlags = {
|
|
|
1304
1226
|
* and its value is numeric.
|
|
1305
1227
|
*/
|
|
1306
1228
|
numeric: boolean;
|
|
1307
|
-
/**
|
|
1308
|
-
* When true, evaluating the function create a temporary scope.
|
|
1309
|
-
* This is used for example by the `Lambda` function to keep track of the
|
|
1310
|
-
* inferred domain of its wildcard `_` arguments
|
|
1311
|
-
*/
|
|
1312
|
-
scoped: boolean;
|
|
1313
1229
|
};
|
|
1314
1230
|
/**
|
|
1315
1231
|
*
|
|
@@ -1326,76 +1242,89 @@ export declare type FunctionSignature = {
|
|
|
1326
1242
|
/**
|
|
1327
1243
|
* Return the canonical form of the expression with the arguments `args`.
|
|
1328
1244
|
*
|
|
1329
|
-
*
|
|
1330
|
-
*
|
|
1245
|
+
* The arguments (`args`) may not be in canonical form. If necessary, they
|
|
1246
|
+
* can be put in canonical form.
|
|
1331
1247
|
*
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1248
|
+
* This handler should validate the domain and number of the arguments.
|
|
1249
|
+
* If a required argument is missing, it should be indicated with a
|
|
1250
|
+
* `["Error", "'missing"]` expression. If more arguments than expected
|
|
1251
|
+
* are present, this should be indicated with a `unexpected-argument` error.
|
|
1252
|
+
* If the domain of an argument is not compatible, it should be indicated with
|
|
1253
|
+
* a `incompatible-domain` error.
|
|
1335
1254
|
*
|
|
1336
|
-
*
|
|
1337
|
-
*
|
|
1338
|
-
* `arg.isLiteral && arg.isRational`) or integers (i.e.
|
|
1339
|
-
* `isLiteral && arg.isInteger`).
|
|
1255
|
+
* `["Sequence"]` expressions are not folded and need to be handled
|
|
1256
|
+
* explicitly.
|
|
1340
1257
|
*
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1258
|
+
* If the function is associative, idempotent or an involution,
|
|
1259
|
+
* this handler should account for it. Notably, if it is commutative, the
|
|
1260
|
+
* arguments should be sorted in canonical order.
|
|
1343
1261
|
*
|
|
1344
|
-
* The handler
|
|
1345
|
-
*
|
|
1346
|
-
* `arg.isInteger`, etc...
|
|
1262
|
+
* The handler can make transformations based on the value of the arguments
|
|
1263
|
+
* that are exact (i.e. `arg.isExact`).
|
|
1347
1264
|
*
|
|
1348
|
-
* The handler should not
|
|
1349
|
-
*
|
|
1265
|
+
* The handler should not consider the value or any assumptions about any
|
|
1266
|
+
* of the arguments that are symbols or functions (i.e. `arg.isZero`,
|
|
1267
|
+
* `arg.isInteger`, etc...) since those may change over time.
|
|
1350
1268
|
*
|
|
1351
1269
|
* The result of the handler should be a canonical expression.
|
|
1352
1270
|
*
|
|
1271
|
+
* If the arguments do not match, they should be replaced with an appropriate
|
|
1272
|
+
* `["Error"]` expression. If the expression cannot be put in canonical form,
|
|
1273
|
+
* the handler should return `null`.
|
|
1274
|
+
*
|
|
1353
1275
|
*/
|
|
1354
|
-
canonical?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression;
|
|
1276
|
+
canonical?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | null;
|
|
1355
1277
|
/**
|
|
1356
1278
|
* Rewrite an expression into a simpler form.
|
|
1357
1279
|
*
|
|
1358
1280
|
* The arguments are in canonical form and have been simplified.
|
|
1359
1281
|
*
|
|
1360
|
-
* The handler can use the values assigned to symbols and the assumptions
|
|
1361
|
-
* symbols, for example with `arg.
|
|
1282
|
+
* The handler can use the values assigned to symbols and the assumptions
|
|
1283
|
+
* about symbols, for example with `arg.numericValue`, `arg.isInteger` or
|
|
1362
1284
|
* `arg.isPositive`.
|
|
1363
1285
|
*
|
|
1364
1286
|
* Even though a symbol may not have a value, there may be some information
|
|
1365
1287
|
* about it reflected for example in `this.isZero` or `this.isPrime`.
|
|
1366
1288
|
*
|
|
1367
1289
|
* The handler should not perform approximate numeric calculations, such
|
|
1368
|
-
* as calculations involving
|
|
1369
|
-
* calculations on integers or rationals is OK.
|
|
1370
|
-
* required, that the calculations be limited to `this.smallIntegerValue`
|
|
1371
|
-
* (i.e. numeric representations of the expression as an integer of small
|
|
1372
|
-
* magnitude).
|
|
1290
|
+
* as calculations involving decimal numbers (non-integers). Making exact
|
|
1291
|
+
* calculations on integers or rationals is OK.
|
|
1373
1292
|
*
|
|
1374
1293
|
* This handler should not have any side-effects: do not modify
|
|
1375
1294
|
* the environment of the `ComputeEngine` instance, do not perform I/O,
|
|
1376
1295
|
* do not do calculations that depend on random values.
|
|
1377
1296
|
*
|
|
1378
|
-
* If no simplification can be performed due to the values, domains or
|
|
1379
|
-
* about its arguments, for example, return `undefined`.
|
|
1297
|
+
* If no simplification can be performed due to the values, domains or
|
|
1298
|
+
* assumptions about its arguments, for example, return `undefined`.
|
|
1380
1299
|
*
|
|
1381
1300
|
*/
|
|
1382
1301
|
simplify?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
|
|
1383
1302
|
/**
|
|
1384
|
-
* Evaluate symbolically
|
|
1303
|
+
* Evaluate symbolically a function expression.
|
|
1385
1304
|
*
|
|
1386
1305
|
* The arguments have been symbolically evaluated, except the arguments to
|
|
1387
1306
|
* which a `hold` apply.
|
|
1388
1307
|
*
|
|
1389
1308
|
* It is not necessary to further simplify or evaluate the arguments.
|
|
1390
1309
|
*
|
|
1391
|
-
* If
|
|
1392
|
-
*
|
|
1310
|
+
* If performing numerical calculations, if all the arguments are exact,
|
|
1311
|
+
* return an exact expression. If any of the arguments is not exact, that is
|
|
1312
|
+
* if it is a literal decimal (non-integer) number, return an approximation.
|
|
1313
|
+
* In this case, the value may be the same as `expr.N()`.
|
|
1393
1314
|
*
|
|
1315
|
+
* When doing an exact calculation:
|
|
1316
|
+
* - do not reduce rational numbers to decimal (floating point approximation)
|
|
1317
|
+
* - do not down convert bignums to machine numbers
|
|
1318
|
+
* - do not reduce square roots of rational numbers
|
|
1319
|
+
* - do not reduce constants with a `hold` attribute
|
|
1394
1320
|
*
|
|
1321
|
+
* If the expression cannot be evaluated, due to the values, domains, or
|
|
1322
|
+
* assumptions about its arguments, for example, return `undefined` or
|
|
1323
|
+
* an `["Error"]` expression.
|
|
1395
1324
|
*/
|
|
1396
|
-
evaluate?:
|
|
1325
|
+
evaluate?: SemiBoxedExpression | ((ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined);
|
|
1397
1326
|
/**
|
|
1398
|
-
* Evaluate numerically
|
|
1327
|
+
* Evaluate numerically a function expression.
|
|
1399
1328
|
*
|
|
1400
1329
|
* The arguments `args` have been simplified and evaluated, numerically
|
|
1401
1330
|
* if possible, except the arguments to which a `hold` apply.
|
|
@@ -1414,19 +1343,22 @@ export declare type FunctionSignature = {
|
|
|
1414
1343
|
* evaluation, but a literal argument is out of range or
|
|
1415
1344
|
* not of the expected type.
|
|
1416
1345
|
*
|
|
1417
|
-
*
|
|
1418
|
-
*
|
|
1419
|
-
*
|
|
1346
|
+
* Note that regardless of the current value of `ce.numericMode`, the
|
|
1347
|
+
* arguments may be boxed numbers representing machine numbers, bignum
|
|
1348
|
+
* numbers, complex numbers, rationals or big rationals.
|
|
1420
1349
|
*
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
* value, return `NaN`. If Complex are not allowed, none of the arguments
|
|
1424
|
-
* will be complex literals.
|
|
1350
|
+
* Use the value of `ce.numericMode` to determine how to perform
|
|
1351
|
+
* the numeric evaluation.
|
|
1425
1352
|
*
|
|
1426
|
-
* If the
|
|
1427
|
-
* `
|
|
1428
|
-
*
|
|
1429
|
-
*
|
|
1353
|
+
* If the numeric mode does not allow complex numbers (the
|
|
1354
|
+
* `engine.numericMode` is not `"complex"` or `"auto"`) and the result of
|
|
1355
|
+
* the evaluation would be a complex number, return `NaN` instead.
|
|
1356
|
+
*
|
|
1357
|
+
* If `ce.numericMode` is `"bignum"` or `"auto"` the evaluation should be done
|
|
1358
|
+
* using bignums.
|
|
1359
|
+
*
|
|
1360
|
+
* Otherwise, `ce.numericMode` is `"machine", the evaluation should be
|
|
1361
|
+
* performed using machine numbers.
|
|
1430
1362
|
*
|
|
1431
1363
|
* You may perform any necessary computations, including approximate
|
|
1432
1364
|
* calculations on floating point numbers.
|
|
@@ -1437,17 +1369,17 @@ export declare type FunctionSignature = {
|
|
|
1437
1369
|
* @experimental
|
|
1438
1370
|
*/
|
|
1439
1371
|
evalDimension?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression;
|
|
1440
|
-
/** Return the sign of the function
|
|
1372
|
+
/** Return the sign of the function expression. */
|
|
1441
1373
|
sgn?: (ce: IComputeEngine, args: BoxedExpression[]) => -1 | 0 | 1 | undefined;
|
|
1442
1374
|
/** Return a compiled (optimized) expression. */
|
|
1443
1375
|
compile?: (expr: BoxedExpression) => CompiledExpression;
|
|
1444
1376
|
};
|
|
1445
1377
|
export declare type BoxedFunctionSignature = {
|
|
1446
1378
|
domain: BoxedDomain;
|
|
1447
|
-
codomain?: BoxedDomain | ((ce: IComputeEngine, args:
|
|
1448
|
-
canonical?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression;
|
|
1379
|
+
codomain?: BoxedDomain | ((ce: IComputeEngine, args: BoxedExpression[]) => BoxedDomain | null);
|
|
1380
|
+
canonical?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | null;
|
|
1449
1381
|
simplify?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
|
|
1450
|
-
evaluate?:
|
|
1382
|
+
evaluate?: BoxedExpression | ((ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined);
|
|
1451
1383
|
N?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
|
|
1452
1384
|
evalDimension?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression;
|
|
1453
1385
|
sgn?: (ce: IComputeEngine, args: BoxedExpression[]) => -1 | 0 | 1 | undefined;
|
|
@@ -1584,8 +1516,6 @@ export interface IComputeEngine {
|
|
|
1584
1516
|
/** @internal */
|
|
1585
1517
|
readonly _ONE: BoxedExpression;
|
|
1586
1518
|
/** @internal */
|
|
1587
|
-
readonly _TWO: BoxedExpression;
|
|
1588
|
-
/** @internal */
|
|
1589
1519
|
readonly _HALF: BoxedExpression;
|
|
1590
1520
|
/** @internal */
|
|
1591
1521
|
readonly _NEGATIVE_ONE: BoxedExpression;
|
|
@@ -1600,19 +1530,19 @@ export interface IComputeEngine {
|
|
|
1600
1530
|
/** @internal */
|
|
1601
1531
|
readonly _COMPLEX_INFINITY: BoxedExpression;
|
|
1602
1532
|
/** @internal */
|
|
1603
|
-
readonly
|
|
1533
|
+
readonly _BIGNUM_NAN: Decimal;
|
|
1604
1534
|
/** @internal */
|
|
1605
|
-
readonly
|
|
1535
|
+
readonly _BIGNUM_ZERO: Decimal;
|
|
1606
1536
|
/** @internal */
|
|
1607
|
-
readonly
|
|
1537
|
+
readonly _BIGNUM_ONE: Decimal;
|
|
1608
1538
|
/** @internal */
|
|
1609
|
-
readonly
|
|
1539
|
+
readonly _BIGNUM_TWO: Decimal;
|
|
1610
1540
|
/** @internal */
|
|
1611
|
-
readonly
|
|
1541
|
+
readonly _BIGNUM_HALF: Decimal;
|
|
1612
1542
|
/** @internal */
|
|
1613
|
-
readonly
|
|
1543
|
+
readonly _BIGNUM_PI: Decimal;
|
|
1614
1544
|
/** @internal */
|
|
1615
|
-
readonly
|
|
1545
|
+
readonly _BIGNUM_NEGATIVE_ONE: Decimal;
|
|
1616
1546
|
/** The current scope */
|
|
1617
1547
|
context: RuntimeScope | null;
|
|
1618
1548
|
/** Absolute time beyond which evaluation should not proceed
|
|
@@ -1634,7 +1564,7 @@ export interface IComputeEngine {
|
|
|
1634
1564
|
chop(n: Complex): Complex | 0;
|
|
1635
1565
|
chop(n: number | Decimal | Complex): number | Decimal | Complex;
|
|
1636
1566
|
/** @internal */
|
|
1637
|
-
|
|
1567
|
+
bignum: (a: Decimal.Value) => Decimal;
|
|
1638
1568
|
/** @internal */
|
|
1639
1569
|
complex: (a: number | Complex, b?: number) => Complex;
|
|
1640
1570
|
set precision(p: number | 'machine');
|
|
@@ -1654,17 +1584,23 @@ export interface IComputeEngine {
|
|
|
1654
1584
|
defineFunction(def: FunctionDefinition): BoxedFunctionDefinition;
|
|
1655
1585
|
lookupSymbol(name: string, wikidata?: string, scope?: RuntimeScope): undefined | BoxedSymbolDefinition;
|
|
1656
1586
|
/** Return `undefined` if no definition exist for this `head` */
|
|
1657
|
-
lookupFunction(head: string, scope?: RuntimeScope): undefined | BoxedFunctionDefinition;
|
|
1587
|
+
lookupFunction(head: string | BoxedExpression, scope?: RuntimeScope | null): undefined | BoxedFunctionDefinition;
|
|
1658
1588
|
/**
|
|
1659
1589
|
* Return a boxed expression from the input.
|
|
1660
|
-
*
|
|
1661
|
-
* The result may not be canonical.
|
|
1662
1590
|
*/
|
|
1663
|
-
box(expr: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression
|
|
1664
|
-
|
|
1665
|
-
|
|
1591
|
+
box(expr: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression, options?: {
|
|
1592
|
+
canonical?: boolean;
|
|
1593
|
+
}): BoxedExpression;
|
|
1594
|
+
/** Return a boxed number */
|
|
1595
|
+
number(value: number | string | MathJsonNumber | Decimal | Complex | [num: number, denom: number] | [num: Decimal, denom: Decimal], options?: {
|
|
1596
|
+
metadata?: Metadata;
|
|
1597
|
+
canonical?: boolean;
|
|
1598
|
+
}): BoxedExpression;
|
|
1666
1599
|
/** Return a canonical boxed symbol */
|
|
1667
|
-
symbol(sym: string,
|
|
1600
|
+
symbol(sym: string, options?: {
|
|
1601
|
+
metadata?: Metadata;
|
|
1602
|
+
canonical?: boolean;
|
|
1603
|
+
}): BoxedExpression;
|
|
1668
1604
|
/** Return a canonical boxed string */
|
|
1669
1605
|
string(s: string, metadata?: Metadata): BoxedExpression;
|
|
1670
1606
|
/** Return a canonical boxed domain.
|
|
@@ -1673,8 +1609,6 @@ export interface IComputeEngine {
|
|
|
1673
1609
|
*
|
|
1674
1610
|
*/
|
|
1675
1611
|
domain(domain: SemiBoxedExpression | BoxedDomain | string, metadata?: Metadata): BoxedDomain;
|
|
1676
|
-
/** Return a canonical lambda expression */
|
|
1677
|
-
lambda(expr: SemiBoxedExpression, sig: BoxedDomain): BoxedLambdaExpression;
|
|
1678
1612
|
/**
|
|
1679
1613
|
* Return a canonical expression.
|
|
1680
1614
|
*
|
|
@@ -1690,7 +1624,7 @@ export interface IComputeEngine {
|
|
|
1690
1624
|
* This is a primitive to create a boxed function. It doesn't perform
|
|
1691
1625
|
* any checks or normalization on its arguments.
|
|
1692
1626
|
*
|
|
1693
|
-
* In general, consider using `fn()` or `box()` instead.
|
|
1627
|
+
* In general, consider using `ce.fn()` or `ce.box()` instead.
|
|
1694
1628
|
*
|
|
1695
1629
|
* The result is canonical, but the caller has to ensure that all the
|
|
1696
1630
|
* conditions are met (i.e. `ops` properly normalized and sorted, all
|
|
@@ -1702,6 +1636,10 @@ export interface IComputeEngine {
|
|
|
1702
1636
|
* The result is canonical.
|
|
1703
1637
|
*/
|
|
1704
1638
|
error(message: string | [string, ...SemiBoxedExpression[]], where?: SemiBoxedExpression): BoxedExpression;
|
|
1639
|
+
/**
|
|
1640
|
+
* Add a`["Hold"]` wrapper to `expr.
|
|
1641
|
+
*/
|
|
1642
|
+
hold(expr: SemiBoxedExpression): BoxedExpression;
|
|
1705
1643
|
/** Shortcut for `this.fn("Add"...)`.
|
|
1706
1644
|
*
|
|
1707
1645
|
* The result is canonical.
|
|
@@ -1716,7 +1654,8 @@ export interface IComputeEngine {
|
|
|
1716
1654
|
*
|
|
1717
1655
|
* The result is canonical.
|
|
1718
1656
|
*/
|
|
1719
|
-
power(base: BoxedExpression, exponent: number |
|
|
1657
|
+
power(base: BoxedExpression, exponent: number | Rational | BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
1658
|
+
sqrt(base: BoxedExpression, metadata?: Metadata): any;
|
|
1720
1659
|
/** Shortcut for `this.fn("Divide", [1, expr])`
|
|
1721
1660
|
*
|
|
1722
1661
|
* The result is canonical.
|
|
@@ -1750,9 +1689,15 @@ export interface IComputeEngine {
|
|
|
1750
1689
|
* The result may not be canonical.
|
|
1751
1690
|
*
|
|
1752
1691
|
*/
|
|
1753
|
-
parse(s: LatexString | string
|
|
1754
|
-
|
|
1755
|
-
|
|
1692
|
+
parse(s: LatexString | string, options?: {
|
|
1693
|
+
canonical?: boolean;
|
|
1694
|
+
}): BoxedExpression;
|
|
1695
|
+
parse(s: null, options?: {
|
|
1696
|
+
canonical?: boolean;
|
|
1697
|
+
}): null;
|
|
1698
|
+
parse(s: LatexString | string | null, options?: {
|
|
1699
|
+
canonical?: boolean;
|
|
1700
|
+
}): null | BoxedExpression;
|
|
1756
1701
|
/** Serialize a `BoxedExpression` or a `MathJSON` expression to
|
|
1757
1702
|
* a LaTeX string
|
|
1758
1703
|
*/
|
|
@@ -1770,8 +1715,22 @@ export interface IComputeEngine {
|
|
|
1770
1715
|
get latexOptions(): NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions;
|
|
1771
1716
|
set latexOptions(opts: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions> & Partial<SerializeLatexOptions>);
|
|
1772
1717
|
/** {@inheritDoc JsonSerializationOptions} */
|
|
1773
|
-
get jsonSerializationOptions(): JsonSerializationOptions
|
|
1718
|
+
get jsonSerializationOptions(): Readonly<JsonSerializationOptions>;
|
|
1774
1719
|
set jsonSerializationOptions(val: Partial<JsonSerializationOptions>);
|
|
1720
|
+
pushScope(options?: {
|
|
1721
|
+
symbolTable?: Readonly<SymbolTable> | Readonly<SymbolTable>[];
|
|
1722
|
+
assumptions?: (LatexString | Expression | BoxedExpression)[];
|
|
1723
|
+
scope?: Partial<Scope>;
|
|
1724
|
+
}): void;
|
|
1725
|
+
popScope(): void;
|
|
1726
|
+
/** Assign a value to an identifier in the current scope */
|
|
1727
|
+
set(identifiers: {
|
|
1728
|
+
[identifier: string]: SemiBoxedExpression;
|
|
1729
|
+
}): void;
|
|
1730
|
+
/** Declare identifiers (specify their domain without necessarily assigning them a value in the current scope*/
|
|
1731
|
+
let(identifiers: {
|
|
1732
|
+
[identifier: string]: SymbolDefinition | FunctionDefinition;
|
|
1733
|
+
}): void;
|
|
1775
1734
|
/**
|
|
1776
1735
|
* Add an assumption.
|
|
1777
1736
|
*
|
|
@@ -1793,13 +1752,7 @@ export interface IComputeEngine {
|
|
|
1793
1752
|
/** Remove all assumptions about one or more symbols */
|
|
1794
1753
|
forget(symbol?: string | string[]): void;
|
|
1795
1754
|
get assumptions(): ExpressionMapInterface<boolean>;
|
|
1796
|
-
ask(pattern: LatexString | SemiBoxedExpression):
|
|
1797
|
-
pushScope(options?: {
|
|
1798
|
-
symbolTable?: Readonly<SymbolTable> | Readonly<SymbolTable>[];
|
|
1799
|
-
assumptions?: (LatexString | Expression | BoxedExpression)[];
|
|
1800
|
-
scope?: Partial<Scope>;
|
|
1801
|
-
}): void;
|
|
1802
|
-
popScope(): void;
|
|
1755
|
+
ask(pattern: LatexString | SemiBoxedExpression): BoxedSubstitution[];
|
|
1803
1756
|
/**
|
|
1804
1757
|
* When `condition` is false, signal.
|
|
1805
1758
|
*
|