@cortex-js/compute-engine 0.16.0 → 0.18.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 +4235 -3949
- package/dist/compute-engine.js +4235 -3949
- package/dist/compute-engine.min.esm.js +50 -27363
- package/dist/compute-engine.min.js +22 -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 +22 -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 +36 -23
- 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 +10 -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/numerics/richardson.d.ts +80 -0
- 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 +9 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
export type CanonicalArithmeticFunctions = 'Add' | 'Negate' | 'Multiply' | 'Divide' | 'Power' | 'Ln';
|
|
1
|
+
/* 0.18.0 */
|
|
2
|
+
export type CanonicalArithmeticFunctions = 'Add' | 'Negate' | 'Sqrt' | 'Multiply' | 'Divide' | 'Power' | 'Ln';
|
|
3
3
|
export declare const ARITHMETIC_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare const CALCULUS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare const COLLECTIONS_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare const COMPLEX_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare const CONTROL_STRUCTURES_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare const CORE_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.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.18.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.18.0 */
|
|
2
2
|
export declare const LINEAR_ALGEBRA_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare const LOGIC_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare const POLYNOMIALS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare function randomExpression(level?: number): Expression;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare const RELOP_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare const SETS_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare const STATISTICS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.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.18.0 */
|
|
4
2
|
export declare function normalizeLimits(range: BoxedExpression): [index: string, lower: number, upper: number, isFinite: boolean];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import Decimal from 'decimal.js';
|
|
1
|
+
/* 0.18.0 */
|
|
2
|
+
import { Decimal } from 'decimal.js';
|
|
3
3
|
import { BoxedExpression } from '../public';
|
|
4
4
|
export declare const MACHINE_PRECISION_BITS = 53;
|
|
5
5
|
export declare const MACHINE_PRECISION: number;
|
|
@@ -98,3 +98,11 @@ export declare function centeredDiff8thOrder(f: (number: any) => number, x: numb
|
|
|
98
98
|
*
|
|
99
99
|
*/
|
|
100
100
|
export declare function monteCarloEstimate(f: (x: number) => number, a: number, b: number, n?: number): number;
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* @param f
|
|
104
|
+
* @param x
|
|
105
|
+
* @param dir Direction of approach: > 0 for right, < 0 for left, 0 for both
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
export declare function limit(f: (x: number) => number, x: number, dir?: number): number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.18.0 */
|
|
2
2
|
export declare function isPrime(n: number): boolean | undefined;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* 0.18.0 */
|
|
2
|
+
|
|
3
|
+
Translated from https://github.com/JuliaMath/Richardson.jl/blob/master/src/Richardson.jl
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
The `Richardson` module provides a function `extrapolate` that
|
|
7
|
+
extrapolates a given function `f(x)` to `f(x0)`, evaluating
|
|
8
|
+
`f` only at a geometric sequence of points `> x0`
|
|
9
|
+
(or optionally `< x0`).
|
|
10
|
+
|
|
11
|
+
The key algorithm is Richardson extrapolation using a Neville—Aitken
|
|
12
|
+
tableau, which adaptively increases the degree of an extrapolation
|
|
13
|
+
polynomial until convergence is achieved to a desired tolerance
|
|
14
|
+
(or convergence stalls due to e.g. floating-point errors). This
|
|
15
|
+
allows one to obtain `f(x0)` to high-order accuracy, assuming
|
|
16
|
+
that `f(x0+h)` has a Taylor series or some other power
|
|
17
|
+
series in `h`.
|
|
18
|
+
*/
|
|
19
|
+
export interface ExtrapolateOptions {
|
|
20
|
+
contract?: number;
|
|
21
|
+
step?: number;
|
|
22
|
+
power?: number;
|
|
23
|
+
atol?: number;
|
|
24
|
+
rtol?: number;
|
|
25
|
+
maxeval?: number;
|
|
26
|
+
breaktol?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* Extrapolate `f(x)` to `f₀ ≈ f(x0)`, evaluating `f` only at `x > x0` points
|
|
31
|
+
(or `x < x0` if `h < 0`) using Richardson extrapolation starting at
|
|
32
|
+
`x=x₀+h`. It returns a tuple `(f₀, err)` of the estimated `f(x0)`
|
|
33
|
+
and an error estimate.
|
|
34
|
+
|
|
35
|
+
The return value of `f` can be any type supporting `±` and `norm`
|
|
36
|
+
operations (i.e. a normed vector space).
|
|
37
|
+
Similarly, `h` and `x0` can be in any normed vector space,
|
|
38
|
+
in which case `extrapolate` performs Richardson extrapolation
|
|
39
|
+
of `f(x0+s*h)` to `s=0⁺` (i.e. it takes the limit as `x` goes
|
|
40
|
+
to `x0` along the `h` direction).
|
|
41
|
+
|
|
42
|
+
On each step of Richardson extrapolation, it shrinks `x-x0` by
|
|
43
|
+
a factor of `contract`, stopping when the estimated error is
|
|
44
|
+
`< max(rtol*norm(f₀), atol)`, when the estimated error
|
|
45
|
+
increases by more than `breaktol` (e.g. due to numerical errors in the
|
|
46
|
+
computation of `f`), when `f` returns a non-finite value (`NaN` or `Inf`),
|
|
47
|
+
or when `f` has been evaluated `maxeval` times. Note that
|
|
48
|
+
if the function may converge to zero, you may want
|
|
49
|
+
specify a nonzero `atol` (which cannot be set by default
|
|
50
|
+
because it depends on the scale/units of `f`); alternatively,
|
|
51
|
+
in such cases `extrapolate` will halt when it becomes
|
|
52
|
+
limited by the floating-point precision. (Passing `breaktol=Inf`
|
|
53
|
+
can be useful to force `extrapolate` to continue shrinking `h` even
|
|
54
|
+
if polynomial extrapolation is initially failing to converge,
|
|
55
|
+
possibly at the cost of extraneous function evaluations.)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
If `x0 = ±∞` (`±Inf`), then `extrapolate` computes the limit of
|
|
59
|
+
`f(x)` as `x ⟶ ±∞` using geometrically *increasing* values
|
|
60
|
+
of `h` (by factors of `1/contract`).
|
|
61
|
+
|
|
62
|
+
In general, the starting `h` should be large enough that `f(x0+h)`
|
|
63
|
+
can be computed accurately and efficiently (e.g. without
|
|
64
|
+
severe cancellation errors), but small enough that `f` does not
|
|
65
|
+
oscillate much between `x0` and `h`. i.e. `h` should be a typical
|
|
66
|
+
scale over which the function `f` varies significantly.
|
|
67
|
+
|
|
68
|
+
Technically, Richardson extrapolation assumes that `f(x0+h)` can
|
|
69
|
+
be expanded in a power series in `h^power`, where the default
|
|
70
|
+
`power=1` corresponds to an ordinary Taylor series (i.e. assuming
|
|
71
|
+
`f` is analytic at `x0`). If this is not true, you may obtain
|
|
72
|
+
slow convergence from `extrapolate`, but you can pass a different
|
|
73
|
+
value of `power` (e.g. `power=0.5`) if your `f` has some different
|
|
74
|
+
(Puiseux) power-series expansion. Conversely, if `f` is
|
|
75
|
+
an *even* function around `x0`, i.e. `f(x0+h) == f(x0-h)`,
|
|
76
|
+
so that its Taylor series contains only *even* powers of `h`,
|
|
77
|
+
you can accelerate convergence by passing `power=2`.
|
|
78
|
+
|
|
79
|
+
*/
|
|
80
|
+
export declare function extrapolate(f: (x: number) => number, x0: number, options?: ExtrapolateOptions): [val: number, err: number];
|