@cortex-js/compute-engine 0.16.0 → 0.17.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 +1 -1
- package/dist/compute-engine.esm.js +3776 -3823
- package/dist/compute-engine.js +3776 -3823
- package/dist/compute-engine.min.esm.js +47 -27363
- package/dist/compute-engine.min.js +19 -27346
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -281
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +7 -8
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +7 -7
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +13 -25
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +6 -6
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +4 -3
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +11 -11
- 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 +2 -2
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +32 -12
- package/dist/types/compute-engine/compile.d.ts +18 -2
- package/dist/types/compute-engine/compute-engine.d.ts +28 -38
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +4 -6
- package/dist/types/compute-engine/function-utils.d.ts +41 -1
- 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-complex.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-statistics.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-identifier.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/public.d.ts +22 -18
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +2 -2
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +2 -2
- 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/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +3 -2
- package/dist/types/compute-engine/library/library.d.ts +4 -2
- package/dist/types/compute-engine/library/linear-algebra.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/random-expression.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/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -3
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +2 -2
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +91 -113
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +16 -2
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -2
- 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 +1 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +5 -3
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +4 -3
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +3 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare const DOMAIN_CONSTRUCTORS: string[];
|
|
3
3
|
export declare const DOMAIN_ALIAS: {
|
|
4
|
+
Functions: (string | string[])[];
|
|
4
5
|
NumericFunctions: (string | string[])[];
|
|
5
6
|
RealFunctions: (string | string[])[];
|
|
6
7
|
LogicOperators: (string | string[])[];
|
|
@@ -11,5 +12,5 @@ export declare function isDomainLiteral(s: string | null): s is DomainLiteral;
|
|
|
11
12
|
export declare function isSubdomainLiteral(lhs: string, rhs: string): boolean;
|
|
12
13
|
/** Return all the domain literals that are an ancestor of `dom`
|
|
13
14
|
*/
|
|
14
|
-
export declare function ancestors(dom:
|
|
15
|
+
export declare function ancestors(dom: DomainLiteral): DomainLiteral[];
|
|
15
16
|
export declare function domainSetsLibrary(): IdentifierDefinitions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import { IComputeEngine, IdentifierDefinitions } from '../public';
|
|
1
|
+
/* 0.17.0 */
|
|
2
|
+
import { FunctionDefinition, IComputeEngine, IdentifierDefinitions, SymbolDefinition } from '../public';
|
|
3
3
|
export declare function getStandardLibrary(categories: LibraryCategory[] | LibraryCategory | 'all'): readonly IdentifierDefinitions[];
|
|
4
4
|
export declare const LIBRARIES: {
|
|
5
5
|
[category in LibraryCategory]?: IdentifierDefinitions | IdentifierDefinitions[];
|
|
@@ -15,3 +15,5 @@ export declare const LIBRARIES: {
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
export declare function setIdentifierDefinitions(engine: IComputeEngine, table: IdentifierDefinitions): void;
|
|
18
|
+
export declare function isSymbolDefinition(def: any): def is SymbolDefinition;
|
|
19
|
+
export declare function isFunctionDefinition(def: any): def is FunctionDefinition;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare const LINEAR_ALGEBRA_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare const LOGIC_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare const POLYNOMIALS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare function randomExpression(level?: number): Expression;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare const RELOP_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare const SETS_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare const STATISTICS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare const TRIGONOMETRY_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
export declare function isSymbolDefinition(def: any): def is SymbolDefinition;
|
|
3
|
-
export declare function isFunctionDefinition(def: any): def is FunctionDefinition;
|
|
1
|
+
/* 0.17.0 */
|
|
4
2
|
export declare function normalizeLimits(range: BoxedExpression): [index: string, lower: number, upper: number, isFinite: boolean];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare function isPrime(n: number): boolean | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
* The most important classes are {@link ComputeEngine} and
|
|
3
3
|
* {@link BoxedExpression}.
|
|
4
4
|
*
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module ComputeEngine
|
|
9
9
|
*/
|
|
10
|
-
import type { Decimal } from 'decimal.js';
|
|
11
10
|
import type { Complex } from 'complex.js';
|
|
11
|
+
import type { Decimal } from 'decimal.js';
|
|
12
12
|
import type { Expression, MathJsonDictionary, MathJsonFunction, MathJsonNumber, MathJsonString, MathJsonSymbol } from '../math-json/math-json-format';
|
|
13
13
|
import type { LatexDictionaryEntry, NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
|
|
14
14
|
export * from './latex-syntax/public';
|
|
@@ -35,6 +35,7 @@ export type Metadata = {
|
|
|
35
35
|
</div>
|
|
36
36
|
*/
|
|
37
37
|
export type NumericMode = 'auto' | 'machine' | 'bignum' | 'complex';
|
|
38
|
+
export type Hold = 'none' | 'all' | 'first' | 'rest' | 'last' | 'most';
|
|
38
39
|
/** Options for `BoxedExpression.simplify()` */
|
|
39
40
|
export type SimplifyOptions = {
|
|
40
41
|
recursive?: boolean;
|
|
@@ -42,9 +43,10 @@ export type SimplifyOptions = {
|
|
|
42
43
|
};
|
|
43
44
|
/** Options for `BoxedExpression.evaluate()`
|
|
44
45
|
*
|
|
45
|
-
* @internal
|
|
46
46
|
*/
|
|
47
|
-
export type EvaluateOptions = {
|
|
47
|
+
export type EvaluateOptions = {
|
|
48
|
+
numericMode?: boolean;
|
|
49
|
+
};
|
|
48
50
|
/** Options for `BoxedExpression.N()`
|
|
49
51
|
* @internal
|
|
50
52
|
*/
|
|
@@ -126,50 +128,24 @@ export type BoxedRule = [
|
|
|
126
128
|
export type BoxedRuleSet = Set<BoxedRule>;
|
|
127
129
|
export type DomainCompatibility = 'covariant' | 'contravariant' | 'bivariant' | 'invariant';
|
|
128
130
|
/** A domain constructor is the head of a domain expression. */
|
|
129
|
-
export type DomainConstructor = '
|
|
130
|
-
export type DomainLiteral =
|
|
131
|
-
export type DomainExpression<T = SemiBoxedExpression> = DomainLiteral | ['
|
|
131
|
+
export type DomainConstructor = 'FunctionOf' | 'ListOf' | 'DictionaryOf' | 'TupleOf' | 'Intersection' | 'Union' | 'OptArg' | 'VarArg' | 'Covariant' | 'Contravariant' | 'Bivariant' | 'Invariant';
|
|
132
|
+
export type DomainLiteral = 'Anything' | 'Values' | 'Domains' | 'Void' | 'NothingDomain' | 'Booleans' | 'Strings' | 'Symbols' | 'Collections' | 'Lists' | 'Dictionaries' | 'Sequences' | 'Tuples' | 'Sets' | 'Functions' | 'Predicates' | 'LogicOperators' | 'RelationalOperators' | 'NumericFunctions' | 'RealFunctions' | 'Numbers' | 'ComplexNumbers' | 'ExtendedRealNumbers' | 'ImaginaryNumbers' | 'Integers' | 'Rationals' | 'PositiveNumbers' | 'PositiveIntegers' | 'NegativeNumbers' | 'NegativeIntegers' | 'NonNegativeNumbers' | 'NonNegativeIntegers' | 'NonPositiveNumbers' | 'NonPositiveIntegers' | 'ExtendedComplexNumbers' | 'TranscendentalNumbers' | 'AlgebraicNumbers' | 'RationalNumbers' | 'RealNumbers';
|
|
133
|
+
export type DomainExpression<T = SemiBoxedExpression> = DomainLiteral | ['Union', ...(DomainExpression<T> | BoxedExpression)[]] | ['Intersection', ...(DomainExpression<T> | BoxedExpression)[]] | ['ListOf', DomainExpression<T>] | ['DictionaryOf', DomainExpression<T>] | ['TupleOf', ...DomainExpression<T>[]] | ['OptArg', ...DomainExpression<T>[]] | ['VarArg', DomainExpression<T>] | ['Covariant', DomainExpression<T>] | ['Contravariant', DomainExpression<T>] | ['Bivariant', DomainExpression<T>] | ['Invariant', DomainExpression<T>] | ['FunctionOf', ...DomainExpression<T>[]];
|
|
132
134
|
export interface BoxedDomain extends BoxedExpression {
|
|
133
|
-
|
|
135
|
+
get canonical(): BoxedDomain;
|
|
136
|
+
get json(): Expression;
|
|
134
137
|
/** True if a valid domain, and compatible with `dom`
|
|
135
|
-
* kind is 'covariant' by default, i.e. `this <: dom`
|
|
138
|
+
* `kind` is '"covariant"' by default, i.e. `this <: dom`
|
|
136
139
|
*/
|
|
137
140
|
isCompatible(dom: BoxedDomain | DomainLiteral, kind?: DomainCompatibility): boolean;
|
|
138
|
-
get
|
|
141
|
+
get base(): DomainLiteral;
|
|
139
142
|
get ctor(): DomainConstructor | null;
|
|
140
|
-
get
|
|
141
|
-
get
|
|
142
|
-
get
|
|
143
|
-
get
|
|
144
|
-
readonly isNothing: boolean;
|
|
143
|
+
get params(): BoxedDomain[];
|
|
144
|
+
get optParams(): BoxedDomain[];
|
|
145
|
+
get restParam(): BoxedDomain | null;
|
|
146
|
+
get result(): BoxedDomain | null;
|
|
145
147
|
readonly isNumeric: boolean;
|
|
146
148
|
readonly isFunction: boolean;
|
|
147
|
-
/**
|
|
148
|
-
* If true, when all the arguments are numeric, the result of the
|
|
149
|
-
* evaluation is numeric. Numeric is any value with a domain of `Number`.
|
|
150
|
-
*
|
|
151
|
-
* Example of numeric functions: `Add`, `Multiply`, `Power`, `Abs`
|
|
152
|
-
*
|
|
153
|
-
* Default: `false`
|
|
154
|
-
*/
|
|
155
|
-
/**
|
|
156
|
-
* If true, when all the arguments are boolean, the result of the
|
|
157
|
-
* evaluation is a boolean. Boolean is any value with a domain of `MaybeBoolean`.
|
|
158
|
-
*
|
|
159
|
-
* Example of logic functions: `And`, `Or`, `Not`, `Implies`
|
|
160
|
-
*
|
|
161
|
-
* **Default:** `false`
|
|
162
|
-
*/
|
|
163
|
-
/**
|
|
164
|
-
* The function represent a relation between the first argument and
|
|
165
|
-
* the second argument, and evaluates to a boolean indicating if the relation
|
|
166
|
-
* is satisfied.
|
|
167
|
-
*
|
|
168
|
-
* For example, `Equal`, `Less`, `Approx`, etc...
|
|
169
|
-
*
|
|
170
|
-
* **Default:** `false`
|
|
171
|
-
*/
|
|
172
|
-
readonly isRelationalOperator: boolean;
|
|
173
149
|
}
|
|
174
150
|
/**
|
|
175
151
|
* Options to control the serialization to MathJSON when using `BoxedExpression.json`.
|
|
@@ -495,21 +471,6 @@ export interface BoxedExpression {
|
|
|
495
471
|
*
|
|
496
472
|
*/
|
|
497
473
|
get canonical(): BoxedExpression;
|
|
498
|
-
/**
|
|
499
|
-
* If this expression is a function, apply the function `fn` to all its operands.
|
|
500
|
-
*
|
|
501
|
-
* Replace the head of this expression with `head`, if defined.
|
|
502
|
-
*
|
|
503
|
-
* If this expression is a dictionary, return a new dictionary with the values
|
|
504
|
-
* modified by `fn`.
|
|
505
|
-
*
|
|
506
|
-
* If `head` is provided, return a function expression with the modified
|
|
507
|
-
* dictionary as operand, otherwise return the modified dictionary.
|
|
508
|
-
*
|
|
509
|
-
* **Note** applicable to canonical and non-canonical expressions.
|
|
510
|
-
*
|
|
511
|
-
* */
|
|
512
|
-
apply(fn: (x: BoxedExpression) => SemiBoxedExpression, head?: string): BoxedExpression;
|
|
513
474
|
/**
|
|
514
475
|
* Replace all the symbols in the expression as indicated.
|
|
515
476
|
*
|
|
@@ -787,29 +748,28 @@ export interface BoxedExpression {
|
|
|
787
748
|
*
|
|
788
749
|
* If the domain was not set, set it to the inferred domain, return `true`
|
|
789
750
|
* If the domain was previously inferred, adjust it by widening it,
|
|
790
|
-
* return `true
|
|
751
|
+
* return `true`
|
|
791
752
|
*
|
|
792
753
|
* @internal
|
|
793
754
|
*/
|
|
794
755
|
infer(domain: BoxedDomain): boolean;
|
|
795
756
|
/**
|
|
796
|
-
* Update the definition associated with this expression,
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
* If no scope is specified, the scope of when the expression was boxed is used.
|
|
800
|
-
*
|
|
801
|
-
* If the scope is `null`, the definition is removed.
|
|
802
|
-
*
|
|
803
|
-
* **Note**: applicable only to canonical expressions
|
|
757
|
+
* Update the definition associated with this expression, using the
|
|
758
|
+
* current scope (`ce.context`).
|
|
804
759
|
*
|
|
805
760
|
* @internal
|
|
806
761
|
*/
|
|
807
|
-
bind(
|
|
762
|
+
bind(): void;
|
|
808
763
|
/**
|
|
764
|
+
*
|
|
765
|
+
* Reset the cached value associated with this expression.
|
|
766
|
+
*
|
|
767
|
+
* Use when the environment has changed, for example the numeric mode
|
|
768
|
+
* or precision, to force the expression to be re-evaluated.
|
|
809
769
|
*
|
|
810
770
|
* @internal
|
|
811
771
|
*/
|
|
812
|
-
|
|
772
|
+
reset(): void;
|
|
813
773
|
/**
|
|
814
774
|
* Return a simpler form of the canonical form of this expression.
|
|
815
775
|
*
|
|
@@ -897,25 +857,28 @@ export interface BoxedExpression {
|
|
|
897
857
|
*
|
|
898
858
|
*/
|
|
899
859
|
set value(value: BoxedExpression | number | undefined);
|
|
900
|
-
/**
|
|
860
|
+
/**
|
|
861
|
+
*
|
|
862
|
+
* The domain of the value of this expression.
|
|
901
863
|
*
|
|
902
|
-
* If a function expression, the domain of the value of the function
|
|
864
|
+
* If a function expression, the domain of the value of the function
|
|
865
|
+
* (the codomain of the function).
|
|
903
866
|
*
|
|
904
867
|
* If a symbol the domain of the value of the symbol.
|
|
905
868
|
*
|
|
906
|
-
* Use `expr.head` to determine if an expression is a symbol or function
|
|
869
|
+
* Use `expr.head` to determine if an expression is a symbol or function
|
|
870
|
+
* expression.
|
|
871
|
+
*
|
|
872
|
+
* **Note**: if non-canonical or not valid, return `undefined`.
|
|
907
873
|
*
|
|
908
|
-
* **Note**: If non-canonical, return the domain of its canonical
|
|
909
|
-
* counterpart
|
|
910
874
|
*/
|
|
911
|
-
get domain(): BoxedDomain;
|
|
912
|
-
/** Modify the domain of a symbol
|
|
913
|
-
* (or a function name).
|
|
875
|
+
get domain(): BoxedDomain | undefined;
|
|
876
|
+
/** Modify the domain of a symbol.
|
|
914
877
|
*
|
|
915
878
|
* **Note**: If non-canonical, does nothing.
|
|
916
879
|
*
|
|
917
880
|
*/
|
|
918
|
-
set domain(domain:
|
|
881
|
+
set domain(domain: DomainExpression | BoxedDomain | undefined);
|
|
919
882
|
/** `true` if the value of this expression is a number.
|
|
920
883
|
*
|
|
921
884
|
* `isExtendedComplex || isNaN` = `isReal || isImaginary || isInfinity || isNaN`
|
|
@@ -1235,7 +1198,7 @@ export type FunctionSignature = {
|
|
|
1235
1198
|
/** An optional handler to determine the codomain of the function.
|
|
1236
1199
|
* If not provided, the codomain of the function is determined from `domain`
|
|
1237
1200
|
*/
|
|
1238
|
-
codomain?: (ce: IComputeEngine, args: BoxedDomain[]) => BoxedDomain | null;
|
|
1201
|
+
codomain?: (ce: IComputeEngine, args: BoxedDomain[]) => BoxedDomain | null | undefined;
|
|
1239
1202
|
/**
|
|
1240
1203
|
* Return the canonical form of the expression with the arguments `args`.
|
|
1241
1204
|
*
|
|
@@ -1243,11 +1206,14 @@ export type FunctionSignature = {
|
|
|
1243
1206
|
* can be put in canonical form.
|
|
1244
1207
|
*
|
|
1245
1208
|
* This handler should validate the domain and number of the arguments.
|
|
1209
|
+
*
|
|
1246
1210
|
* If a required argument is missing, it should be indicated with a
|
|
1247
1211
|
* `["Error", "'missing"]` expression. If more arguments than expected
|
|
1248
|
-
* are present, this should be indicated with
|
|
1212
|
+
* are present, this should be indicated with an
|
|
1213
|
+
* ["Error", "'unexpected-argument'"]` error expression
|
|
1214
|
+
*
|
|
1249
1215
|
* If the domain of an argument is not compatible, it should be indicated
|
|
1250
|
-
* with
|
|
1216
|
+
* with an `incompatible-domain` error.
|
|
1251
1217
|
*
|
|
1252
1218
|
* `["Sequence"]` expressions are not folded and need to be handled
|
|
1253
1219
|
* explicitly.
|
|
@@ -1257,8 +1223,8 @@ export type FunctionSignature = {
|
|
|
1257
1223
|
* arguments should be sorted in canonical order.
|
|
1258
1224
|
*
|
|
1259
1225
|
* The handler can make transformations based on the value of the arguments
|
|
1260
|
-
* that are exact and literal
|
|
1261
|
-
*
|
|
1226
|
+
* that are exact and literal (i.e.
|
|
1227
|
+
* `arg.numericValue !== null && arg.isExact`).
|
|
1262
1228
|
*
|
|
1263
1229
|
* Values of symbols should not be substituted, unless they have
|
|
1264
1230
|
* a `holdUntil` attribute of `"never"`.
|
|
@@ -1380,7 +1346,7 @@ export type FunctionSignature = {
|
|
|
1380
1346
|
};
|
|
1381
1347
|
export type BoxedFunctionSignature = {
|
|
1382
1348
|
domain: BoxedDomain;
|
|
1383
|
-
codomain?: BoxedDomain | ((ce: IComputeEngine, args: BoxedExpression[]) => BoxedDomain | null);
|
|
1349
|
+
codomain?: BoxedDomain | ((ce: IComputeEngine, args: BoxedExpression[]) => BoxedDomain | null | undefined);
|
|
1384
1350
|
canonical?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | null;
|
|
1385
1351
|
simplify?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
|
|
1386
1352
|
evaluate?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
|
|
@@ -1476,12 +1442,12 @@ export type FunctionDefinition = BaseDefinition & Partial<CollectionHandlers> &
|
|
|
1476
1442
|
*
|
|
1477
1443
|
* **Default**: `"none"`
|
|
1478
1444
|
*/
|
|
1479
|
-
hold?:
|
|
1445
|
+
hold?: Hold;
|
|
1480
1446
|
signature: FunctionSignature;
|
|
1481
1447
|
};
|
|
1482
1448
|
export type BoxedFunctionDefinition = BoxedBaseDefinition & Partial<CollectionHandlers> & FunctionDefinitionFlags & {
|
|
1483
1449
|
complexity: number;
|
|
1484
|
-
hold:
|
|
1450
|
+
hold: Hold;
|
|
1485
1451
|
signature: BoxedFunctionSignature;
|
|
1486
1452
|
};
|
|
1487
1453
|
/**
|
|
@@ -1493,7 +1459,7 @@ export type BoxedFunctionDefinition = BoxedBaseDefinition & Partial<CollectionHa
|
|
|
1493
1459
|
* For example, it might be useful to override `algebraic = false`
|
|
1494
1460
|
* for a transcendental number.
|
|
1495
1461
|
*/
|
|
1496
|
-
export type
|
|
1462
|
+
export type NumericFlags = {
|
|
1497
1463
|
number: boolean | undefined;
|
|
1498
1464
|
integer: boolean | undefined;
|
|
1499
1465
|
rational: boolean | undefined;
|
|
@@ -1559,7 +1525,7 @@ export type SymbolAttributes = {
|
|
|
1559
1525
|
* (e.g. ∀ x ∈ ℝ), a value (x = 5) or both (π: value = 3.14... domain = TranscendentalNumbers)
|
|
1560
1526
|
*/
|
|
1561
1527
|
export type SymbolDefinition = BaseDefinition & Partial<SymbolAttributes> & {
|
|
1562
|
-
domain?:
|
|
1528
|
+
domain?: DomainLiteral | BoxedDomain;
|
|
1563
1529
|
/** If true, the domain is inferred, and could be adjusted later
|
|
1564
1530
|
* as more information becomes available or if the symbol is explicitly
|
|
1565
1531
|
* declared.
|
|
@@ -1569,9 +1535,9 @@ export type SymbolDefinition = BaseDefinition & Partial<SymbolAttributes> & {
|
|
|
1569
1535
|
* `Pi`, the actual value depends on the `precision` setting of the
|
|
1570
1536
|
* `ComputeEngine` and possible other environment settings */
|
|
1571
1537
|
value?: LatexString | SemiBoxedExpression | ((ce: IComputeEngine) => SemiBoxedExpression | null);
|
|
1572
|
-
flags?: Partial<
|
|
1538
|
+
flags?: Partial<NumericFlags>;
|
|
1573
1539
|
};
|
|
1574
|
-
export interface BoxedSymbolDefinition extends BoxedBaseDefinition, SymbolAttributes, Partial<
|
|
1540
|
+
export interface BoxedSymbolDefinition extends BoxedBaseDefinition, SymbolAttributes, Partial<NumericFlags> {
|
|
1575
1541
|
get value(): BoxedExpression | undefined;
|
|
1576
1542
|
set value(val: SemiBoxedExpression | number | undefined);
|
|
1577
1543
|
domain: BoxedDomain | undefined;
|
|
@@ -1592,24 +1558,25 @@ export type AssignValue = boolean | number | string | Decimal | Complex | LatexS
|
|
|
1592
1558
|
/** @internal */
|
|
1593
1559
|
export interface IComputeEngine {
|
|
1594
1560
|
latexDictionary: readonly LatexDictionaryEntry[];
|
|
1595
|
-
|
|
1596
|
-
readonly
|
|
1597
|
-
|
|
1598
|
-
readonly
|
|
1599
|
-
|
|
1600
|
-
readonly
|
|
1601
|
-
|
|
1602
|
-
readonly
|
|
1603
|
-
|
|
1604
|
-
readonly
|
|
1605
|
-
|
|
1606
|
-
readonly
|
|
1607
|
-
|
|
1608
|
-
readonly
|
|
1609
|
-
|
|
1610
|
-
readonly
|
|
1611
|
-
|
|
1612
|
-
readonly
|
|
1561
|
+
readonly Anything: BoxedDomain;
|
|
1562
|
+
readonly Void: BoxedDomain;
|
|
1563
|
+
readonly Strings: BoxedDomain;
|
|
1564
|
+
readonly Booleans: BoxedDomain;
|
|
1565
|
+
readonly Numbers: BoxedDomain;
|
|
1566
|
+
readonly True: BoxedExpression;
|
|
1567
|
+
readonly False: BoxedExpression;
|
|
1568
|
+
readonly Pi: BoxedExpression;
|
|
1569
|
+
readonly E: BoxedExpression;
|
|
1570
|
+
readonly Nothing: BoxedExpression;
|
|
1571
|
+
readonly Zero: BoxedExpression;
|
|
1572
|
+
readonly One: BoxedExpression;
|
|
1573
|
+
readonly Half: BoxedExpression;
|
|
1574
|
+
readonly NegativeOne: BoxedExpression;
|
|
1575
|
+
readonly I: BoxedExpression;
|
|
1576
|
+
readonly NaN: BoxedExpression;
|
|
1577
|
+
readonly PositiveInfinity: BoxedExpression;
|
|
1578
|
+
readonly NegativeInfinity: BoxedExpression;
|
|
1579
|
+
readonly ComplexInfinity: BoxedExpression;
|
|
1613
1580
|
/** @internal */
|
|
1614
1581
|
readonly _BIGNUM_NAN: Decimal;
|
|
1615
1582
|
/** @internal */
|
|
@@ -1636,7 +1603,6 @@ export interface IComputeEngine {
|
|
|
1636
1603
|
readonly iterationLimit: number;
|
|
1637
1604
|
/** @experimental */
|
|
1638
1605
|
readonly recursionLimit: number;
|
|
1639
|
-
defaultDomain: null | BoxedDomain;
|
|
1640
1606
|
/** {@inheritDoc NumericMode} */
|
|
1641
1607
|
numericMode: NumericMode;
|
|
1642
1608
|
tolerance: number;
|
|
@@ -1802,7 +1768,7 @@ export interface IComputeEngine {
|
|
|
1802
1768
|
* If the domain is invalid, may return an `["Error"]` expression
|
|
1803
1769
|
*
|
|
1804
1770
|
*/
|
|
1805
|
-
domain(domain:
|
|
1771
|
+
domain(domain: BoxedDomain | DomainExpression, metadata?: Metadata): BoxedDomain;
|
|
1806
1772
|
/**
|
|
1807
1773
|
* Return a canonical expression.
|
|
1808
1774
|
*
|
|
@@ -1832,6 +1798,7 @@ export interface IComputeEngine {
|
|
|
1832
1798
|
* The result is canonical.
|
|
1833
1799
|
*/
|
|
1834
1800
|
error(message: string | [string, ...SemiBoxedExpression[]], where?: SemiBoxedExpression): BoxedExpression;
|
|
1801
|
+
domainError(expectedDomain: BoxedDomain | DomainLiteral, actualDomain: undefined | BoxedDomain, where?: SemiBoxedExpression): BoxedExpression;
|
|
1835
1802
|
/**
|
|
1836
1803
|
* Add a`["Hold"]` wrapper to `expr.
|
|
1837
1804
|
*/
|
|
@@ -1851,6 +1818,10 @@ export interface IComputeEngine {
|
|
|
1851
1818
|
* The result is canonical.
|
|
1852
1819
|
*/
|
|
1853
1820
|
pow(base: BoxedExpression, exponent: number | Rational | BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
1821
|
+
/** Shortcut for `this.fn("Sqrt"...)`
|
|
1822
|
+
*
|
|
1823
|
+
* The result is canonical.
|
|
1824
|
+
*/
|
|
1854
1825
|
sqrt(base: BoxedExpression, metadata?: Metadata): any;
|
|
1855
1826
|
/** Shortcut for `this.fn("Divide", [1, expr])`
|
|
1856
1827
|
*
|
|
@@ -1897,7 +1868,9 @@ export interface IComputeEngine {
|
|
|
1897
1868
|
/** Serialize a `BoxedExpression` or a `MathJSON` expression to
|
|
1898
1869
|
* a LaTeX string
|
|
1899
1870
|
*/
|
|
1900
|
-
serialize(expr: SemiBoxedExpression
|
|
1871
|
+
serialize(expr: SemiBoxedExpression, options?: {
|
|
1872
|
+
canonical?: boolean;
|
|
1873
|
+
}): LatexString;
|
|
1901
1874
|
/**
|
|
1902
1875
|
* Options to control the serialization of MathJSON expression to LaTeX
|
|
1903
1876
|
* when using `this.latex` or `this.engine.serialize()`.
|
|
@@ -1920,6 +1893,11 @@ export interface IComputeEngine {
|
|
|
1920
1893
|
popScope(): IComputeEngine;
|
|
1921
1894
|
/** Set the current scope, return the previous scope. */
|
|
1922
1895
|
swapScope(scope: RuntimeScope | null): RuntimeScope | null;
|
|
1896
|
+
/**
|
|
1897
|
+
* Reset the value of any identifiers that have been assigned a value
|
|
1898
|
+
* in the current scope.
|
|
1899
|
+
* @internal */
|
|
1900
|
+
resetContext(): void;
|
|
1923
1901
|
/** Assign a value to an identifier in the current scope.
|
|
1924
1902
|
* Use `undefined` to reset the identifier to no value.
|
|
1925
1903
|
*
|
|
@@ -1955,12 +1933,12 @@ export interface IComputeEngine {
|
|
|
1955
1933
|
*
|
|
1956
1934
|
*/
|
|
1957
1935
|
declare(identifiers: {
|
|
1958
|
-
[id: string]: DomainExpression | SymbolDefinition | FunctionDefinition;
|
|
1936
|
+
[id: string]: BoxedDomain | DomainExpression | SymbolDefinition | FunctionDefinition;
|
|
1959
1937
|
}): IComputeEngine;
|
|
1960
|
-
declare(id: string, def: DomainExpression | SymbolDefinition | FunctionDefinition): IComputeEngine;
|
|
1938
|
+
declare(id: string, def: BoxedDomain | DomainExpression | SymbolDefinition | FunctionDefinition): IComputeEngine;
|
|
1961
1939
|
declare(arg1: string | {
|
|
1962
|
-
[id: string]: DomainExpression | SymbolDefinition | FunctionDefinition;
|
|
1963
|
-
}, arg2?: DomainExpression | SymbolDefinition | FunctionDefinition): IComputeEngine;
|
|
1940
|
+
[id: string]: BoxedDomain | DomainExpression | SymbolDefinition | FunctionDefinition;
|
|
1941
|
+
}, arg2?: BoxedDomain | DomainExpression | SymbolDefinition | FunctionDefinition): IComputeEngine;
|
|
1964
1942
|
/**
|
|
1965
1943
|
* Add an assumption.
|
|
1966
1944
|
*
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param fn The function to differentiate, a `["Function"]` expression or
|
|
5
|
+
* an identifier for a function name.
|
|
6
|
+
*
|
|
7
|
+
* @param degrees
|
|
8
|
+
* @returns a function expression representing the derivative of `fn` with
|
|
9
|
+
* respect to the variables in `degrees`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function differentiateFunction(fn: BoxedExpression, degrees: number[]): BoxedExpression | undefined;
|
|
2
12
|
/**
|
|
3
13
|
* Calculate the partial derivative of an expression with respect to a
|
|
4
14
|
* variable, `v`.
|
|
15
|
+
*
|
|
16
|
+
* All expressions that do not explicitly depend on `v` are taken to have zero
|
|
17
|
+
* partial derivative.
|
|
18
|
+
*
|
|
5
19
|
*/
|
|
6
|
-
export declare function
|
|
20
|
+
export declare function differentiate(expr: BoxedExpression, v: string): BoxedExpression | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
export declare function distribute(expr: BoxedExpression[]): BoxedExpression;
|
|
3
3
|
/** Use the multinomial theorem (https://en.wikipedia.org/wiki/Multinomial_theorem) to expand the expression.
|
|
4
4
|
* The expression must be a power of a sum of terms.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
2
|
/**
|
|
3
3
|
* Flatten the arguments.
|
|
4
4
|
* If `expr` was canonical, the result it canonical.
|
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
export declare function flatten(expr: BoxedExpression, head: string): BoxedExpression;
|
|
7
7
|
export declare function flattenOps(ops: BoxedExpression[], head: string): BoxedExpression[];
|
|
8
8
|
export declare function flattenSequence(xs: BoxedExpression[]): BoxedExpression[];
|
|
9
|
-
export declare function canonical(xs: BoxedExpression[]): BoxedExpression[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import Decimal from 'decimal.js';
|
|
3
|
-
import { BoxedExpression, Rational } from '../public';
|
|
1
|
+
/* 0.17.0 */
|
|
2
|
+
import { Decimal } from 'decimal.js';
|
|
3
|
+
import { BoxedExpression, Hold, Rational } from '../public';
|
|
4
4
|
/**
|
|
5
5
|
* Return a rational coef and constant such that `coef * mod + constant = expr`
|
|
6
6
|
*/
|
|
@@ -23,3 +23,5 @@ export declare function apply(expr: BoxedExpression, fn: (x: number) => number |
|
|
|
23
23
|
export declare function applyN(expr: BoxedExpression, fn: (x: number) => number | Complex, bigFn?: (x: Decimal) => Decimal | Complex | number, complexFn?: (x: Complex) => number | Complex): BoxedExpression | undefined;
|
|
24
24
|
export declare function apply2(expr1: BoxedExpression, expr2: BoxedExpression, fn: (x1: number, x2: number) => number | Complex | Rational, bigFn?: (x1: Decimal, x2: Decimal) => Decimal | Complex | Rational | number, complexFn?: (x1: Complex, x2: number | Complex) => Complex | number): number | Decimal | Complex | Rational;
|
|
25
25
|
export declare function apply2N(expr1: BoxedExpression, expr2: BoxedExpression, fn: (x1: number, x2: number) => number | Complex | Rational, bigFn?: (x1: Decimal, x2: Decimal) => Decimal | Complex | number | Rational, complexFn?: (x1: Complex, x2: number | Complex) => Complex | number): BoxedExpression | undefined;
|
|
26
|
+
export declare function shouldHold(skip: Hold, count: number, index: number): boolean;
|
|
27
|
+
export declare function canonical(xs: BoxedExpression[]): BoxedExpression[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
export declare const version = "0.
|
|
1
|
+
/* 0.17.0 */
|
|
2
|
+
export declare const version = "0.17.0";
|
|
3
3
|
export { ComputeEngine } from './compute-engine/compute-engine';
|