@cortex-js/compute-engine 0.11.0 → 0.12.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 (86) hide show
  1. package/dist/compute-engine.esm.js +1607 -1357
  2. package/dist/compute-engine.min.esm.js +2 -2
  3. package/dist/compute-engine.min.js +2 -2
  4. package/dist/math-json.esm.js +2 -2
  5. package/dist/math-json.min.esm.js +2 -2
  6. package/dist/math-json.min.js +2 -2
  7. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  8. package/dist/types/common/signals.d.ts +1 -1
  9. package/dist/types/common/utils.d.ts +1 -1
  10. package/dist/types/compute-engine/assume.d.ts +1 -1
  11. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +3 -2
  12. package/dist/types/compute-engine/boxed-expression/box.d.ts +2 -2
  13. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  14. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
  15. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
  16. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  17. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  18. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  19. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  20. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
  21. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  22. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  23. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  25. package/dist/types/compute-engine/boxed-expression/utils.d.ts +8 -3
  26. package/dist/types/compute-engine/boxed-expression/validate.d.ts +4 -3
  27. package/dist/types/compute-engine/compute-engine.d.ts +15 -32
  28. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  29. package/dist/types/compute-engine/domain-utils.d.ts +3 -3
  30. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  31. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  32. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  33. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  34. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  35. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  36. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  37. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  38. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  39. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  40. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  41. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  42. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  43. package/dist/types/compute-engine/latex-syntax/public.d.ts +2 -2
  44. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -2
  45. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  48. package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
  49. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
  50. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
  51. package/dist/types/compute-engine/library/arithmetic-power.d.ts +2 -4
  52. package/dist/types/compute-engine/library/arithmetic.d.ts +2 -2
  53. package/dist/types/compute-engine/library/calculus.d.ts +2 -2
  54. package/dist/types/compute-engine/library/collections.d.ts +2 -2
  55. package/dist/types/compute-engine/library/core.d.ts +2 -2
  56. package/dist/types/compute-engine/library/domains.d.ts +1 -1
  57. package/dist/types/compute-engine/library/library.d.ts +5 -5
  58. package/dist/types/compute-engine/library/logic.d.ts +2 -2
  59. package/dist/types/compute-engine/library/polynomials.d.ts +2 -2
  60. package/dist/types/compute-engine/library/random-expression.d.ts +2 -0
  61. package/dist/types/compute-engine/library/relational-operator.d.ts +2 -2
  62. package/dist/types/compute-engine/library/sets.d.ts +2 -2
  63. package/dist/types/compute-engine/library/trigonometry.d.ts +2 -2
  64. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  65. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +12 -0
  66. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -9
  67. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  68. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  69. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  70. package/dist/types/compute-engine/numerics/rationals.d.ts +10 -12
  71. package/dist/types/compute-engine/public.d.ts +31 -47
  72. package/dist/types/compute-engine/rules.d.ts +1 -1
  73. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  74. package/dist/types/compute-engine/solve.d.ts +1 -1
  75. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  76. package/dist/types/compute-engine/symbolic/flatten.d.ts +3 -2
  77. package/dist/types/compute-engine/symbolic/negate.d.ts +4 -6
  78. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  79. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  80. package/dist/types/compute-engine/symbolic/sum.d.ts +3 -2
  81. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  82. package/dist/types/compute-engine.d.ts +2 -3
  83. package/dist/types/math-json/math-json-format.d.ts +1 -1
  84. package/dist/types/math-json/utils.d.ts +2 -1
  85. package/dist/types/math-json.d.ts +2 -3
  86. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ /* 0.12.1 */
2
+ export declare function randomExpression(level?: number): Expression;
@@ -1,2 +1,2 @@
1
- /* 0.11.0 */
2
- export declare const RELOP_LIBRARY: IDTable;
1
+ /* 0.12.1 */
2
+ export declare const RELOP_LIBRARY: IdTable;
@@ -1,2 +1,2 @@
1
- /* 0.11.0 */
2
- export declare const SETS_LIBRARY: IDTable;
1
+ /* 0.12.1 */
2
+ export declare const SETS_LIBRARY: IdTable;
@@ -1,2 +1,2 @@
1
- /* 0.11.0 */
2
- export declare const TRIGONOMETRY_LIBRARY: IDTable[];
1
+ /* 0.12.1 */
2
+ export declare const TRIGONOMETRY_LIBRARY: IdTable[];
@@ -1,3 +1,3 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  export declare function isSymbolDefinition(def: BoxedSymbolDefinition | BoxedFunctionDefinition | SymbolDefinition | FunctionDefinition | undefined | null): def is BoxedSymbolDefinition;
3
3
  export declare function isFunctionDefinition(def: BoxedSymbolDefinition | BoxedFunctionDefinition | SymbolDefinition | FunctionDefinition | undefined | null): def is BoxedFunctionDefinition;
@@ -0,0 +1,12 @@
1
+ /* 0.12.1 */
2
+ export declare function bigint(a: Decimal | number | bigint | string): bigint;
3
+ export declare function gcd(a: bigint, b: bigint): bigint;
4
+ export declare function lcm(a: bigint, b: bigint): bigint;
5
+ export declare function primeFactors(d: bigint): Map<bigint, number>;
6
+ /** Return `[factor, root]` such that
7
+ * pow(n, 1/exponent) = factor * pow(root, 1/exponent)
8
+ *
9
+ * factorPower(75, 2) -> [5, 3] = 5^2 * 3
10
+ *
11
+ */
12
+ export declare function factorPower(n: bigint, exponent: number): [factor: bigint, root: bigint];
@@ -1,15 +1,7 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  import { IComputeEngine } from '../public';
3
3
  export declare function gcd(a: Decimal, b: Decimal): Decimal;
4
4
  export declare function lcm(a: Decimal, b: Decimal): Decimal;
5
- export declare function primeFactors(ce: IComputeEngine, n: Decimal): Map<Decimal, number>;
6
- /** Return `[factor, root]` such that
7
- * pow(n, 1/exponent) = factor * pow(root, 1/exponent)
8
- *
9
- * factorPower(75, 2) -> [5, 3] = 5^2 * 3
10
- *
11
- */
12
- export declare function factorPower(ce: IComputeEngine, n: Decimal, exponent: number): [factor: Decimal, root: Decimal];
13
5
  export declare function factorial(ce: IComputeEngine, n: Decimal): Decimal;
14
6
  export declare function lngamma(ce: IComputeEngine, z: Decimal): Decimal;
15
7
  export declare function gamma(ce: IComputeEngine, z: Decimal): Decimal;
@@ -1,3 +1,3 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  export declare function gamma(c: Complex): Complex;
3
3
  export declare function lngamma(c: Complex): Complex;
@@ -1,4 +1,4 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { BoxedExpression } from '../public';
4
4
  export declare const MACHINE_PRECISION_BITS = 53;
@@ -1,2 +1,2 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  export declare function isPrime(n: number): boolean | undefined;
@@ -1,22 +1,20 @@
1
- /* 0.11.0 */
2
- import Decimal from 'decimal.js';
1
+ /* 0.12.1 */
3
2
  export declare function isRational(x: any | null): x is Rational;
4
3
  export declare function isMachineRational(x: any | null): x is [number, number];
5
- export declare function isBigRational(x: any | null): x is [Decimal, Decimal];
4
+ export declare function isBigRational(x: any | null): x is [bigint, bigint];
6
5
  export declare function isRationalZero(x: Rational): boolean;
7
6
  export declare function isRationalOne(x: Rational): boolean;
8
7
  export declare function isRationalNegativeOne(x: Rational): boolean;
9
8
  export declare function machineNumerator(x: Rational): number;
10
9
  export declare function machineDenominator(x: Rational): number;
11
- export declare function isNeg(lhs: Rational): boolean;
12
- export declare function neg(lhs: [number, number]): [number, number];
13
- export declare function neg(lhs: [Decimal, Decimal]): [Decimal, Decimal];
14
- export declare function neg(lhs: Rational): Rational;
15
- export declare function inverse(lhs: [number, number]): [number, number];
16
- export declare function inverse(lhs: [Decimal, Decimal]): [Decimal, Decimal];
17
- export declare function inverse(lhs: Rational): Rational;
10
+ export declare function isNeg(x: Rational): boolean;
11
+ export declare function neg(x: [number, number]): [number, number];
12
+ export declare function neg(x: [bigint, bigint]): [bigint, bigint];
13
+ export declare function neg(x: Rational): Rational;
14
+ export declare function inverse(x: [number, number]): [number, number];
15
+ export declare function inverse(x: [bigint, bigint]): [bigint, bigint];
16
+ export declare function inverse(x: Rational): Rational;
18
17
  export declare function asRational(expr: BoxedExpression): Rational | undefined;
19
- export declare function asMachineRational(r: Rational): [number, number];
20
18
  /**
21
19
  * Add a literal numeric value to a rational.
22
20
  * If the rational is a bignum, this is a hint to do the calculation in bignum
@@ -29,7 +27,7 @@ export declare function add(lhs: Rational, rhs: BoxedExpression | Rational): Rat
29
27
  export declare function mul(lhs: Rational, rhs: BoxedExpression | Rational): Rational;
30
28
  export declare function pow(r: Rational, exp: number): Rational;
31
29
  export declare function reducedRational(r: [number, number]): [number, number];
32
- export declare function reducedRational(r: [Decimal, Decimal]): [Decimal, Decimal];
30
+ export declare function reducedRational(r: [bigint, bigint]): [bigint, bigint];
33
31
  export declare function reducedRational(r: Rational): Rational;
34
32
  /** Return a rational approximation of x */
35
33
  export declare function rationalize(x: number): [n: number, d: number] | number;
@@ -1,4 +1,4 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  * The most important classes are {@link ComputeEngine} and
3
3
  * {@link BoxedExpression}.
4
4
  *
@@ -9,11 +9,10 @@
9
9
  */
10
10
  import type { Decimal } from 'decimal.js';
11
11
  import type { Complex } from 'complex.js';
12
- import type { SignalMessage, WarningSignal, WarningSignalHandler } from '../common/signals';
13
12
  import type { Expression, MathJsonDictionary, MathJsonFunction, MathJsonNumber, MathJsonString, MathJsonSymbol } from '../math-json/math-json-format';
14
13
  import type { NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
15
14
  export * from './latex-syntax/public';
16
- export type Rational = [number, number] | [Decimal, Decimal];
15
+ export type Rational = [number, number] | [bigint, bigint];
17
16
  /**
18
17
  * Metadata that can be associated with a `BoxedExpression`
19
18
  */
@@ -82,12 +81,10 @@ export type ReplaceOptions = {
82
81
  * A substitution can also be considered a more constrained version of a
83
82
  * rule whose `lhs` is always a symbol.
84
83
  */
85
- export type Substitution = {
86
- [symbol: string]: SemiBoxedExpression;
87
- };
88
- export type BoxedSubstitution = {
89
- [symbol: string]: BoxedExpression;
84
+ export type Substitution<T = SemiBoxedExpression> = {
85
+ [symbol: string]: T;
90
86
  };
87
+ export type BoxedSubstitution = Substitution<BoxedExpression>;
91
88
  /** A LaTeX string starts and end with `$`, for example
92
89
  * `"$\frac{\pi}{2}$"`.
93
90
  */
@@ -352,7 +349,12 @@ export interface BoxedExpression {
352
349
  * **Note** applicable to canonical and non-canonical expressions.
353
350
  *
354
351
  */
355
- readonly symbols: BoxedExpression[];
352
+ readonly symbols: string[];
353
+ /**
354
+ * All the free variables in the expression, recursively,
355
+ * that is all the symbols with no value
356
+ */
357
+ readonly freeVars: string[];
356
358
  /** All the `["Error"]` subexpressions
357
359
  *
358
360
  * **Note** applicable to canonical and non-canonical expressions.
@@ -1022,7 +1024,7 @@ export interface ExpressionMapInterface<U> {
1022
1024
  * - Functions and symbols exported from a library should start with an uppercase letter `/^[A-Z]/`
1023
1025
  *
1024
1026
  */
1025
- export type IDTable = {
1027
+ export type IdTable = {
1026
1028
  [id: string]: SymbolDefinition | FunctionDefinition;
1027
1029
  };
1028
1030
  /**
@@ -1050,33 +1052,30 @@ export type RuntimeIdentifierTable = Map<string, BoxedSymbolDefinition | BoxedFu
1050
1052
  *
1051
1053
  */
1052
1054
  export type Scope = {
1053
- /** This handler is invoked when exiting this scope if there are any
1054
- * warnings pending. */
1055
- warn?: WarningSignalHandler;
1056
1055
  /** Signal `timeout` when the execution time for this scope is exceeded.
1057
1056
  * Time in seconds, default 2s.
1058
1057
  *
1059
1058
  * @experimental
1060
1059
  */
1061
- timeLimit?: number;
1060
+ timeLimit: number;
1062
1061
  /** Signal `out-of-memory` when the memory usage for this scope is exceeded.
1063
1062
  * Memory in Megabytes, default: 1Mb.
1064
1063
  *
1065
1064
  * @experimental
1066
1065
  */
1067
- memoryLimit?: number;
1066
+ memoryLimit: number;
1068
1067
  /** Signal `recursion-depth-exceeded` when the recursion depth for this
1069
1068
  * scope is exceeded.
1070
1069
  *
1071
1070
  * @experimental
1072
1071
  */
1073
- recursionLimit?: number;
1072
+ recursionLimit: number;
1074
1073
  /** Signal `iteration-limit-exceeded` when the iteration limit for this
1075
1074
  * scope is exceeded. Default: no limits.
1076
1075
  *
1077
1076
  * @experimental
1078
1077
  */
1079
- iterationLimit?: number;
1078
+ iterationLimit: number;
1080
1079
  };
1081
1080
  export type RuntimeScope = Scope & {
1082
1081
  parentScope?: RuntimeScope;
@@ -1090,8 +1089,6 @@ export type RuntimeScope = Scope & {
1090
1089
  };
1091
1090
  /** Free memory should not go below this level for execution to proceed */
1092
1091
  lowWaterMark?: number;
1093
- /** Set when one or more warnings have been signaled in this scope */
1094
- warnings?: WarningSignal[];
1095
1092
  };
1096
1093
  export type BaseDefinition = {
1097
1094
  /** A short (about 1 line) description. May contain Markdown. */
@@ -1468,10 +1465,10 @@ export type SymbolAttributes = {
1468
1465
 
1469
1466
  | Operation | `"never"` | `"simplify"` | `"evaluate"` | `"N"` |
1470
1467
  | :--- | :----- |
1471
- | `canonical()`| {% icon "circle-check" "green-700" %} | | | |
1472
- | `simplify()` | {% icon "circle-check" "green-700" %} | {% icon "circle-check" "green-700" %} | | |
1473
- | `evaluate()` | {% icon "circle-check" "green-700" %} | {% icon "circle-check" "green-700" %} | {% icon "circle-check" "green-700" %} | |
1474
- | `"N()"` | {% icon "circle-check" "green-700" %} | {% icon "circle-check" "green-700" %} | {% icon "circle-check" "green-700" %} | {% icon "circle-check" "green-700" %} |
1468
+ | `canonical()`| (X) | | | |
1469
+ | `simplify()` | (X) | (X) | | |
1470
+ | `evaluate()` | (X) | (X) | (X) | |
1471
+ | `"N()"` | (X) | (X) | (X) | (X) |
1475
1472
 
1476
1473
  </div>
1477
1474
 
@@ -1569,7 +1566,7 @@ export interface IComputeEngine {
1569
1566
  chop(n: Complex): Complex | 0;
1570
1567
  chop(n: number | Decimal | Complex): number | Decimal | Complex;
1571
1568
  /** @internal */
1572
- bignum: (a: Decimal.Value) => Decimal;
1569
+ bignum: (a: Decimal.Value | bigint) => Decimal;
1573
1570
  /** @internal */
1574
1571
  complex: (a: number | Complex, b?: number) => Complex;
1575
1572
  set precision(p: number | 'machine');
@@ -1604,8 +1601,9 @@ export interface IComputeEngine {
1604
1601
  box(expr: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression, options?: {
1605
1602
  canonical?: boolean;
1606
1603
  }): BoxedExpression;
1604
+ canonical(xs: SemiBoxedExpression[]): BoxedExpression[];
1607
1605
  /** Return a boxed number */
1608
- number(value: number | string | MathJsonNumber | Decimal | Complex | [num: number, denom: number] | [num: Decimal, denom: Decimal], options?: {
1606
+ number(value: number | bigint | string | MathJsonNumber | Decimal | Complex | Rational, options?: {
1609
1607
  metadata?: Metadata;
1610
1608
  canonical?: boolean;
1611
1609
  }): BoxedExpression;
@@ -1667,23 +1665,23 @@ export interface IComputeEngine {
1667
1665
  *
1668
1666
  * The result is canonical.
1669
1667
  */
1670
- power(base: BoxedExpression, exponent: number | Rational | BoxedExpression, metadata?: Metadata): BoxedExpression;
1668
+ pow(base: BoxedExpression, exponent: number | Rational | BoxedExpression, metadata?: Metadata): BoxedExpression;
1671
1669
  sqrt(base: BoxedExpression, metadata?: Metadata): any;
1672
1670
  /** Shortcut for `this.fn("Divide", [1, expr])`
1673
1671
  *
1674
1672
  * The result is canonical.
1675
1673
  */
1676
- inverse(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
1674
+ inv(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
1677
1675
  /** Shortcut for `this.fn("Negate", [expr])`
1678
1676
  *
1679
1677
  * The result is canonical.
1680
1678
  */
1681
- negate(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
1679
+ neg(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
1682
1680
  /** Shortcut for `this.fn("Divide", [num, denom])`
1683
1681
  *
1684
1682
  * The result is canonical.
1685
1683
  */
1686
- divide(num: BoxedExpression, denom: BoxedExpression, metadata?: Metadata): BoxedExpression;
1684
+ div(num: BoxedExpression, denom: BoxedExpression, metadata?: Metadata): BoxedExpression;
1687
1685
  /** Shortcut for `this.fn("Pair"...)`
1688
1686
  *
1689
1687
  * The result is canonical.
@@ -1730,16 +1728,12 @@ export interface IComputeEngine {
1730
1728
  /** {@inheritDoc JsonSerializationOptions} */
1731
1729
  get jsonSerializationOptions(): Readonly<JsonSerializationOptions>;
1732
1730
  set jsonSerializationOptions(val: Partial<JsonSerializationOptions>);
1733
- pushScope(symbolTable?: Readonly<IDTable> | Readonly<IDTable>[], scope?: Partial<Scope>): void;
1731
+ pushScope(identifiers?: Readonly<IdTable> | Readonly<IdTable>[], scope?: Partial<Scope>): void;
1734
1732
  popScope(): void;
1735
1733
  /** Assign a value to an identifier in the current scope. Use `null` to reset the identifier to no value */
1736
- set(identifiers: {
1737
- [identifier: string]: SemiBoxedExpression | null;
1738
- }): void;
1739
- /** Declare identifiers (specify their domain without necessarily assigning them a value in the current scope*/
1740
- let(identifiers: {
1741
- [identifier: string]: SymbolDefinition | FunctionDefinition;
1742
- }): void;
1734
+ set(identifiers: Substitution<SemiBoxedExpression | null | undefined>): void;
1735
+ /** Declare identifiers (specify their domain without necessarily assigning them a value in the current scope) */
1736
+ let(identifiers: IdTable): void;
1743
1737
  /**
1744
1738
  * Add an assumption.
1745
1739
  *
@@ -1762,16 +1756,6 @@ export interface IComputeEngine {
1762
1756
  forget(symbol?: string | string[]): void;
1763
1757
  get assumptions(): ExpressionMapInterface<boolean>;
1764
1758
  ask(pattern: LatexString | SemiBoxedExpression): BoxedSubstitution[];
1765
- /**
1766
- * When `condition` is false, signal.
1767
- *
1768
- * - `condition` - If `true`, do nothing. If `false`, signal.
1769
- *
1770
- * @experimental
1771
- */
1772
- assert(condition: boolean, expr: BoxedExpression, msg: string, code?: SignalMessage): any;
1773
- signal(expr: BoxedExpression, msg: string, code?: SignalMessage): void;
1774
- signal(sig: WarningSignal): void;
1775
1759
  /** @internal */
1776
1760
  shouldContinueExecution(): boolean;
1777
1761
  /** @internal */
@@ -1,4 +1,4 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
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.11.0 */
1
+ /* 0.12.1 */
2
2
  /**
3
3
  * A set of simplification rules.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
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.11.0 */
1
+ /* 0.12.1 */
2
2
  /**
3
3
  * Return the expansion of ['Multiply', lhs, rhs]
4
4
  * - lhs = 'a + b', rhs = '2'
@@ -1,8 +1,9 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  /**
3
3
  * Flatten the arguments.
4
4
  * If `expr` was canonical, the result it canonical.
5
5
  */
6
6
  export declare function flatten(expr: BoxedExpression, head: string): BoxedExpression;
7
- export declare function flattenOps(ops: BoxedExpression[], head: string): BoxedExpression[] | null;
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,12 +1,10 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  /**
3
3
  * Distribute `Negate` (multiply by -1) if expr is a number literal, an
4
- * addition or another `Negate`.
4
+ * addition or multiplication or another `Negate`.
5
5
  *
6
- * This is appropriate to call during a `canonical` chain.
7
- *
8
- * For more thorough distribution (including multiplication), see `distributeNegate`,
9
- * applicable during a `simplify` or `evaluate` chain.
6
+ * It is important to do all these to handle cases like
7
+ * `-3x` -> ["Negate, ["Multiply", 3, "x"]] -> ["Multiply, -3, x]
10
8
  */
11
9
  export declare function canonicalNegate(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
12
10
  export declare function processNegate(_ce: IComputeEngine, x: BoxedExpression, _mode?: 'simplify' | 'evaluate' | 'N'): BoxedExpression;
@@ -1,4 +1,4 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  /**
3
3
  * Coefficient of a univariate (single variable) polynomial.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  /**
3
3
  * Group terms in a product by common term.
4
4
  *
@@ -1,14 +1,15 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  export declare class Sum {
3
3
  private engine;
4
+ private _isCanonical;
4
5
  private _rational;
5
6
  private _imaginary;
6
7
  private _number;
7
8
  private _bignum;
8
9
  private _posInfinityCount;
9
10
  private _negInfinityCount;
11
+ private _naNCount;
10
12
  private _terms;
11
- private _isCanonical;
12
13
  constructor(ce: IComputeEngine, xs?: BoxedExpression[], options?: {
13
14
  canonical?: boolean;
14
15
  });
@@ -1,4 +1,4 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { BoxedExpression, Rational } from '../public';
4
4
  /**
@@ -1,4 +1,3 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
+ export declare const version = "0.12.1";
2
3
  export { ComputeEngine } from './compute-engine/compute-engine';
3
- export declare const version = "0.11.0";
4
- export { getVars } from './compute-engine/boxed-expression/utils';
@@ -1,4 +1,4 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
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,5 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
2
+ export declare function isNumberExpression(expr: Expression | null): expr is number | string | MathJsonNumber;
2
3
  export declare function isNumberObject(expr: Expression | null): expr is MathJsonNumber;
3
4
  export declare function isSymbolObject(expr: Expression | null): expr is MathJsonSymbol;
4
5
  export declare function isStringObject(expr: Expression | null): expr is MathJsonString;
@@ -1,4 +1,3 @@
1
- /* 0.11.0 */
1
+ /* 0.12.1 */
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 type { LatexToken, ParseHandler, SerializeHandler, LatexDictionaryEntry, LatexDictionary, ParseLatexOptions, SerializeLatexOptions, NumberFormattingOptions, } from './compute-engine/latex-syntax/public';
4
- export declare const version = "0.11.0";
3
+ export declare const version = "0.12.1";
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.11.0",
2
+ "version": "0.12.1",
3
3
  "scripts": {
4
4
  "build": "bash ./scripts/build.sh",
5
5
  "clean": "bash ./scripts/clean.sh",