@cortex-js/compute-engine 0.25.0 → 0.25.1

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 (110) hide show
  1. package/dist/compute-engine.esm.js +3185 -5191
  2. package/dist/compute-engine.js +3185 -5191
  3. package/dist/compute-engine.min.esm.js +10 -10
  4. package/dist/compute-engine.min.js +10 -10
  5. package/dist/math-json.esm.js +39 -76
  6. package/dist/math-json.js +39 -76
  7. package/dist/math-json.min.esm.js +39 -76
  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 +2 -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/boxed-tensor.d.ts +1 -1
  26. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  27. package/dist/types/compute-engine/boxed-expression/coefficient-field.d.ts +56 -0
  28. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  29. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  30. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  32. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  33. package/dist/types/compute-engine/boxed-expression/public.d.ts +54 -35
  34. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  35. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  36. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  37. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  38. package/dist/types/compute-engine/compile.d.ts +1 -1
  39. package/dist/types/compute-engine/compute-engine.d.ts +4 -3
  40. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  41. package/dist/types/compute-engine/domain-utils.d.ts +1 -1
  42. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  43. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  51. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  52. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  53. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  54. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  55. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  56. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  57. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  58. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  59. package/dist/types/compute-engine/latex-syntax/public.d.ts +1 -1
  60. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  61. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  62. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  63. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  64. package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
  65. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -2
  66. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +2 -2
  67. package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
  68. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  69. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  70. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  71. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  72. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  73. package/dist/types/compute-engine/library/core.d.ts +1 -1
  74. package/dist/types/compute-engine/library/domains.d.ts +1 -1
  75. package/dist/types/compute-engine/library/library.d.ts +1 -1
  76. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  77. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  78. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  79. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  80. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  81. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  82. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  83. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  84. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  85. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  86. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  87. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  88. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  89. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  90. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  91. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  92. package/dist/types/compute-engine/numerics/terms.d.ts +1 -1
  93. package/dist/types/compute-engine/public.d.ts +1 -1
  94. package/dist/types/compute-engine/rules.d.ts +1 -1
  95. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  96. package/dist/types/compute-engine/solve.d.ts +1 -1
  97. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  98. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  99. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  100. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  101. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  102. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  103. package/dist/types/compute-engine/symbolic/tensor-fields.d.ts +1 -1
  104. package/dist/types/compute-engine/symbolic/tensors.d.ts +1 -1
  105. package/dist/types/compute-engine/symbolic/utils.d.ts +2 -2
  106. package/dist/types/compute-engine.d.ts +2 -2
  107. package/dist/types/math-json/math-json-format.d.ts +1 -1
  108. package/dist/types/math-json/utils.d.ts +1 -1
  109. package/dist/types/math-json.d.ts +2 -2
  110. package/package.json +10 -10
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  /** @category Error Handling */
3
3
  export type RuntimeSignalCode = 'timeout' | 'out-of-memory' | 'recursion-depth-exceeded' | 'iteration-limit-exceeded';
4
4
  /** @category Error Handling */
@@ -1 +1 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  /**
3
3
  * Add an assumption, in the form of a predicate, for example:
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { LatexString } from '../public';
@@ -87,6 +87,7 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
87
87
  }): BoxedExpression;
88
88
  map(fn: (x: BoxedExpression) => BoxedExpression, options?: {
89
89
  canonical: CanonicalOptions;
90
+ recursive?: boolean;
90
91
  }): BoxedExpression;
91
92
  solve(_vars: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
92
93
  replace(_rules: BoxedRuleSet | Rule | Rule[]): null | BoxedExpression;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata, CanonicalOptions } from './public';
4
4
  import { MathJsonNumber } from '../../math-json/math-json-format';
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, BoxedSubstitution, Rule, CanonicalOptions } from './public';
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { BoxedDomain, BoxedSubstitution, DomainCompatibility, DomainConstructor, DomainExpression, DomainLiteral, IComputeEngine, Metadata, PatternMatchOptions } from '../public';
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { BoxedExpression } from './public';
3
3
  export declare class _BoxedFunctionDefinition implements BoxedFunctionDefinition {
4
4
  engine: IComputeEngine;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { _BoxedExpression } from './abstract-boxed-expression';
4
4
  import { Expression } from '../../math-json/math-json-format';
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, NOptions, PatternMatchOptions, SimplifyOptions, BoxedSubstitution, EvaluateOptions, SemiBoxedExpression } from '../public';
4
4
  import { Rational } from '../numerics/rationals';
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { BoxedExpression } from './public';
3
3
  export declare function isWildcard(expr: BoxedExpression): expr is BoxedSymbol;
4
4
  export declare function wildcardName(expr: BoxedExpression): string | null;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, PatternMatchOptions, BoxedSubstitution, SemiBoxedExpression } from './public';
3
3
  import Complex from 'complex.js';
4
4
  import Decimal from 'decimal.js';
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  /**
3
3
  * ### THEORY OF OPERATIONS
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { _BoxedExpression } from './abstract-boxed-expression';
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, SimplifyOptions, Metadata, BoxedDomain, BoxedSubstitution, PatternMatchOptions, BoxedBaseDefinition, BoxedFunctionDefinition, SemiBoxedExpression } from '../public';
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare function canonicalForm(expr: BoxedExpression, forms: CanonicalOptions): BoxedExpression;
@@ -0,0 +1,56 @@
1
+ /* 0.25.1 */
2
+ *
3
+ * ## THEORY OF OPERATIONS
4
+ *
5
+ * In order to preserve exact results, some numeric operations are performed
6
+ * on "coefficients" which represent a product of a rational number,
7
+ * an algebraic numbers and the square root of an integer.
8
+ *
9
+ * A field is defined on these coefficients.
10
+ *
11
+ *
12
+ */
13
+ import { Rational } from '../numerics/rationals';
14
+ import { BoxedExpression } from './public';
15
+ export interface CoefficientData {
16
+ float: number;
17
+ rational: Rational;
18
+ sqrt: number;
19
+ }
20
+ export declare class Coefficient implements CoefficientData {
21
+ static zero: Coefficient;
22
+ static one: Coefficient;
23
+ /**
24
+ * Attempt to factor a numeric coefficient `c` and a `rest` out of a
25
+ * canonical expression `expr` such that `ce.mul(c, rest)` is equal to `expr`.
26
+ *
27
+ * Attempts to make `rest` a positive value (i.e. pulls out negative sign).
28
+ *
29
+ * For example:
30
+ *
31
+ * ['Multiply', 2, 'x', 3, 'a']
32
+ * -> [6, ['Multiply', 'x', 'a']]
33
+ *
34
+ * ['Divide', ['Multiply', 2, 'x'], ['Multiply', 3, 'y', 'a']]
35
+ * -> [['Rational', 2, 3], ['Divide', 'x', ['Multiply, 'y', 'a']]]
36
+ */
37
+ static fromExpression(expr: BoxedExpression): [coef: Coefficient, rest: BoxedExpression];
38
+ float: number;
39
+ rational: Rational;
40
+ sqrt: number;
41
+ constructor(value?: number | Partial<CoefficientData>);
42
+ asFloat(): number;
43
+ asRational(): Rational;
44
+ normalize(): void;
45
+ get isZero(): boolean;
46
+ get isOne(): boolean;
47
+ get sign(): number;
48
+ neg(): Coefficient;
49
+ inv(): Coefficient;
50
+ mul(other: Partial<CoefficientData> | number | Rational): Coefficient;
51
+ pow(exponent: number): Coefficient;
52
+ div(other: Partial<CoefficientData> | number | Rational): Coefficient;
53
+ add(other: Partial<CoefficientData> | number | Rational): Coefficient;
54
+ sub(other: Partial<CoefficientData> | number | Rational): Coefficient;
55
+ eq(other: Coefficient): boolean;
56
+ }
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare class ExpressionMap<U> implements ExpressionMapInterface<U> {
3
3
  readonly _items: Map<BoxedExpression, U>;
4
4
  constructor(source?: ExpressionMapInterface<U> | readonly (readonly [BoxedExpression, U])[]);
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { Rational } from '../numerics/rationals';
4
4
  import { BoxedExpression } from './public';
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { BoxedSubstitution, PatternMatchOptions, BoxedExpression, SemiBoxedExpression } from './public';
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Rational } from '../numerics/rationals';
3
3
  import { BoxedExpression } from './public';
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export type Order = 'lex' | 'dexlex' | 'grevlex' | 'elim';
3
3
  export declare const DEFAULT_COMPLEXITY = 100000;
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { Expression, MathJsonNumber, MathJsonString, MathJsonSymbol, MathJsonFunction, MathJsonDictionary, MathJsonIdentifier } from '../../math-json';
4
4
  import type { SerializeLatexOptions, LatexDictionaryEntry, ParseLatexOptions } from '../latex-syntax/public';
@@ -361,9 +361,12 @@ export interface BoxedExpression {
361
361
  *
362
362
  * The canonical option is applied to each function subexpression after
363
363
  * the substitution is applied.
364
+ *
365
+ * **Default**: `{canonical: true, recursive: true}`
364
366
  */
365
367
  map(fn: (expr: BoxedExpression) => BoxedExpression, options?: {
366
368
  canonical: CanonicalOptions;
369
+ recursive?: boolean;
367
370
  }): BoxedExpression;
368
371
  /**
369
372
  * Transform the expression by applying the rules:
@@ -1225,21 +1228,61 @@ export type PatternReplaceFunction = (expr: BoxedExpression, wildcards: BoxedSub
1225
1228
  /** @category Rules */
1226
1229
  export type PatternConditionFunction = (wildcards: BoxedSubstitution, ce: IComputeEngine) => boolean;
1227
1230
  /**
1228
- * @noInheritDoc
1231
+ * A rule describes how to modify an expressions that matches a pattern `match`
1232
+ * into a new expression `replace`.
1229
1233
  *
1230
- * @category Pattern Matching
1234
+ * - `x-1` \( \to \) `1-x`
1235
+ * - `(x+1)(x-1)` \( \to \) `x^2-1
1236
+ *
1237
+ * The patterns can be expressed as LaTeX strings or a MathJSON expressions.
1238
+ *
1239
+ * As a shortcut, a rule can be defined as a LaTeX string: `x-1 -> 1-x`.
1240
+ * The expression to the left of `->` is the `match` and the expression to the
1241
+ * right is the `replace`. When using LaTeX strings, single character variables
1242
+ * are assumed to be wildcards.
1243
+ *
1244
+ * When using MathJSON expressions, anonymous wildcards (`_`) will match any
1245
+ * expression. Named wildcards (`_x`, `_a`, etc...) will match any expression
1246
+ * and bind the expression to the wildcard name.
1247
+ *
1248
+ * In addition the sequence wildcard (`__1`, `__a`, etc...) will match
1249
+ * a sequence of one or more expressions, and bind the sequence to the
1250
+ * wildcard name.
1251
+ *
1252
+ * If `exact` is false, the rule will match variants. For example
1253
+ * 'x' will match 'a + x', 'x' will match 'ax', etc...
1254
+ * For simplification rules, you generally want `exact` to be true, but
1255
+ * to solve equations, you want it to be false. Default to true.
1256
+ *
1257
+ * When set to false, infinite recursion is possible.
1258
+ *
1259
+ * @category Rules
1231
1260
  */
1232
- export type Pattern = BoxedExpression;
1261
+ export type Rule = string | {
1262
+ match: LatexString | SemiBoxedExpression | Pattern;
1263
+ replace: LatexString | SemiBoxedExpression | PatternReplaceFunction;
1264
+ condition?: LatexString | PatternConditionFunction;
1265
+ exact?: boolean;
1266
+ priority?: number;
1267
+ id?: string;
1268
+ };
1233
1269
  /** @category Rules */
1234
1270
  export type BoxedRule = {
1235
1271
  match: Pattern;
1236
1272
  replace: BoxedExpression | PatternReplaceFunction;
1237
1273
  condition: undefined | PatternConditionFunction;
1238
1274
  priority: number;
1275
+ exact?: boolean;
1239
1276
  id?: string;
1240
1277
  };
1241
1278
  /** @category Rules */
1242
- export type BoxedRuleSet = ReadonlySet<BoxedRule>;
1279
+ export type BoxedRuleSet = Iterable<BoxedRule>;
1280
+ /**
1281
+ * @noInheritDoc
1282
+ *
1283
+ * @category Pattern Matching
1284
+ */
1285
+ export type Pattern = BoxedExpression;
1243
1286
  /**
1244
1287
  * @category Boxed Expression
1245
1288
  *
@@ -1282,7 +1325,7 @@ export type DomainExpression<T = SemiBoxedExpression> = DomainLiteral | ['Union'
1282
1325
  */
1283
1326
  export type SimplifyOptions = {
1284
1327
  recursive?: boolean;
1285
- rules?: BoxedRuleSet;
1328
+ rules?: null | BoxedRuleSet;
1286
1329
  };
1287
1330
  /** Options for `BoxedExpression.evaluate()`
1288
1331
  *
@@ -1438,6 +1481,10 @@ export interface IComputeEngine {
1438
1481
  tuple(elements: ReadonlyArray<BoxedExpression>, metadata?: Metadata): BoxedExpression;
1439
1482
  array(elements: ArrayValue[] | ArrayValue[][], metadata?: Metadata): BoxedExpression;
1440
1483
  rules(rules: Rule[]): BoxedRuleSet;
1484
+ /**
1485
+ * Return a set of built-in rules.
1486
+ */
1487
+ getRuleSet(id?: 'harmonization' | 'solve-univariate' | 'standard-simplification'): BoxedRuleSet | undefined;
1441
1488
  /**
1442
1489
  * This is a primitive to create a boxed function.
1443
1490
  *
@@ -1511,7 +1558,7 @@ export interface ComputeEngineStats {
1511
1558
  highwaterMark: number;
1512
1559
  }
1513
1560
  /**
1514
- * Options to control the serialization to MathJSON when using `BoxedExpression.json`.
1561
+ * Options to control the serialization to MathJSON when using `BoxedExpression.toMathJson()`.
1515
1562
  *
1516
1563
  * @category Compute Engine
1517
1564
  */
@@ -1627,34 +1674,6 @@ export type ReplaceOptions = {
1627
1674
  export type Substitution<T = SemiBoxedExpression> = {
1628
1675
  [symbol: string]: T;
1629
1676
  };
1630
- /**
1631
- * A rule describes how to modify an expressions that matches a pattern `match`
1632
- * into a new expression `replace`.
1633
- *
1634
- * `x-1` \( \to \) `1-x`
1635
- * `(x+1)(x-1)` \( \to \) `x^2-1
1636
- *
1637
- * The `match` pattern can be expressed as a LaTeX string or a
1638
- * MathJSON expression.
1639
- *
1640
- *
1641
- * Anonymous wildcards (`_`) will match any
1642
- * expression. Named wildcards (`_x`, `_a`, etc...) will match any expression
1643
- * and bind the expression to the wildcard name.
1644
- *
1645
- * In addition the sequence wildcard (`__1`, `__a`, etc...) will match
1646
- * a sequence of one or more expressions, and bind the sequence to the
1647
- * wildcard name.
1648
- *
1649
- * @category Rules
1650
- */
1651
- export type Rule = {
1652
- match: LatexString | SemiBoxedExpression | Pattern;
1653
- replace: LatexString | SemiBoxedExpression | PatternReplaceFunction;
1654
- condition?: LatexString | PatternConditionFunction;
1655
- priority?: number;
1656
- id?: string;
1657
- };
1658
1677
  /** @category Assumptions */
1659
1678
  export interface ExpressionMapInterface<U> {
1660
1679
  has(expr: BoxedExpression): boolean;
@@ -1,3 +1,3 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { BoxedExpression, IComputeEngine, JsonSerializationOptions } from '../public';
3
3
  export declare function serializeJson(ce: IComputeEngine, expr: BoxedExpression, options: Readonly<JsonSerializationOptions>): Expression;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Expression } from '../../math-json/math-json-format';
3
3
  import { BoxedExpression, IComputeEngine } from './public';
4
4
  export declare function isBoxedExpression(x: unknown): x is BoxedExpression;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { BoxedExpression } from './public';
3
3
  /**
4
4
  * Check that the number of arguments is as expected.
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare function isCollection(col: BoxedExpression): boolean;
3
3
  export declare function isFiniteCollection(col: BoxedExpression): boolean;
4
4
  export declare function isIndexableCollection(col: BoxedExpression): boolean;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { BoxedExpression } from './public';
3
3
  export type CompiledType = boolean | number | string | object;
4
4
  type JSSource = string;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { MathJsonIdentifier, MathJsonNumber } from '../math-json/math-json-format';
4
4
  import type { LibraryCategory, LatexDictionaryEntry, LatexString, ParseLatexOptions } from './latex-syntax/public';
@@ -497,7 +497,7 @@ export declare class ComputeEngine implements IComputeEngine {
497
497
  /** @internal */
498
498
  checkContinueExecution(): void;
499
499
  /** @internal */
500
- cache<T>(cacheName: string, build: () => T, purge: (T: any) => T | undefined): T;
500
+ cache<T>(cacheName: string, build: () => T, purge?: (T: any) => T | undefined): T;
501
501
  /** Return a boxed expression from a number, string or semiboxed expression.
502
502
  * Calls `ce.function()`, `ce.number()` or `ce.symbol()` as appropriate.
503
503
  */
@@ -549,7 +549,7 @@ export declare class ComputeEngine implements IComputeEngine {
549
549
  * Shortcut for `this.box(["Sqrt", base]).evaluate()`
550
550
  *
551
551
  */
552
- sqrt(base: BoxedExpression): any;
552
+ sqrt(base: BoxedExpression): BoxedExpression;
553
553
  /**
554
554
  *
555
555
  * Shortcut for `this.box(["Power", base, exponent]).evaluate()`
@@ -595,6 +595,7 @@ export declare class ComputeEngine implements IComputeEngine {
595
595
  canonical?: CanonicalOptions;
596
596
  }): BoxedExpression;
597
597
  rules(rules: Rule[]): BoxedRuleSet;
598
+ getRuleSet(id?: string): BoxedRuleSet | undefined;
598
599
  /**
599
600
  * Return a function expression, but the caller is responsible for making
600
601
  * sure that the arguments are canonical.
@@ -1,3 +1,3 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare function costFunction(expr: BoxedExpression): number;
3
3
  export declare const DEFAULT_COST_FUNCTION: typeof costFunction;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { Rational } from './numerics/rationals';
4
4
  import type { BoxedDomain, BoxedFunctionSignature, DomainLiteral, FunctionSignature, IComputeEngine } from './public';
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  /***
3
3
  * ### THEORY OF OPERATIONS
4
4
  *
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_CALCULUS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_COMPLEX: LatexDictionary;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_CORE: LatexDictionary;
3
3
  export declare const DELIMITERS_SHORTHAND: {
4
4
  '(': string;
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_LINEAR_ALGEBRA: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_LOGIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_OTHERS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_INEQUALITIES: LatexDictionaryEntry[];
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_SETS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_STATISTICS: LatexDictionary;
@@ -1,3 +1,3 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const SYMBOLS: [string, string, number][];
3
3
  export declare const DEFINITIONS_SYMBOLS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Delimiter, EnvironmentParseHandler, ExpressionParseHandler, InfixParseHandler, LatexDictionary, LatexDictionaryEntry, LatexString, LatexToken, LibraryCategory, MatchfixParseHandler, PostfixParseHandler, Precedence, SerializeHandler } from '../public';
3
3
  export type CommonEntry = {
4
4
  /** Note: a name is required if a serialize handler is provided */
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { Parser } from './public';
3
3
  /** For error handling, if we have a identifier prefix, assume
4
4
  * the identifier is invalid (it would have been captured by
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { ParseLatexOptions, LatexToken, Terminator, Parser, SymbolTable, SymbolType } from './public';
3
3
  import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry, IndexedInfixEntry, IndexedPostfixEntry, IndexedPrefixEntry, IndexedSymbolEntry, IndexedExpressionEntry, IndexedFunctionEntry } from './dictionary/definitions';
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export type SymbolType = 'symbol' | 'function' | 'unknown';
3
3
  export type SymbolTable = {
4
4
  parent: SymbolTable | null;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { NumberSerializationFormat } from './public';
3
3
  /**
4
4
  * @param expr - A number, can be represented as a string
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { DelimiterScale } from './public';
3
3
  export declare function getApplyFunctionStyle(_expr: Expression, _level: number): DelimiterScale;
4
4
  export declare function getGroupStyle(_expr: Expression, _level: number): DelimiterScale;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { LatexString, SerializeLatexOptions, DelimiterScale } from './public';
3
3
  import { IndexedLatexDictionary, IndexedLatexDictionaryEntry } from './dictionary/definitions';
4
4
  export declare class Serializer {
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  * ## Reference
3
3
  * TeX source code:
4
4
  * {@link http://tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web | Tex.web}
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  /** The canonical form of `Add`:
3
3
  * - removes `0`
4
4
  * - capture complex numbers (a + ib or ai +b)
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  /**
3
3
  * Canonical form of 'Divide' (and 'Rational')
4
4
  * - remove denominator of 1
@@ -6,7 +6,6 @@
6
6
  * - factor out negate (make the numerator and denominator positive)
7
7
  * - if numerator and denominator are integer literals, return a rational number
8
8
  * or Rational experssion
9
- * - if Divide, transform into Multiply/Power
10
9
  */
11
10
  export declare function canonicalDivide(ce: IComputeEngine, op1: BoxedExpression, op2: BoxedExpression): BoxedExpression;
12
11
  /**
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  /** The canonical form of `Multiply`:
3
3
  * - remove `1`
4
4
  * - simplify the signs:
@@ -10,7 +10,7 @@
10
10
  * The ops must be canonical, the result is canonical.
11
11
  */
12
12
  export declare function canonicalMultiply(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>): BoxedExpression;
13
- export declare function simplifyMultiply(ce: IComputeEngine, ops: BoxedExpression[]): BoxedExpression;
13
+ export declare function simplifyMultiply(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>): BoxedExpression;
14
14
  export declare function evalMultiply(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>, mode?: 'N' | 'evaluate'): BoxedExpression;
15
15
  export declare function canonicalProduct(ce: IComputeEngine, body: BoxedExpression | undefined, indexingSet: BoxedExpression | undefined): BoxedExpression | null;
16
16
  export declare function evalMultiplication(ce: IComputeEngine, summationEquation: ReadonlyArray<BoxedExpression>, mode: 'simplify' | 'N' | 'evaluate'): BoxedExpression | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  import { BoxedExpression, IComputeEngine, Metadata } from '../public';
3
3
  /**
4
4
  *
@@ -1,3 +1,3 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export type CanonicalArithmeticFunctions = 'Add' | 'Negate' | 'Sqrt' | 'Multiply' | 'Divide' | 'Power' | 'Ln';
3
3
  export declare const ARITHMETIC_LIBRARY: IdentifierDefinitions[];