@cortex-js/compute-engine 0.52.0 → 0.53.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 (229) hide show
  1. package/README.md +2 -4
  2. package/dist/compute-engine.esm.js +1404 -3552
  3. package/dist/compute-engine.min.esm.js +110 -2331
  4. package/dist/compute-engine.min.umd.js +110 -2331
  5. package/dist/compute-engine.umd.js +1403 -3551
  6. package/dist/math-json.esm.js +2 -2
  7. package/dist/math-json.min.esm.js +2 -2
  8. package/dist/math-json.min.umd.js +2 -2
  9. package/dist/math-json.umd.js +2 -2
  10. package/dist/types/common/ansi-codes.d.ts +1 -1
  11. package/dist/types/common/configuration-change.d.ts +1 -1
  12. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  13. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  14. package/dist/types/common/interruptible.d.ts +1 -1
  15. package/dist/types/common/one-of.d.ts +1 -1
  16. package/dist/types/common/signals.d.ts +1 -1
  17. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  18. package/dist/types/common/type/boxed-type.d.ts +1 -1
  19. package/dist/types/common/type/lexer.d.ts +1 -1
  20. package/dist/types/common/type/parse.d.ts +1 -1
  21. package/dist/types/common/type/parser.d.ts +1 -1
  22. package/dist/types/common/type/primitive.d.ts +1 -1
  23. package/dist/types/common/type/reduce.d.ts +1 -1
  24. package/dist/types/common/type/serialize.d.ts +1 -1
  25. package/dist/types/common/type/subtype.d.ts +1 -1
  26. package/dist/types/common/type/type-builder.d.ts +1 -1
  27. package/dist/types/common/type/types.d.ts +1 -1
  28. package/dist/types/common/type/utils.d.ts +1 -1
  29. package/dist/types/common/utils.d.ts +1 -1
  30. package/dist/types/compute-engine/assume.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +7 -2
  32. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  33. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  34. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  35. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  36. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  37. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  38. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  39. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +3 -4
  40. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +4 -2
  41. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  42. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  43. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  44. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +10 -11
  45. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  46. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +8 -4
  47. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  50. package/dist/types/compute-engine/boxed-expression/compare.d.ts +2 -2
  51. package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/expand.d.ts +3 -3
  53. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  54. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  71. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  72. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  73. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  74. package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
  75. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  76. package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
  77. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  78. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  79. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  80. package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
  81. package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
  82. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  83. package/dist/types/compute-engine/compilation/gpu-target.d.ts +14 -2
  84. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  85. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  86. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  87. package/dist/types/compute-engine/compilation/types.d.ts +3 -9
  88. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  89. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  90. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  91. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  92. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  93. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  94. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  95. package/dist/types/compute-engine/engine-declarations.d.ts +1 -2
  96. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +2 -2
  97. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  98. package/dist/types/compute-engine/engine-latex-dictionary-state.d.ts +1 -1
  99. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  100. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  101. package/dist/types/compute-engine/engine-parse-entrypoint.d.ts +1 -1
  102. package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
  103. package/dist/types/compute-engine/engine-scope.d.ts +1 -4
  104. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  105. package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
  106. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  107. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  108. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  109. package/dist/types/compute-engine/free-functions.d.ts +3 -3
  110. package/dist/types/compute-engine/function-utils.d.ts +34 -15
  111. package/dist/types/compute-engine/global-types.d.ts +1 -1
  112. package/dist/types/compute-engine/index.d.ts +5 -26
  113. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  114. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  115. package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
  116. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  117. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  118. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  119. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  120. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  121. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  122. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  123. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  124. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  125. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  126. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  127. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  128. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  129. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  130. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  131. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  132. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  133. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  134. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  135. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
  136. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  137. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  138. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  139. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  140. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  141. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  142. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  143. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  144. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  145. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  146. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  147. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  148. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  149. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  150. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  151. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  152. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  153. package/dist/types/compute-engine/library/core.d.ts +1 -1
  154. package/dist/types/compute-engine/library/fractals.d.ts +2 -0
  155. package/dist/types/compute-engine/library/library.d.ts +1 -1
  156. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  157. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  158. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  159. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  160. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  161. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  162. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  163. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  164. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  165. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  166. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  167. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  168. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  169. package/dist/types/compute-engine/library/units.d.ts +1 -1
  170. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  171. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  172. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  173. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  174. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  175. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  176. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  177. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  178. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  179. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  180. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  181. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  182. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  183. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  184. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  185. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  186. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  187. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  188. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  189. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  190. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  191. package/dist/types/compute-engine/oeis.d.ts +1 -1
  192. package/dist/types/compute-engine/sequence.d.ts +1 -1
  193. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  194. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  195. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  196. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  197. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  198. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  199. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  200. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  201. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  202. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  203. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  204. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  205. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  206. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  207. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  208. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  209. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  210. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  211. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  212. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  213. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  214. package/dist/types/compute-engine/types-definitions.d.ts +6 -7
  215. package/dist/types/compute-engine/types-engine.d.ts +1 -9
  216. package/dist/types/compute-engine/types-evaluation.d.ts +2 -2
  217. package/dist/types/compute-engine/types-expression.d.ts +58 -8
  218. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +5 -8
  219. package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
  220. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  221. package/dist/types/compute-engine/types.d.ts +1 -1
  222. package/dist/types/compute-engine.d.ts +1 -3
  223. package/dist/types/math-json/symbols.d.ts +1 -1
  224. package/dist/types/math-json/types.d.ts +1 -1
  225. package/dist/types/math-json/utils.d.ts +1 -1
  226. package/dist/types/math-json.d.ts +2 -2
  227. package/package.json +18 -18
  228. package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +0 -51
  229. package/dist/types/compute-engine/compilation/interval-wgsl-target.d.ts +0 -54
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  import type { Type, TypeString } from '../common/type/types';
3
3
  import type { BoxedType } from '../common/type/boxed-type';
4
4
  import type { LatexString, LatexDictionaryEntry } from './latex-syntax/types';
@@ -14,7 +14,7 @@ import type { EvaluateOptions as KernelEvaluateOptions, Rule as KernelRule, Boxe
14
14
  */
15
15
  export interface ComputeEngine {
16
16
  }
17
- type EvaluateOptions = KernelEvaluateOptions<Expression>;
17
+ type EvaluateOptions = KernelEvaluateOptions;
18
18
  type Rule = KernelRule<Expression, ExpressionInput, ComputeEngine>;
19
19
  type BoxedRule = KernelBoxedRule<Expression, ComputeEngine>;
20
20
  type BoxedRuleSet = KernelBoxedRuleSet<Expression, ComputeEngine>;
@@ -723,12 +723,11 @@ export interface BoxedValueDefinition extends BoxedBaseDefinition {
723
723
  * **Default:** `evaluate`
724
724
  */
725
725
  holdUntil: 'never' | 'evaluate' | 'N';
726
- /** This is either the initial value of the symbol (i.e. when a new
727
- * evaluation context is created), or its constant value, if a constant.
728
- * Otherwise, the current value is tracked in the evaluation context.
729
- *
726
+ /** The current value of the symbol. For constants, this is immutable.
727
+ * The definition object is the single source of truth there is no
728
+ * separate evaluation-context values map.
730
729
  */
731
- readonly value: Expression | undefined;
730
+ value: Expression | undefined;
732
731
  eq?: (a: Expression) => boolean | undefined;
733
732
  neq?: (a: Expression) => boolean | undefined;
734
733
  cmp?: (a: Expression) => '=' | '>' | '<' | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  import type { OneOf } from '../common/one-of';
3
3
  import type { MathJsonSymbol, MathJsonNumberObject } from '../math-json';
4
4
  import type { Type, TypeString, TypeResolver } from '../common/type/types';
@@ -219,16 +219,8 @@ export interface IComputeEngine extends IBigNum {
219
219
  * Use `ce.assign(id, value)` instead.
220
220
  * @internal */
221
221
  _setSymbolValue(id: MathJsonSymbol, value: Expression | boolean | number | undefined): void;
222
- /**
223
- * Set a value directly in the current context's values map.
224
- * Used for assumptions so values are properly scoped.
225
- * @internal */
226
- _setCurrentContextValue(id: MathJsonSymbol, value: Expression | boolean | number | undefined): void;
227
222
  /** A list of the function calls to the current evaluation context */
228
223
  trace: ReadonlyArray<string>;
229
- lookupContext(id: MathJsonSymbol): undefined | EvalContext;
230
- /** @internal */
231
- _swapContext(context: EvalContext): void;
232
224
  lookupDefinition(id: MathJsonSymbol): undefined | BoxedDefinition;
233
225
  assign(ids: {
234
226
  [id: MathJsonSymbol]: AssignValue;
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  import type { IComputeEngine as ComputeEngine } from './types-engine';
3
3
  import type { Expression, ExpressionInput } from './types-expression';
4
4
  import type { Assumption as KernelAssumption, AssumeResult, AssignValue as KernelAssignValue, BoxedRule as KernelBoxedRule, BoxedRuleSet as KernelBoxedRuleSet, EvaluateOptions as KernelEvaluateOptions, EvalContext as KernelEvalContext, ExpressionMapInterface as KernelExpressionMapInterface, Rule as KernelRule, RuleConditionFunction as KernelRuleConditionFunction, RuleFunction as KernelRuleFunction, RuleReplaceFunction as KernelRuleReplaceFunction, RuleStep as KernelRuleStep, RuleSteps as KernelRuleSteps, Scope as KernelScope } from './types-kernel-evaluation';
@@ -10,7 +10,7 @@ export type { AssumeResult };
10
10
  *
11
11
  * @category Boxed Expression
12
12
  */
13
- export type EvaluateOptions = KernelEvaluateOptions<Expression>;
13
+ export type EvaluateOptions = KernelEvaluateOptions;
14
14
  /**
15
15
  * Map-like interface keyed by boxed expressions.
16
16
  *
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  import type { OneOf } from '../common/one-of';
3
3
  import type { MathJsonExpression, MathJsonNumberObject, MathJsonStringObject, MathJsonSymbolObject, MathJsonFunctionObject, MathJsonSymbol, MathJsonDictionaryObject } from '../math-json';
4
4
  import type { Type, TypeString } from '../common/type/types';
@@ -47,7 +47,7 @@ interface BoxedBaseDefinition extends Partial<BaseDefinition> {
47
47
  }
48
48
  interface BoxedValueDefinition extends BoxedBaseDefinition {
49
49
  holdUntil: 'never' | 'evaluate' | 'N';
50
- readonly value: Expression | undefined;
50
+ value: Expression | undefined;
51
51
  eq?: (a: Expression) => boolean | undefined;
52
52
  neq?: (a: Expression) => boolean | undefined;
53
53
  cmp?: (a: Expression) => '=' | '>' | '<' | undefined;
@@ -103,7 +103,7 @@ type BoxedDefinition = {
103
103
  operator: BoxedOperatorDefinition;
104
104
  };
105
105
  type Scope = KernelScope<BoxedDefinition>;
106
- type EvaluateOptions = KernelEvaluateOptions<Expression>;
106
+ type EvaluateOptions = KernelEvaluateOptions;
107
107
  type Rule = KernelRule<Expression, ExpressionInput, ExpressionComputeEngine>;
108
108
  type BoxedRule = KernelBoxedRule<Expression, ExpressionComputeEngine>;
109
109
  type BoxedRuleSet = KernelBoxedRuleSet<Expression, ExpressionComputeEngine>;
@@ -868,6 +868,44 @@ export interface Expression {
868
868
  * Return this expression expressed as a numerator and denominator.
869
869
  */
870
870
  get numeratorDenominator(): [Expression, Expression];
871
+ /**
872
+ * Return the value of this expression as a pair of integer numerator and
873
+ * denominator, or `null` if the expression is not a rational number.
874
+ *
875
+ * - For a `BoxedNumber` with an exact rational value, extracts from the
876
+ * numeric representation.
877
+ * - For an integer, returns `[n, 1]`.
878
+ * - For a `Divide` or `Rational` function with integer operands, returns
879
+ * `[num, den]`.
880
+ * - For everything else, returns `null`.
881
+ *
882
+ * The returned rational is always in lowest terms.
883
+ *
884
+ * ```typescript
885
+ * ce.parse('\\frac{6}{4}').toRational() // [3, 2]
886
+ * ce.parse('7').toRational() // [7, 1]
887
+ * ce.parse('x + 1').toRational() // null
888
+ * ce.number(1.5).toRational() // null (machine float)
889
+ * ```
890
+ */
891
+ toRational(): [number, number] | null;
892
+ /**
893
+ * Return the multiplicative factors of this expression as a flat array.
894
+ *
895
+ * This is a structural decomposition — it does not perform algebraic
896
+ * factoring (use `ce.function('Factor', [expr])` for that).
897
+ *
898
+ * - `Multiply(a, b, c)` returns `[a, b, c]`
899
+ * - `Negate(x)` returns `[-1, ...x.factors()]`
900
+ * - Anything else returns `[expr]`
901
+ *
902
+ * ```typescript
903
+ * ce.parse('2xyz').factors() // [2, x, y, z]
904
+ * ce.parse('-3x').factors() // [-1, 3, x]
905
+ * ce.parse('x + 1').factors() // [x + 1]
906
+ * ```
907
+ */
908
+ factors(): ReadonlyArray<Expression>;
871
909
  /**
872
910
  * The name of the operator of the expression.
873
911
  *
@@ -1000,24 +1038,35 @@ export interface Expression {
1000
1038
  isSame(rhs: Expression | number | bigint | boolean | string): boolean;
1001
1039
  /**
1002
1040
  * Smart equality check: structural first, then numeric evaluation fallback.
1041
+ * Symmetric: `a.is(b)` always equals `b.is(a)`.
1003
1042
  *
1004
1043
  * First tries an exact structural check (same as `isSame()`). If that fails
1005
1044
  * and the expression is constant (no free variables), evaluates numerically
1006
1045
  * and compares within `engine.tolerance`.
1007
1046
  *
1008
- * For literal numbers (`BoxedNumber`), behaves identically to `isSame()` —
1009
- * no tolerance is applied. Tolerance only applies to expressions that
1010
- * require evaluation (e.g., `\\sin(\\pi)`).
1047
+ * For literal numbers compared to primitives (`number`, `bigint`), behaves
1048
+ * identically to `isSame()` — no tolerance is applied. Tolerance only
1049
+ * applies to expressions that require evaluation (e.g., `\\sin(\\pi)`).
1011
1050
  *
1012
1051
  * ```typescript
1013
1052
  * ce.parse('\\cos(\\frac{\\pi}{2})').is(0) // true — evaluates, within tolerance
1014
1053
  * ce.number(1e-17).is(0) // false — literal, no tolerance
1015
- * ce.parse('x + 1').is(1) // false — not constant
1054
+ * ce.parse('x + 1').is(1) // false — has free variables
1055
+ * ce.parse('\\pi').is(3.14, 0.01) // true — within custom tolerance
1016
1056
  * ```
1017
1057
  *
1058
+ * After the structural check, attempts to expand both sides (distributing
1059
+ * products, applying the multinomial theorem, etc.) and re-checks
1060
+ * structural equality. This catches equivalences like `(x+1)^2` vs
1061
+ * `x^2+2x+1` even when the expression has free variables.
1062
+ *
1063
+ * @param tolerance - If provided, overrides `engine.tolerance` for the
1064
+ * numeric comparison. Has no effect when the comparison is structural
1065
+ * (i.e., when `isSame()` succeeds or the expression has free variables).
1066
+ *
1018
1067
  * @category Primitive Methods
1019
1068
  */
1020
- is(other: Expression | number | bigint | boolean | string): boolean;
1069
+ is(other: Expression | number | bigint | boolean | string, tolerance?: number): boolean;
1021
1070
  /**
1022
1071
  * If this expression matches `pattern`, return a substitution that makes
1023
1072
  * `pattern` equal to `this`. Otherwise return `null`.
@@ -1568,6 +1617,7 @@ export interface Expression {
1568
1617
  */
1569
1618
  export interface NumberLiteralInterface {
1570
1619
  readonly numericValue: number | NumericValue;
1620
+ readonly isExact: boolean;
1571
1621
  readonly isNumberLiteral: true;
1572
1622
  }
1573
1623
  /**
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  import type { TypeReference } from '../common/type/types';
3
3
  import type { BoxedType } from '../common/type/boxed-type';
4
4
  import type { LatexString } from './latex-syntax/types';
@@ -43,7 +43,7 @@ export type AssumeResult = 'internal-error' | 'not-a-predicate' | 'contradiction
43
43
  *
44
44
  * @category Boxed Expression
45
45
  */
46
- export type EvaluateOptions<Expr = unknown> = {
46
+ export type EvaluateOptions = {
47
47
  /**
48
48
  * If `true`, the evaluation returns a numeric approximation of the expression,
49
49
  * when possible.
@@ -69,10 +69,6 @@ export type EvaluateOptions<Expr = unknown> = {
69
69
  materialization: boolean | number | [number, number];
70
70
  /** Cancellation signal for long-running evaluations. */
71
71
  signal: AbortSignal;
72
- /**
73
- * Temporary named argument bindings used while evaluating this expression.
74
- */
75
- withArguments: Record<MathJsonSymbol, Expr>;
76
72
  };
77
73
  /**
78
74
  * Given an expression and set of wildcards, return a replacement expression.
@@ -146,7 +142,7 @@ export type BoxedRuleSet<Expr = unknown, CE = unknown> = {
146
142
  *
147
143
  * @category Compute Engine
148
144
  */
149
- export type AssignValue<Expr = unknown, SemiExpr = unknown, CE = unknown> = boolean | number | bigint | SemiExpr | ((args: ReadonlyArray<Expr>, options: EvaluateOptions<Expr> & {
145
+ export type AssignValue<Expr = unknown, SemiExpr = unknown, CE = unknown> = boolean | number | bigint | SemiExpr | ((args: ReadonlyArray<Expr>, options: EvaluateOptions & {
150
146
  engine: CE;
151
147
  }) => Expr) | undefined;
152
148
  /** @category Definitions */
@@ -154,11 +150,12 @@ export type Scope<Binding = unknown> = {
154
150
  parent: Scope<Binding> | null;
155
151
  bindings: Map<string, Binding>;
156
152
  types?: Record<string, TypeReference>;
153
+ /** When true, auto-declarations during canonicalization are promoted to parent scope. */
154
+ noAutoDeclare?: boolean;
157
155
  };
158
156
  /** @category Compute Engine */
159
157
  export type EvalContext<Expr = unknown, Binding = unknown> = {
160
158
  lexicalScope: Scope<Binding>;
161
159
  assumptions: ExpressionMapInterface<boolean, Expr>;
162
- values: Record<string, Expr | undefined>;
163
160
  name: undefined | string;
164
161
  };
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  export type Hold = 'none' | 'all' | 'first' | 'rest' | 'last' | 'most';
3
3
  /**
4
4
  * Options to control serialization to MathJSON when using
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  import type { BoxedSubstitution as KernelBoxedSubstitution, CanonicalForm, CanonicalOptions, FormOption, Hold, JsonSerializationOptions, Metadata, PatternMatchOptions as KernelPatternMatchOptions, ReplaceOptions, Substitution as KernelSubstitution } from './types-kernel-serialization';
3
3
  export type { Hold, JsonSerializationOptions, ReplaceOptions, CanonicalForm, CanonicalOptions, FormOption, Metadata, };
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  export type { MathJsonExpression, MathJsonAttributes, MathJsonNumberObject, MathJsonSymbolObject, MathJsonStringObject, MathJsonFunctionObject, DictionaryValue, MathJsonDictionaryObject, ExpressionObject, MathJsonSymbol, } from '../math-json/types';
3
3
  export * from '../common/type/boxed-type';
4
4
  export * from '../common/type/types';
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  export { ComputeEngine } from './compute-engine/index';
3
3
  export type * from './compute-engine/types';
4
4
  export type { CompileTarget, CompiledOperators, CompiledFunctions, CompilationOptions, CompilationResult, ExecutableTarget, ComplexResult, CompiledRunner, ExpressionRunner, LambdaRunner, LanguageTarget, TargetSource, CompiledFunction, } from './compute-engine/compilation/types';
@@ -8,8 +8,6 @@ export { GLSLTarget } from './compute-engine/compilation/glsl-target';
8
8
  export { WGSLTarget } from './compute-engine/compilation/wgsl-target';
9
9
  export { PythonTarget } from './compute-engine/compilation/python-target';
10
10
  export { IntervalJavaScriptTarget } from './compute-engine/compilation/interval-javascript-target';
11
- export { IntervalGLSLTarget } from './compute-engine/compilation/interval-glsl-target';
12
- export { IntervalWGSLTarget } from './compute-engine/compilation/interval-wgsl-target';
13
11
  export { BaseCompiler } from './compute-engine/compilation/base-compiler';
14
12
  export type { Interval, IntervalResult, BoolInterval, } from './compute-engine/interval/types';
15
13
  export { parse, simplify, evaluate, N, declare, assign, expand, expandAll, factor, solve, compile, getDefaultEngine, } from './compute-engine/free-functions';
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  * Return true if the string is a valid symbol.
3
3
  *
4
4
  * Check for symbols matching a profile of [Unicode UAX31](https://unicode.org/reports/tr31/)
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  * The following properties can be added to any MathJSON expression
3
3
  * to provide additional information about the expression.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  export declare const MISSING: MathJsonExpression;
3
3
  export declare function isNumberExpression(expr: MathJsonExpression | null): expr is number | string | MathJsonNumberObject;
4
4
  export declare function isNumberObject(expr: MathJsonExpression | null): expr is MathJsonNumberObject;
@@ -1,3 +1,3 @@
1
- /* 0.52.0 */
1
+ /* 0.53.0 */
2
2
  export { isSymbolObject, isStringObject, isFunctionObject, stringValue, operator, operand, symbol, mapArgs, dictionaryFromExpression, } from './math-json/utils';
3
- export declare const version = "0.52.0";
3
+ export declare const version = "0.53.0";
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.52.0",
2
+ "version": "0.53.0",
3
3
  "scripts": {
4
4
  "doc": "bash ./scripts/doc.sh",
5
5
  "build": "bash ./scripts/build.sh",
@@ -69,33 +69,33 @@
69
69
  "@cortex-js/prettier-config": "^1.2.0",
70
70
  "@jest/console": "^29.7.0",
71
71
  "@types/jest": "^29.5.5",
72
- "@types/node": "^24.0.13",
73
- "@typescript-eslint/eslint-plugin": "^7.14.1",
74
- "@typescript-eslint/parser": "^7.14.1",
75
- "@typescript-eslint/typescript-estree": "^7.14.1",
76
- "chalk": "^5.3.0",
72
+ "@types/node": "^25.3.0",
73
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
74
+ "@typescript-eslint/parser": "^8.56.0",
75
+ "@typescript-eslint/typescript-estree": "^8.56.0",
76
+ "chalk": "^5.6.2",
77
77
  "check-node-version": "^4.2.1",
78
78
  "concat-md": "^0.5.1",
79
- "esbuild": "^0.25.8",
79
+ "esbuild": "^0.27.3",
80
80
  "eslint": "^8.56.0",
81
- "eslint-config-prettier": "^9.0.0",
82
- "eslint-plugin-import": "^2.28.1",
83
- "eslint-plugin-no-unsanitized": "^4.0.2",
84
- "eslint-plugin-prettier": "^5.0.0",
81
+ "eslint-config-prettier": "^10.1.8",
82
+ "eslint-plugin-import": "^2.32.0",
83
+ "eslint-plugin-no-unsanitized": "^4.1.5",
84
+ "eslint-plugin-prettier": "^5.5.5",
85
85
  "jest": "^29.7.0",
86
86
  "jest-silent-reporter": "^0.6.0",
87
87
  "madge": "^8.0.0",
88
- "open": "^10.1.2",
89
- "prettier": "^3.6.2",
88
+ "open": "^11.0.0",
89
+ "prettier": "^3.8.1",
90
90
  "prettier-2": "npm:prettier@^2.8.8",
91
91
  "serve-http": "^1.0.7",
92
- "ts-jest": "^29.4.0",
92
+ "ts-jest": "^29.4.6",
93
93
  "ts-node": "^10.9.2",
94
- "typedoc": "^0.28.8",
95
- "typedoc-plugin-markdown": "^4.8.0",
94
+ "typedoc": "^0.28.17",
95
+ "typedoc-plugin-markdown": "^4.10.0",
96
96
  "typedoc-plugin-no-inherit": "^1.6.1",
97
- "typescript": "^5.8.3",
98
- "update-notifier": "^7.0.0"
97
+ "typescript": "^5.9.3",
98
+ "update-notifier": "^7.3.1"
99
99
  },
100
100
  "prettier": "@cortex-js/prettier-config",
101
101
  "dependencies": {
@@ -1,51 +0,0 @@
1
- /* 0.52.0 */
2
- * GLSL interval arithmetic compilation target
3
- *
4
- * Compiles mathematical expressions to GLSL code using interval arithmetic
5
- * for reliable function evaluation in shaders.
6
- *
7
- * Intervals are represented as vec2(lo, hi).
8
- * Status flags use float constants for shader compatibility.
9
- *
10
- * @module compilation/interval-glsl-target
11
- */
12
- import type { Expression } from '../global-types';
13
- import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
14
- /**
15
- * GLSL interval arithmetic target implementation.
16
- */
17
- export declare class IntervalGLSLTarget implements LanguageTarget<Expression> {
18
- getOperators(): CompiledOperators;
19
- getFunctions(): CompiledFunctions<Expression>;
20
- /**
21
- * Get the GLSL interval library code.
22
- *
23
- * This should be included in shaders that use interval arithmetic.
24
- */
25
- getLibrary(): string;
26
- createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
27
- compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult<'interval-glsl'>;
28
- /**
29
- * Compile an expression to GLSL interval code string.
30
- */
31
- compileToSource(expr: Expression, _options?: CompilationOptions<Expression>): string;
32
- /**
33
- * Create a complete GLSL interval function from an expression.
34
- *
35
- * @param expr - The expression to compile
36
- * @param functionName - Name of the GLSL function
37
- * @param parameters - Parameter names (each becomes a vec2 interval input)
38
- */
39
- compileFunction(expr: Expression, functionName: string, parameters: string[]): string;
40
- /**
41
- * Create a complete GLSL fragment shader for interval function plotting.
42
- *
43
- * @param expr - The expression to compile
44
- * @param options - Shader options
45
- */
46
- compileShaderFunction(expr: Expression, options?: {
47
- functionName?: string;
48
- version?: string;
49
- parameters?: string[];
50
- }): string;
51
- }
@@ -1,54 +0,0 @@
1
- /* 0.52.0 */
2
- * WGSL interval arithmetic compilation target
3
- *
4
- * Compiles mathematical expressions to WGSL code using interval arithmetic
5
- * for reliable function evaluation in WebGPU shaders.
6
- *
7
- * Intervals are represented as vec2f(lo, hi).
8
- * Status flags use f32 constants for shader compatibility.
9
- *
10
- * Since WGSL does not support function overloading, internal vec2f-parameter
11
- * implementations use a `_v` suffix (e.g., `ia_add_v`), while the public
12
- * IntervalResult wrappers keep the base name (e.g., `ia_add`).
13
- *
14
- * @module compilation/interval-wgsl-target
15
- */
16
- import type { Expression } from '../global-types';
17
- import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
18
- /**
19
- * WGSL interval arithmetic target implementation.
20
- */
21
- export declare class IntervalWGSLTarget implements LanguageTarget<Expression> {
22
- getOperators(): CompiledOperators;
23
- getFunctions(): CompiledFunctions<Expression>;
24
- /**
25
- * Get the WGSL interval library code.
26
- *
27
- * This should be included in shaders that use interval arithmetic.
28
- */
29
- getLibrary(): string;
30
- createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
31
- compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult<'interval-wgsl'>;
32
- /**
33
- * Compile an expression to WGSL interval code string.
34
- */
35
- compileToSource(expr: Expression, _options?: CompilationOptions<Expression>): string;
36
- /**
37
- * Create a complete WGSL interval function from an expression.
38
- *
39
- * @param expr - The expression to compile
40
- * @param functionName - Name of the WGSL function
41
- * @param parameters - Parameter names (each becomes a vec2f interval input)
42
- */
43
- compileFunction(expr: Expression, functionName: string, parameters: string[]): string;
44
- /**
45
- * Create a complete WGSL compute shader for interval function evaluation.
46
- *
47
- * @param expr - The expression to compile
48
- * @param options - Shader options
49
- */
50
- compileShaderFunction(expr: Expression, options?: {
51
- functionName?: string;
52
- parameters?: string[];
53
- }): string;
54
- }