@cortex-js/compute-engine 0.25.1 → 0.26.2

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 (153) hide show
  1. package/README.md +5 -8
  2. package/dist/compute-engine.esm.js +26338 -22472
  3. package/dist/compute-engine.js +26348 -22470
  4. package/dist/compute-engine.min.esm.js +89 -23
  5. package/dist/compute-engine.min.js +89 -23
  6. package/dist/math-json.esm.js +22 -139
  7. package/dist/math-json.js +22 -139
  8. package/dist/math-json.min.esm.js +22 -139
  9. package/dist/math-json.min.js +2 -2
  10. package/dist/types/common/ansi-codes.d.ts +30 -4
  11. package/dist/types/common/buffer.d.ts +9 -0
  12. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  13. package/dist/types/common/one-of.d.ts +9 -0
  14. package/dist/types/common/signals.d.ts +1 -1
  15. package/dist/types/common/styled-text.d.ts +28 -0
  16. package/dist/types/common/suggest.d.ts +1 -0
  17. package/dist/types/common/syntax-highlighter.d.ts +40 -0
  18. package/dist/types/common/terminal.d.ts +19 -0
  19. package/dist/types/common/type/parse.d.ts +4 -0
  20. package/dist/types/common/type/primitive.d.ts +8 -0
  21. package/dist/types/common/type/serialize.d.ts +2 -0
  22. package/dist/types/common/type/subtype.d.ts +6 -0
  23. package/dist/types/common/type/types.d.ts +249 -0
  24. package/dist/types/common/type/utils.d.ts +39 -0
  25. package/dist/types/common/utils.d.ts +2 -1
  26. package/dist/types/compute-engine/assume.d.ts +13 -13
  27. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +71 -47
  28. package/dist/types/compute-engine/boxed-expression/apply.d.ts +5 -0
  29. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +15 -0
  30. package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +12 -0
  31. package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +16 -0
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +20 -0
  33. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +11 -0
  34. package/dist/types/compute-engine/boxed-expression/box.d.ts +13 -71
  35. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +31 -13
  36. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +66 -45
  37. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +42 -37
  38. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -2
  39. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +13 -9
  40. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +34 -66
  41. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +63 -41
  42. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +44 -27
  43. package/dist/types/compute-engine/boxed-expression/cache.d.ts +6 -0
  44. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/compare.d.ts +13 -0
  46. package/dist/types/compute-engine/boxed-expression/expand.d.ts +20 -0
  47. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/factor.d.ts +7 -6
  49. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +25 -0
  50. package/dist/types/compute-engine/boxed-expression/hold.d.ts +9 -0
  51. package/dist/types/compute-engine/boxed-expression/match.d.ts +2 -4
  52. package/dist/types/compute-engine/{symbolic → boxed-expression}/negate.d.ts +4 -4
  53. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +5 -39
  54. package/dist/types/compute-engine/boxed-expression/order.d.ts +26 -14
  55. package/dist/types/compute-engine/{symbolic → boxed-expression}/polynomials.d.ts +11 -15
  56. package/dist/types/compute-engine/{symbolic → boxed-expression}/product.d.ts +18 -24
  57. package/dist/types/compute-engine/boxed-expression/public.d.ts +911 -634
  58. package/dist/types/compute-engine/boxed-expression/rules.d.ts +129 -0
  59. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +2 -2
  60. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +6 -0
  61. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +6 -0
  62. package/dist/types/compute-engine/{solve.d.ts → boxed-expression/solve.d.ts} +5 -5
  63. package/dist/types/compute-engine/{symbolic → boxed-expression}/tensor-fields.d.ts +3 -3
  64. package/dist/types/compute-engine/boxed-expression/terms.d.ts +10 -0
  65. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +10 -0
  66. package/dist/types/compute-engine/boxed-expression/utils.d.ts +22 -16
  67. package/dist/types/compute-engine/boxed-expression/validate.d.ts +10 -7
  68. package/dist/types/compute-engine/collection-utils.d.ts +24 -2
  69. package/dist/types/compute-engine/compile.d.ts +3 -3
  70. package/dist/types/compute-engine/compute-engine.d.ts +132 -165
  71. package/dist/types/compute-engine/cost-function.d.ts +11 -1
  72. package/dist/types/compute-engine/function-utils.d.ts +5 -5
  73. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  74. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  75. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  86. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  87. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +2 -2
  88. package/dist/types/compute-engine/latex-syntax/parse.d.ts +26 -31
  89. package/dist/types/compute-engine/latex-syntax/public.d.ts +24 -18
  90. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +2 -2
  91. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  92. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +5 -8
  93. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  94. package/dist/types/compute-engine/library/arithmetic.d.ts +4 -2
  95. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  96. package/dist/types/compute-engine/library/collections.d.ts +24 -1
  97. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  98. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  99. package/dist/types/compute-engine/library/core.d.ts +1 -3
  100. package/dist/types/compute-engine/library/invisible-operator.d.ts +4 -0
  101. package/dist/types/compute-engine/library/library.d.ts +2 -4
  102. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  103. package/dist/types/compute-engine/library/logic.d.ts +5 -1
  104. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  105. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  106. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  107. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  108. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  109. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  110. package/dist/types/compute-engine/library/utils.d.ts +46 -40
  111. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +59 -0
  112. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +77 -0
  113. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +58 -0
  114. package/dist/types/compute-engine/numeric-value/public.d.ts +110 -0
  115. package/dist/types/compute-engine/numerics/bigint.d.ts +2 -0
  116. package/dist/types/compute-engine/numerics/bignum.d.ts +12 -0
  117. package/dist/types/compute-engine/numerics/expression.d.ts +4 -0
  118. package/dist/types/compute-engine/numerics/interval.d.ts +12 -0
  119. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +19 -0
  120. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +4 -14
  121. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +6 -9
  122. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  123. package/dist/types/compute-engine/numerics/numeric.d.ts +9 -59
  124. package/dist/types/compute-engine/numerics/primes.d.ts +3 -3
  125. package/dist/types/compute-engine/numerics/rationals.d.ts +29 -13
  126. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  127. package/dist/types/compute-engine/numerics/special-functions.d.ts +28 -0
  128. package/dist/types/compute-engine/numerics/strings.d.ts +2 -0
  129. package/dist/types/compute-engine/public.d.ts +8 -4
  130. package/dist/types/compute-engine/symbolic/derivative.d.ts +2 -2
  131. package/dist/types/compute-engine/symbolic/distribute.d.ts +5 -0
  132. package/dist/types/compute-engine/{simplify-rules.d.ts → symbolic/simplify-rules.d.ts} +1 -1
  133. package/dist/types/compute-engine/{symbolic → tensor}/tensors.d.ts +3 -3
  134. package/dist/types/compute-engine.d.ts +4 -2
  135. package/dist/types/math-json/identifiers.d.ts +11 -0
  136. package/dist/types/math-json/{math-json-format.d.ts → types.d.ts} +4 -9
  137. package/dist/types/math-json/utils.d.ts +15 -23
  138. package/dist/types/math-json.d.ts +3 -3
  139. package/package.json +3 -3
  140. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +0 -48
  141. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +0 -40
  142. package/dist/types/compute-engine/boxed-expression/coefficient-field.d.ts +0 -56
  143. package/dist/types/compute-engine/domain-utils.d.ts +0 -19
  144. package/dist/types/compute-engine/library/arithmetic-add.d.ts +0 -21
  145. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +0 -16
  146. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +0 -16
  147. package/dist/types/compute-engine/library/arithmetic-power.d.ts +0 -11
  148. package/dist/types/compute-engine/library/domains.d.ts +0 -16
  149. package/dist/types/compute-engine/numerics/terms.d.ts +0 -17
  150. package/dist/types/compute-engine/rules.d.ts +0 -20
  151. package/dist/types/compute-engine/symbolic/expand.d.ts +0 -23
  152. package/dist/types/compute-engine/symbolic/flatten.d.ts +0 -9
  153. package/dist/types/compute-engine/symbolic/utils.d.ts +0 -22
@@ -0,0 +1,25 @@
1
+ /* 0.26.2 */
2
+ /**
3
+ *
4
+ * Make all the arguments canonical.
5
+ *
6
+ * "Lift" Sequence expressions to the top level.
7
+ * e.g. `["Add", 1, ["Sequence", 2, 3]]` -> `["Add", 1, 2, 3]`
8
+ *
9
+ * Additionally, if an operator is provided, also lift nested expressions
10
+ * with the same operator.
11
+ * e.g. `["f", a, ["f", b, c]]` -> `["f", a, b, c]`
12
+ *
13
+ * Note: *not* recursive
14
+ */
15
+ export declare function flatten<T extends ReadonlyArray<BoxedExpression> | BoxedExpression[]>(ops: T, operator?: string): T;
16
+ /**
17
+ * Flatten the arguments.
18
+ * @fixme replace with just flatten.
19
+ * @fixme consider adding flatternSort()
20
+ */
21
+ export declare function flattenOps<T extends ReadonlyArray<BoxedExpression> | BoxedExpression[]>(ops: T, operator: string): T;
22
+ /**
23
+ * @todo: this function should probably not be recursive. As it, it is semi-recursive.
24
+ */
25
+ export declare function flattenSequence(xs: ReadonlyArray<BoxedExpression>): ReadonlyArray<BoxedExpression>;
@@ -0,0 +1,9 @@
1
+ /* 0.26.2 */
2
+ /** Apply the function `f` to each operand of the expression `expr`,
3
+ * account for the 'hold' property of the function definition:
4
+ *
5
+ * Account for `Hold`, `ReleaseHold`, `Sequence`, `Symbol` and `Nothing`.
6
+ *
7
+ * If `f` returns `null`, the element is not added to the result
8
+ */
9
+ export declare function holdMap(expr: BoxedExpression, f: (x: BoxedExpression) => BoxedExpression | null): ReadonlyArray<BoxedExpression>;
@@ -1,6 +1,4 @@
1
- /* 0.25.1 */
2
- import Decimal from 'decimal.js';
3
- import { BoxedSubstitution, PatternMatchOptions, BoxedExpression, SemiBoxedExpression } from './public';
1
+ /* 0.26.2 */
4
2
  /**
5
3
  * The function attempts to match a subject expression to a
6
4
  * [pattern](/compute-engine/guides/patterns-and-rules/).
@@ -11,4 +9,4 @@ import { BoxedSubstitution, PatternMatchOptions, BoxedExpression, SemiBoxedExpre
11
9
  * If the expression does not match the pattern, it returns `null`.
12
10
  *
13
11
  */
14
- export declare function match(subject: BoxedExpression, pattern: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression | BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
12
+ export declare function match(subject: BoxedExpression, pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
@@ -1,4 +1,5 @@
1
- /* 0.25.1 */
1
+ /* 0.26.2 */
2
+ export declare function canonicalNegate(expr: BoxedExpression): BoxedExpression;
2
3
  /**
3
4
  * Distribute `Negate` (multiply by -1) if expr is a number literal, an
4
5
  * addition or multiplication or another `Negate`.
@@ -6,6 +7,5 @@
6
7
  * It is important to do all these to handle cases like
7
8
  * `-3x` -> ["Negate, ["Multiply", 3, "x"]] -> ["Multiply, -3, x]
8
9
  */
9
- export declare function evalNegate(expr: BoxedExpression): BoxedExpression;
10
- export declare function canonicalNegate(expr: BoxedExpression): BoxedExpression;
11
- export declare function processNegate(_ce: IComputeEngine, x: BoxedExpression, _mode?: 'simplify' | 'evaluate' | 'N'): BoxedExpression;
10
+ export declare function negate(expr: BoxedExpression): BoxedExpression;
11
+ export declare function negateProduct(ce: IComputeEngine, args: ReadonlyArray<BoxedExpression>): BoxedExpression;
@@ -1,41 +1,7 @@
1
- /* 0.25.1 */
2
- import { Rational } from '../numerics/rationals';
3
- import { BoxedExpression } from './public';
4
- /**
5
- * Attempt to factor a numeric coefficient `c` and a `rest` out of a
6
- * canonical expression `expr` such that `ce.mul(c, rest)` is equal to `expr`.
7
- *
8
- * Attempts to make `rest` a positive value (i.e. pulls out negative sign).
9
- *
10
- * For example:
11
- *
12
- * ['Multiply', 2, 'x', 3, 'a']
13
- * -> [6, ['Multiply', 'x', 'a']]
14
- *
15
- * ['Divide', ['Multiply', 2, 'x'], ['Multiply', 3, 'y', 'a']]
16
- * -> [['Rational', 2, 3], ['Divide', 'x', ['Multiply, 'y', 'a']]]
17
- */
18
- export declare function asCoefficient(expr: BoxedExpression): [coef: Rational, rest: BoxedExpression];
1
+ /* 0.26.2 */
2
+ import type { Rational } from '../numerics/rationals';
3
+ import type { BoxedExpression } from './public';
19
4
  export declare function asRational(expr: BoxedExpression): Rational | undefined;
20
- export declare function asApproximateRational(expr: BoxedExpression): Rational | undefined;
21
- export declare function div(lhs: Rational, rhs: Rational): Rational;
22
- /**
23
- * Add a literal numeric value to a rational.
24
- * If the rational is a bigint, this is a hint to do the calculation in bigint
25
- * (no need to check `bignumPreferred()`).
26
- * @param lhs
27
- * @param rhs
28
- * @returns
29
- */
30
- export declare function add(lhs: Rational, rhs: BoxedExpression | Rational): Rational;
31
- export declare function mul(lhs: Rational, rhs: BoxedExpression | Rational): Rational;
32
- export declare function asFloat(expr: BoxedExpression | undefined): number | null;
5
+ export declare function asBigint(expr: BoxedExpression | undefined): bigint | null;
33
6
  export declare function asBignum(expr: BoxedExpression | undefined): Decimal | null;
34
- export declare function asMachineInteger(expr: BoxedExpression | undefined): number | null;
35
- /**
36
- *
37
- * @param lhs
38
- * @param rhs
39
- * @returns the sign (-1, 0, 1) of the difference between `lhs` and `rhs`
40
- */
41
- export declare function signDiff(lhs: BoxedExpression, rhs: BoxedExpression, tolerance?: number): -1 | 0 | 1 | undefined;
7
+ export declare function asSmallInteger(expr: number | BoxedExpression | undefined): number | null;
@@ -1,11 +1,22 @@
1
- /* 0.25.1 */
1
+ /* 0.26.2 */
2
2
  export type Order = 'lex' | 'dexlex' | 'grevlex' | 'elim';
3
3
  export declare const DEFAULT_COMPLEXITY = 100000;
4
4
  /**
5
- * Sort by higher total degree (sum of degree), if tied, sort by max degree,
6
- * if tied,
5
+ * The sorting order of arguments of the Add function uses a modified degrevlex:
6
+ * - Sort by total degree (sum of degree)
7
+ * - Sort by max degree.
8
+ * - Sort reverse lexicographically
9
+ * - Sort by rank
10
+ *
11
+ *
12
+ * E.g.
13
+ * - 2x^2 + 3x + 1
14
+ * - 2x^2y^3 + 5x^3y
7
15
  */
8
- export declare function sortAdd(ops: ReadonlyArray<BoxedExpression>): ReadonlyArray<BoxedExpression>;
16
+ export declare function addOrder(a: BoxedExpression, b: BoxedExpression): number;
17
+ export declare function equalOrder(a: BoxedExpression, b: BoxedExpression): number;
18
+ declare const RANKS: readonly ["integer", "rational", "radical", "real", "complex", "constant", "symbol", "multiply", "divide", "add", "trig", "fn", "power", "string", "other"];
19
+ export type Rank = (typeof RANKS)[number];
9
20
  /**
10
21
  * Given two expressions `a` and `b`, return:
11
22
  * - `-1` if `a` should be ordered before `b`
@@ -15,7 +26,7 @@ export declare function sortAdd(ops: ReadonlyArray<BoxedExpression>): ReadonlyAr
15
26
  * The default order is as follow:
16
27
  *
17
28
  * 1/ Literal numeric values (rational, machine numbers and Decimal numbers),
18
- * ordered by they numeric value (smaller numbers before larger numbers)
29
+ * ordered by their numeric value (smaller numbers before larger numbers)
19
30
  *
20
31
  * 2/ Literal complex numbers, ordered by their real parts. In case of a tie,
21
32
  * ordered by the absolute value of their imaginary parts. In case of a tie,
@@ -26,7 +37,7 @@ export declare function sortAdd(ops: ReadonlyArray<BoxedExpression>): ReadonlyAr
26
37
  * 4/ Addition, ordered as a polynom, with higher degree terms first
27
38
  *
28
39
  * 5/ Other functions, ordered by their `complexity` property. In case
29
- * of a tie, ordered by the head of the expression as a string. In case of a
40
+ * of a tie, ordered by the operator of the expression as a string. In case of a
30
41
  * tie, by the leaf count of each expression. In case of a tie, by the order
31
42
  * of each argument, left to right.
32
43
  *
@@ -35,9 +46,8 @@ export declare function sortAdd(ops: ReadonlyArray<BoxedExpression>): ReadonlyAr
35
46
  * example "E" < "e" < "È" and "11" < "2". This ordering is not suitable to
36
47
  * collate natural language strings.
37
48
  *
38
- * 7/ Dictionaries, ordered by the number of keys. If there is a tie, by the
39
- * sum of the complexities of the values of the dictionary
40
- *
49
+ * See https://reference.wolfram.com/language/ref/Sort.html for a
50
+ * description of the ordering of expressions in Mathematica.
41
51
  *
42
52
  */
43
53
  export declare function order(a: BoxedExpression, b: BoxedExpression): number;
@@ -47,13 +57,15 @@ export declare function order(a: BoxedExpression, b: BoxedExpression): number;
47
57
  export declare function canonicalOrder(expr: BoxedExpression, { recursive }: {
48
58
  recursive?: boolean;
49
59
  }): BoxedExpression;
60
+ export declare function sortOperands(operator: string, xs: ReadonlyArray<BoxedExpression>): ReadonlyArray<BoxedExpression>;
50
61
  /**
51
62
  * Sort the terms of a polynomial expression (`Add` expression) according
52
63
  * to the deglex polynomial ordering
53
64
  *
54
65
  */
55
- export declare function polynomialOrder(expr: BoxedExpression): SemiBoxedExpression;
56
- export declare function lexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): SemiBoxedExpression;
57
- export declare function degreeLexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): SemiBoxedExpression;
58
- export declare function degreeReverseLexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): SemiBoxedExpression;
59
- export declare function eliminationOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): SemiBoxedExpression;
66
+ export declare function polynomialOrder(expr: BoxedExpression): BoxedExpression;
67
+ export declare function lexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
68
+ export declare function degreeLexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
69
+ export declare function degreeReverseLexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
70
+ export declare function eliminationOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
71
+ export {};
@@ -1,4 +1,4 @@
1
- /* 0.25.1 */
1
+ /* 0.26.2 */
2
2
  /**
3
3
  * Coefficient of a univariate (single variable) polynomial.
4
4
  *
@@ -22,31 +22,27 @@ export type MultivariateCoefficients = (null | (null | BoxedExpression)[])[];
22
22
  */
23
23
  export declare function coefficients(poly: BoxedExpression, vars: string): UnivariateCoefficients | null;
24
24
  export declare function coefficients(poly: BoxedExpression, vars: string[]): MultivariateCoefficients | null;
25
- /**
26
- * Return a polynomial expression of `vars` with coefficient
27
- * of powers `coefs`.
28
- *
29
- * `poly === polynomial(coefficients(poly), getVars(poly))`
30
- *
31
- */
32
- export declare function polynomial(coefs: UnivariateCoefficients, vars: string): SemiBoxedExpression;
33
- export declare function polynomial(coefs: MultivariateCoefficients, vars: string[]): SemiBoxedExpression;
34
25
  /**
35
26
  * The total degree of an expression is the sum of the
36
- * of the positive integer degrees of the factors in the expression:
27
+ * positive integer degrees of the factors in the expression:
37
28
  *
38
- * `3√2x^5y^3` -> 8 (5 + 3)
29
+ * `3√2x^5y^3` -> 5 + 3 = 8
39
30
  */
40
31
  export declare function totalDegree(expr: BoxedExpression): number;
41
32
  /**
42
- * The max degree of an expression is the largest positive integer degree
43
- * in the factors of the expression
33
+ * The max degree of a polynomial is the largest positive integer degree
34
+ * in the factors (monomials) of the expression
44
35
  *
45
36
  * `3√2x^5y^3` -> 5
46
37
  *
47
38
  */
48
39
  export declare function maxDegree(expr: BoxedExpression): number;
49
40
  /**
50
- * Return a lexicographic key of the expression
41
+ * Return a lexicographic key of the expression, for example
42
+ * `xy^2` -> `x y`
43
+ * `x\frac{1}{y}` -> `x y`
44
+ * `2xy + y^2` -> `x y y`
45
+ *
51
46
  */
52
47
  export declare function lex(expr: BoxedExpression): string;
48
+ export declare function revlex(expr: BoxedExpression): string;
@@ -1,18 +1,19 @@
1
- /* 0.25.1 */
1
+ /* 0.26.2 */
2
2
  import { Rational } from '../numerics/rationals';
3
+ import { NumericValue } from '../numeric-value/public';
3
4
  /**
4
5
  * Group terms in a product by common term.
5
6
  *
6
7
  * All the terms should be canonical.
7
8
  * - the arguments should have been flattened for `Multiply`
8
9
  *
9
- * - any argument of power been factored out, i.e.
10
+ * - any argument of power been distributed, i.e.
10
11
  * (ab)^2 -> a^2 b^2
11
12
  * *
12
13
  * 3 + √5 + √(x+1) + x^2 + (a+b)^2 + d
13
14
  * -> [ [[3, "d"], [1, 1]],
14
15
  * [[5, "x+1"], [1, 2]],
15
- * [[x, "a+b"], [2, 1]]
16
+ * [[1, "a+b"], [2, 1]]
16
17
  * ]
17
18
  *
18
19
  */
@@ -21,40 +22,30 @@ export declare class Product {
21
22
  canonical?: boolean;
22
23
  };
23
24
  engine: IComputeEngine;
24
- private _sign;
25
- private _number;
26
- private _complex;
27
- private _bignum;
28
- private _rational;
29
- private _rationalSqrt;
30
- private _terms;
31
- private _hasInfinity;
32
- private _hasZero;
25
+ coefficient: NumericValue;
26
+ terms: {
27
+ term: BoxedExpression;
28
+ exponent: Rational;
29
+ }[];
33
30
  private _isCanonical;
31
+ static from(expr: BoxedExpression): Product;
34
32
  constructor(ce: IComputeEngine, xs?: ReadonlyArray<BoxedExpression>, options?: {
35
33
  canonical?: boolean;
36
34
  });
37
- get isEmpty(): boolean;
38
35
  /**
39
36
  * Add a term to the product.
40
37
  *
41
38
  * If `this._isCanonical` a running product of exact terms is kept.
42
39
  * Otherwise, terms and their exponent are tallied.
43
40
  */
44
- addTerm(term: BoxedExpression): void;
45
- /** Return all the terms with an exponent of 1 and
46
- * the square root of rationals (which technically have an
47
- * exponent of 1/2, but are considered as degree 1 terms)
48
- */
49
- unitTerms(mode: 'rational' | 'expression' | 'numeric'): {
50
- exponent: Rational;
51
- terms: BoxedExpression[];
52
- }[] | null;
41
+ mul(term: BoxedExpression, exp?: Rational): void;
42
+ /** Divide the product by a term of coefficient */
43
+ div(term: NumericValue | BoxedExpression): void;
53
44
  /** The terms of the product, grouped by degrees.
54
45
  *
55
46
  * If `mode` is `rational`, rationals are split into separate numerator and
56
47
  * denominator, so that a rational expression can be created later
57
- * If `mode` is `expression`, a regular expression is returned, without
48
+ * If `mode` is `expression`, a boxed expression is returned, without
58
49
  * splitting rationals
59
50
  * If `mode` is `numeric`, the literals are combined into one expression
60
51
  *
@@ -65,8 +56,11 @@ export declare class Product {
65
56
  exponent: Rational;
66
57
  terms: BoxedExpression[];
67
58
  }[] | null;
68
- asExpression(mode?: 'N' | 'evaluate'): BoxedExpression;
59
+ asExpression(options?: {
60
+ numericApproximation: boolean;
61
+ }): BoxedExpression;
69
62
  /** The product, expressed as a numerator and denominator */
70
63
  asNumeratorDenominator(): [BoxedExpression, BoxedExpression];
71
64
  asRationalExpression(): BoxedExpression;
72
65
  }
66
+ export declare function commonTerms(lhs: Product, rhs: Product): [NumericValue, BoxedExpression];