@cortex-js/compute-engine 0.17.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.
Files changed (100) hide show
  1. package/dist/compute-engine.esm.js +478 -145
  2. package/dist/compute-engine.js +478 -145
  3. package/dist/compute-engine.min.esm.js +11 -8
  4. package/dist/compute-engine.min.js +11 -8
  5. package/dist/math-json.esm.js +2 -2
  6. package/dist/math-json.js +2 -2
  7. package/dist/math-json.min.esm.js +2 -2
  8. package/dist/math-json.min.js +2 -2
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  11. package/dist/types/common/signals.d.ts +1 -1
  12. package/dist/types/common/utils.d.ts +1 -1
  13. package/dist/types/compute-engine/assume.d.ts +1 -1
  14. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  15. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  16. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  17. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
  18. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
  19. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  20. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  21. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  22. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  23. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  25. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  26. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  27. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  28. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  29. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  30. package/dist/types/compute-engine/compile.d.ts +8 -4
  31. package/dist/types/compute-engine/compute-engine.d.ts +1 -1
  32. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  33. package/dist/types/compute-engine/domain-utils.d.ts +1 -1
  34. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  35. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  36. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  37. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  38. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  39. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  40. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  41. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  42. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  43. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  51. package/dist/types/compute-engine/latex-syntax/public.d.ts +15 -6
  52. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  53. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  54. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  55. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  56. package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
  57. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
  58. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
  59. package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
  60. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  61. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  62. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  63. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  64. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  65. package/dist/types/compute-engine/library/core.d.ts +1 -1
  66. package/dist/types/compute-engine/library/domains.d.ts +1 -1
  67. package/dist/types/compute-engine/library/library.d.ts +1 -1
  68. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  69. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  70. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  71. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  72. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  73. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  74. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  75. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  76. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  77. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  78. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  79. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  80. package/dist/types/compute-engine/numerics/numeric.d.ts +9 -1
  81. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  82. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  83. package/dist/types/compute-engine/numerics/richardson.d.ts +80 -0
  84. package/dist/types/compute-engine/public.d.ts +1 -1
  85. package/dist/types/compute-engine/rules.d.ts +1 -1
  86. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  87. package/dist/types/compute-engine/solve.d.ts +1 -1
  88. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  89. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  90. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  91. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  92. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  93. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  94. package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
  95. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  96. package/dist/types/compute-engine.d.ts +2 -2
  97. package/dist/types/math-json/math-json-format.d.ts +1 -1
  98. package/dist/types/math-json/utils.d.ts +1 -1
  99. package/dist/types/math-json.d.ts +2 -2
  100. package/package.json +10 -3
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { BoxedExpression } from '../public';
4
4
  export declare const MACHINE_PRECISION_BITS = 53;
@@ -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.17.0 */
1
+ /* 0.18.0 */
2
2
  export declare function isPrime(n: number): boolean | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  export declare function isRational(x: any | null): x is Rational;
3
3
  export declare function isMachineRational(x: any | null): x is [number, number];
4
4
  export declare function isBigRational(x: any | null): x is [bigint, bigint];
@@ -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];
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  * The most important classes are {@link ComputeEngine} and
3
3
  * {@link BoxedExpression}.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  /**
3
3
  * Go through all the rules in the rule set, and for all the rules that match
4
4
  * return the rhs of the rule applied to `expr`.
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  /**
3
3
  * A set of simplification rules.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  export declare const UNIVARIATE_ROOTS: Rule[];
3
3
  /**
4
4
  * Expression is a function of a single variable (`x`) or an Equality
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  /**
3
3
  *
4
4
  * @param fn The function to differentiate, a `["Function"]` expression or
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.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.17.0 */
1
+ /* 0.18.0 */
2
2
  /**
3
3
  * Flatten the arguments.
4
4
  * If `expr` was canonical, the result it canonical.
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  /**
3
3
  * Distribute `Negate` (multiply by -1) if expr is a number literal, an
4
4
  * addition or multiplication or another `Negate`.
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  /**
3
3
  * Coefficient of a univariate (single variable) polynomial.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  /**
3
3
  * Group terms in a product by common term.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  export declare class Sum {
3
3
  private engine;
4
4
  private _isCanonical;
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { BoxedExpression, Hold, Rational } from '../public';
4
4
  /**
@@ -1,3 +1,3 @@
1
- /* 0.17.0 */
2
- export declare const version = "0.17.0";
1
+ /* 0.18.0 */
2
+ export declare const version = "0.18.0";
3
3
  export { ComputeEngine } from './compute-engine/compute-engine';
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  /** A human readable string to annotate this expression, since JSON does not
3
3
  * allow comments in its encoding */
4
4
  comment?: string;
@@ -1,4 +1,4 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  export declare const MISSING: Expression;
3
3
  export declare function isNumberExpression(expr: Expression | null): expr is number | string | MathJsonNumber;
4
4
  export declare function isNumberObject(expr: Expression | null): expr is MathJsonNumber;
@@ -1,3 +1,3 @@
1
- /* 0.17.0 */
1
+ /* 0.18.0 */
2
2
  export { isSymbolObject, isStringObject, isFunctionObject, isDictionaryObject, stringValue as getStringValue, head, headName, symbol, applyRecursively, mapArgs, op, nops, dictionary as getDictionary, } from './math-json/utils';
3
- export declare const version = "0.17.0";
3
+ export declare const version = "0.18.0";
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.17.0",
2
+ "version": "0.18.0",
3
3
  "scripts": {
4
4
  "build": "bash ./scripts/build.sh",
5
5
  "clean": "bash ./scripts/clean.sh",
@@ -38,6 +38,14 @@
38
38
  "files": [
39
39
  "/dist"
40
40
  ],
41
+ "exports": {
42
+ ".": {
43
+ "types": "./dist/types/compute-engine.d.ts",
44
+ "require": "./dist/compute-engine.min.js",
45
+ "import": "./dist/compute-engine.min.esm.js",
46
+ "default": "./dist/compute-engine.min.js"
47
+ }
48
+ },
41
49
  "main": "./dist/compute-engine.min.js",
42
50
  "module": "./dist/compute-engine.min.esm.js",
43
51
  "types": "./dist/types/compute-engine.d.ts",
@@ -76,6 +84,5 @@
76
84
  "dependencies": {
77
85
  "complex.js": "^2.1.1",
78
86
  "decimal.js": "^10.4.3"
79
- },
80
- "type": "module"
87
+ }
81
88
  }