@cortex-js/compute-engine 0.52.0 → 0.52.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 (228) hide show
  1. package/README.md +2 -4
  2. package/dist/compute-engine.esm.js +607 -68
  3. package/dist/compute-engine.min.esm.js +103 -75
  4. package/dist/compute-engine.min.umd.js +104 -76
  5. package/dist/compute-engine.umd.js +607 -68
  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 +2 -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 +1 -1
  40. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +3 -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 +2 -2
  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 +1 -1
  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 +1 -1
  51. package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  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 +2 -2
  84. package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +1 -1
  85. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  86. package/dist/types/compute-engine/compilation/interval-wgsl-target.d.ts +1 -1
  87. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  88. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  89. package/dist/types/compute-engine/compilation/types.d.ts +1 -1
  90. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  91. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  92. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  93. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  94. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  95. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  96. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  97. package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
  98. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
  99. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  100. package/dist/types/compute-engine/engine-latex-dictionary-state.d.ts +1 -1
  101. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  102. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  103. package/dist/types/compute-engine/engine-parse-entrypoint.d.ts +1 -1
  104. package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
  105. package/dist/types/compute-engine/engine-scope.d.ts +1 -1
  106. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  107. package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
  108. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  109. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  110. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  111. package/dist/types/compute-engine/free-functions.d.ts +1 -1
  112. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  113. package/dist/types/compute-engine/global-types.d.ts +1 -1
  114. package/dist/types/compute-engine/index.d.ts +1 -1
  115. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  116. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  117. package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
  118. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  119. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  120. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  121. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  122. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  123. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  124. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  125. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  126. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  127. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  128. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  129. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  130. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  131. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  132. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  133. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  134. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  135. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  136. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  137. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
  138. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  139. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  140. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  141. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  142. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  143. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  144. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  145. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  146. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  147. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  148. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  149. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  150. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  151. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  152. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  153. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  154. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  155. package/dist/types/compute-engine/library/core.d.ts +1 -1
  156. package/dist/types/compute-engine/library/library.d.ts +1 -1
  157. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  158. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  159. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  160. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  161. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  162. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  163. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  164. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  165. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  166. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  167. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  168. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  169. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  170. package/dist/types/compute-engine/library/units.d.ts +1 -1
  171. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  172. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  173. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  174. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  175. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  176. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  177. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  178. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  179. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  180. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  181. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  182. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  183. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  184. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  185. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  186. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  187. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  188. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  189. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  190. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  191. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  192. package/dist/types/compute-engine/oeis.d.ts +1 -1
  193. package/dist/types/compute-engine/sequence.d.ts +1 -1
  194. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  195. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  196. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  197. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  198. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  199. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  200. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  201. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  202. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  203. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  204. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  205. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  206. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  207. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  208. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  209. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  210. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  211. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  212. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  213. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  214. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  215. package/dist/types/compute-engine/types-definitions.d.ts +1 -1
  216. package/dist/types/compute-engine/types-engine.d.ts +1 -1
  217. package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
  218. package/dist/types/compute-engine/types-expression.d.ts +9 -3
  219. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
  220. package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
  221. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  222. package/dist/types/compute-engine/types.d.ts +1 -1
  223. package/dist/types/compute-engine.d.ts +1 -1
  224. package/dist/types/math-json/symbols.d.ts +1 -1
  225. package/dist/types/math-json/types.d.ts +1 -1
  226. package/dist/types/math-json/utils.d.ts +1 -1
  227. package/dist/types/math-json.d.ts +2 -2
  228. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.52.0 */
1
+ /** Compute Engine 0.52.1 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComputeEngine = {}));})(this, (function (exports) { 'use strict';
3
3
  var ComputeEngine = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -8194,6 +8194,58 @@ var ComputeEngine = (() => {
8194
8194
  }
8195
8195
 
8196
8196
  // src/compute-engine/latex-syntax/tokenizer.ts
8197
+ var UNICODE_SUPERSCRIPT_MAP = {
8198
+ "\u2070": "0",
8199
+ // ⁰
8200
+ "\xB9": "1",
8201
+ // ¹
8202
+ "\xB2": "2",
8203
+ // ²
8204
+ "\xB3": "3",
8205
+ // ³
8206
+ "\u2074": "4",
8207
+ // ⁴
8208
+ "\u2075": "5",
8209
+ // ⁵
8210
+ "\u2076": "6",
8211
+ // ⁶
8212
+ "\u2077": "7",
8213
+ // ⁷
8214
+ "\u2078": "8",
8215
+ // ⁸
8216
+ "\u2079": "9",
8217
+ // ⁹
8218
+ "\u207B": "-",
8219
+ // ⁻
8220
+ "\u2071": "i",
8221
+ // ⁱ
8222
+ "\u207F": "n"
8223
+ // ⁿ
8224
+ };
8225
+ var UNICODE_SUBSCRIPT_MAP = {
8226
+ "\u2080": "0",
8227
+ // ₀
8228
+ "\u2081": "1",
8229
+ // ₁
8230
+ "\u2082": "2",
8231
+ // ₂
8232
+ "\u2083": "3",
8233
+ // ₃
8234
+ "\u2084": "4",
8235
+ // ₄
8236
+ "\u2085": "5",
8237
+ // ₅
8238
+ "\u2086": "6",
8239
+ // ₆
8240
+ "\u2087": "7",
8241
+ // ₇
8242
+ "\u2088": "8",
8243
+ // ₈
8244
+ "\u2089": "9",
8245
+ // ₉
8246
+ "\u208B": "-"
8247
+ // ₋
8248
+ };
8197
8249
  var Tokenizer = class {
8198
8250
  s;
8199
8251
  pos;
@@ -8201,6 +8253,14 @@ var ComputeEngine = (() => {
8201
8253
  constructor(s) {
8202
8254
  s = s.replace(/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/g, "");
8203
8255
  s = s.replace(/\u2212/g, "-");
8256
+ s = s.replace(/[⁰¹²³⁴⁵⁶⁷⁸⁹⁻ⁱⁿ]+/g, (m) => {
8257
+ const digits = Array.from(m).map((c) => UNICODE_SUPERSCRIPT_MAP[c]).join("");
8258
+ return `^{${digits}}`;
8259
+ });
8260
+ s = s.replace(/[₀₁₂₃₄₅₆₇₈₉₋]+/g, (m) => {
8261
+ const digits = Array.from(m).map((c) => UNICODE_SUBSCRIPT_MAP[c]).join("");
8262
+ return `_{${digits}}`;
8263
+ });
8204
8264
  this.s = splitGraphemes(s);
8205
8265
  this.pos = 0;
8206
8266
  }
@@ -9398,6 +9458,7 @@ var ComputeEngine = (() => {
9398
9458
  result.push("Nothing");
9399
9459
  parser.skipSpace();
9400
9460
  }
9461
+ parser.skipVisualSpace();
9401
9462
  if (parser.atTerminator(terminator)) {
9402
9463
  result.push("Nothing");
9403
9464
  } else {
@@ -9408,6 +9469,7 @@ var ComputeEngine = (() => {
9408
9469
  if (!done) {
9409
9470
  parser.skipSpace();
9410
9471
  done = !parser.match(sep);
9472
+ if (!done) parser.skipVisualSpace();
9411
9473
  }
9412
9474
  }
9413
9475
  return result;
@@ -9977,7 +10039,7 @@ var ComputeEngine = (() => {
9977
10039
  const args = operands(expr);
9978
10040
  if (!args || args.length === 0) return "";
9979
10041
  const parts = args.filter((a) => operator(a) !== "Declare").map((a) => serializer.serialize(a));
9980
- return parts.join(";\\; ");
10042
+ return parts.join("; ");
9981
10043
  }
9982
10044
  },
9983
10045
  // Serializer for If expressions (separate from the parser entry
@@ -10764,6 +10826,7 @@ var ComputeEngine = (() => {
10764
10826
  // '⎿': '', // U+23BF RIGHT PARENTHESIS LOWER HOOK
10765
10827
  };
10766
10828
  function parseAssign(parser, lhs, until) {
10829
+ const isLocalBindingContext = (until?.minPrec ?? 0) >= 19;
10767
10830
  const lhsSymbol = symbol(lhs);
10768
10831
  if (lhsSymbol && lhsSymbol.includes("_")) {
10769
10832
  const underscoreIndex = lhsSymbol.indexOf("_");
@@ -10771,7 +10834,10 @@ var ComputeEngine = (() => {
10771
10834
  const subscriptStr = lhsSymbol.substring(underscoreIndex + 1);
10772
10835
  const subscriptNum = parseInt(subscriptStr, 10);
10773
10836
  const subscript = !isNaN(subscriptNum) && String(subscriptNum) === subscriptStr ? subscriptNum : subscriptStr;
10774
- lhs = ["Subscript", baseName, subscript];
10837
+ const simpleSequenceLikeSubscript = subscript !== "" && (typeof subscript === "number" || typeof subscript === "string" && subscript.length === 1);
10838
+ if (parser.getSymbolType(baseName).matches("indexed_collection") || !isLocalBindingContext && simpleSequenceLikeSubscript) {
10839
+ lhs = ["Subscript", baseName, subscript];
10840
+ }
10775
10841
  }
10776
10842
  if (operator(lhs) === "InvisibleOperator" && nops(lhs) === 2 && operator(operand(lhs, 2)) === "Delimiter") {
10777
10843
  const fn2 = symbol(operand(lhs, 1));
@@ -10786,7 +10852,15 @@ var ComputeEngine = (() => {
10786
10852
  }
10787
10853
  if (operator(lhs) === "Subscript" && symbol(operand(lhs, 1))) {
10788
10854
  const fn2 = symbol(operand(lhs, 1));
10789
- if (!fn2) return null;
10855
+ if (!parser.getSymbolType(fn2).matches("indexed_collection")) {
10856
+ const sub4 = operand(lhs, 2);
10857
+ const subStr = (sub4 !== null && typeof sub4 === "string" ? sub4 : void 0) ?? (sub4 !== null && typeof sub4 === "number" ? String(sub4) : void 0);
10858
+ if (subStr && isLocalBindingContext) {
10859
+ const rhs3 = parser.parseExpression({ ...until ?? {}, minPrec: 20 });
10860
+ if (rhs3 === null) return null;
10861
+ return ["Assign", fn2 + "_" + subStr, rhs3];
10862
+ }
10863
+ }
10790
10864
  const rhs2 = parser.parseExpression({ ...until ?? {}, minPrec: 20 });
10791
10865
  if (rhs2 === null) return null;
10792
10866
  const sub3 = operand(lhs, 2);
@@ -10867,6 +10941,7 @@ var ComputeEngine = (() => {
10867
10941
  }
10868
10942
  function matchKeyword(parser, keyword) {
10869
10943
  const start = parser.index;
10944
+ parser.skipVisualSpace();
10870
10945
  if (parser.match("\\text")) {
10871
10946
  if (matchTextKeyword(parser, keyword)) return true;
10872
10947
  parser.index = start;
@@ -10884,18 +10959,21 @@ var ComputeEngine = (() => {
10884
10959
  return result;
10885
10960
  }
10886
10961
  function parseIfExpression(parser, until) {
10962
+ parser.skipVisualSpace();
10887
10963
  const condition = parser.parseExpression({
10888
10964
  minPrec: 0,
10889
10965
  condition: (p) => peekKeyword(p, "then")
10890
10966
  });
10891
10967
  if (condition === null) return null;
10892
10968
  if (!matchKeyword(parser, "then")) return null;
10969
+ parser.skipVisualSpace();
10893
10970
  const trueBranch = parser.parseExpression({
10894
10971
  minPrec: 0,
10895
10972
  condition: (p) => peekKeyword(p, "else")
10896
10973
  });
10897
10974
  if (trueBranch === null) return null;
10898
10975
  if (!matchKeyword(parser, "else")) return null;
10976
+ parser.skipVisualSpace();
10899
10977
  const falseBranch = parser.parseExpression(until) ?? "Nothing";
10900
10978
  return ["If", condition, trueBranch, falseBranch];
10901
10979
  }
@@ -10950,11 +11028,12 @@ var ComputeEngine = (() => {
10950
11028
  if (bindings.length === 0) return null;
10951
11029
  const block = [];
10952
11030
  for (const b of bindings) {
10953
- if (operator(b) === "Assign") {
10954
- block.push(["Declare", operand(b, 1)]);
10955
- block.push(b);
11031
+ const normalized = normalizeLocalAssign(b);
11032
+ if (operator(normalized) === "Assign") {
11033
+ block.push(["Declare", operand(normalized, 1)]);
11034
+ block.push(normalized);
10956
11035
  } else {
10957
- block.push(b);
11036
+ block.push(normalized);
10958
11037
  }
10959
11038
  }
10960
11039
  block.push(lhs);
@@ -10963,13 +11042,25 @@ var ComputeEngine = (() => {
10963
11042
  function buildBlockFromSequence(seq) {
10964
11043
  const block = [];
10965
11044
  for (const s of seq) {
10966
- if (operator(s) === "Assign") {
10967
- block.push(["Declare", operand(s, 1)]);
11045
+ const normalized = normalizeLocalAssign(s);
11046
+ if (operator(normalized) === "Assign") {
11047
+ block.push(["Declare", operand(normalized, 1)]);
10968
11048
  }
10969
- block.push(s);
11049
+ block.push(normalized);
10970
11050
  }
10971
11051
  return ["Block", ...block];
10972
11052
  }
11053
+ function normalizeLocalAssign(expr) {
11054
+ if (operator(expr) !== "Assign") return expr;
11055
+ const lhs = operand(expr, 1);
11056
+ if (operator(lhs) !== "Subscript") return expr;
11057
+ const base = symbol(operand(lhs, 1));
11058
+ if (!base) return expr;
11059
+ const sub3 = operand(lhs, 2);
11060
+ const subStr = (typeof sub3 === "string" ? sub3 : void 0) ?? (typeof sub3 === "number" ? String(sub3) : void 0);
11061
+ if (!subStr) return expr;
11062
+ return ["Assign", `${base}_${subStr}`, operand(expr, 2) ?? "Nothing"];
11063
+ }
10973
11064
  function parseAt(...close) {
10974
11065
  return (parser, lhs) => {
10975
11066
  if (!symbol(lhs) && operator(lhs) !== "List") return null;
@@ -12426,14 +12517,14 @@ var ComputeEngine = (() => {
12426
12517
  get numeratorDenominator() {
12427
12518
  return [this, this.engine.One];
12428
12519
  }
12429
- is(other) {
12520
+ is(other, tolerance) {
12430
12521
  if (this.isSame(other)) return true;
12431
- if (!this.isConstant) return false;
12522
+ if (this.freeVariables.length > 0) return false;
12432
12523
  if (typeof other === "number" || typeof other === "bigint") {
12433
12524
  const n = this.N();
12434
12525
  if (n === this) return false;
12435
12526
  if (!isNumber(n)) return false;
12436
- const tol = this.engine.tolerance;
12527
+ const tol = tolerance ?? this.engine.tolerance;
12437
12528
  const nRe = n.re;
12438
12529
  const nIm = n.im;
12439
12530
  if (typeof other === "number") {
@@ -12444,11 +12535,11 @@ var ComputeEngine = (() => {
12444
12535
  return Math.abs(nRe - Number(other)) <= tol && Math.abs(nIm) <= tol;
12445
12536
  }
12446
12537
  if (other instanceof __BoxedExpression) {
12447
- if (!other.isConstant) return false;
12538
+ if (other.freeVariables.length > 0) return false;
12448
12539
  const nThis = this.N();
12449
12540
  const nOther = other.N();
12450
12541
  if (!isNumber(nThis) || !isNumber(nOther)) return false;
12451
- const tol = this.engine.tolerance;
12542
+ const tol = tolerance ?? this.engine.tolerance;
12452
12543
  return Math.abs(nThis.re - nOther.re) <= tol && Math.abs(nThis.im - nOther.im) <= tol;
12453
12544
  }
12454
12545
  return false;
@@ -12829,7 +12920,6 @@ var ComputeEngine = (() => {
12829
12920
  if (def.neq) this.neq = def.neq;
12830
12921
  if (def.cmp) this.cmp = def.cmp;
12831
12922
  if (def.collection) {
12832
- if (name === "Take") debugger;
12833
12923
  this.collection = defaultCollectionHandlers(def.collection);
12834
12924
  }
12835
12925
  if (def.subscriptEvaluate) this.subscriptEvaluate = def.subscriptEvaluate;
@@ -13009,7 +13099,8 @@ var ComputeEngine = (() => {
13009
13099
  if (expr.re === 0) return ce.number(expr.im);
13010
13100
  if (isFunction2(expr, "Negate")) return getImaginaryFactor(expr.op1)?.neg();
13011
13101
  if (isFunction2(expr, "Complex")) {
13012
- if (expr.op1.isSame(0) && !isNaN(expr.op2.re)) return ce.number(expr.op2.re);
13102
+ if (expr.op1.isSame(0) && !isNaN(expr.op2.re))
13103
+ return ce.number(expr.op2.re);
13013
13104
  return void 0;
13014
13105
  }
13015
13106
  if (isFunction2(expr, "Multiply") && expr.nops === 2) {
@@ -23477,6 +23568,7 @@ ${lines.join("\n")}`;
23477
23568
  // Functions
23478
23569
  //
23479
23570
  Abs: {
23571
+ description: "Absolute value (magnitude) of a number.",
23480
23572
  wikidata: "Q3317982",
23481
23573
  // magnitude 'Q120812 (for reals)
23482
23574
  broadcastable: true,
@@ -23492,6 +23584,7 @@ ${lines.join("\n")}`;
23492
23584
  evaluate: ([x]) => evaluateAbs(x)
23493
23585
  },
23494
23586
  Add: {
23587
+ description: "Sum of two or more values.",
23495
23588
  wikidata: "Q32043",
23496
23589
  associative: true,
23497
23590
  commutative: true,
@@ -23546,6 +23639,7 @@ ${lines.join("\n")}`;
23546
23639
  )
23547
23640
  },
23548
23641
  Chop: {
23642
+ description: "Replace tiny numeric values with zero.",
23549
23643
  associative: true,
23550
23644
  broadcastable: true,
23551
23645
  idempotent: true,
@@ -23569,6 +23663,7 @@ ${lines.join("\n")}`;
23569
23663
  // complexity: 500,
23570
23664
  // },
23571
23665
  Divide: {
23666
+ description: "Quotient of a numerator and one or more denominators.",
23572
23667
  wikidata: "Q1226939",
23573
23668
  complexity: 2500,
23574
23669
  broadcastable: true,
@@ -23617,6 +23712,7 @@ ${lines.join("\n")}`;
23617
23712
  }
23618
23713
  },
23619
23714
  Exp: {
23715
+ description: "Natural exponential function: e^x.",
23620
23716
  wikidata: "Q168698",
23621
23717
  broadcastable: true,
23622
23718
  complexity: 3500,
@@ -23726,6 +23822,7 @@ ${lines.join("\n")}`;
23726
23822
  }
23727
23823
  },
23728
23824
  Floor: {
23825
+ description: "Rounds a number down to the nearest integer.",
23729
23826
  wikidata: "Q56860783",
23730
23827
  complexity: 1250,
23731
23828
  broadcastable: true,
@@ -23765,6 +23862,7 @@ ${lines.join("\n")}`;
23765
23862
  )
23766
23863
  },
23767
23864
  Gamma: {
23865
+ description: "Gamma function, extending factorial to complex numbers.",
23768
23866
  wikidata: "Q190573",
23769
23867
  complexity: 8e3,
23770
23868
  broadcastable: true,
@@ -23779,6 +23877,7 @@ ${lines.join("\n")}`;
23779
23877
  ) : void 0
23780
23878
  },
23781
23879
  GammaLn: {
23880
+ description: "Natural logarithm of the gamma function.",
23782
23881
  complexity: 8e3,
23783
23882
  broadcastable: true,
23784
23883
  signature: "(number) -> number",
@@ -24050,6 +24149,7 @@ ${lines.join("\n")}`;
24050
24149
  )
24051
24150
  },
24052
24151
  Multiply: {
24152
+ description: "Product of two or more values.",
24053
24153
  wikidata: "Q40276",
24054
24154
  associative: true,
24055
24155
  commutative: true,
@@ -24146,6 +24246,7 @@ ${lines.join("\n")}`;
24146
24246
  evaluate: ([x, y], { engine }) => engine.tuple(x.add(y.neg()), x.add(y))
24147
24247
  },
24148
24248
  Power: {
24249
+ description: "Exponentiation: raise a base to a power.",
24149
24250
  wikidata: "Q33456",
24150
24251
  broadcastable: true,
24151
24252
  complexity: 3500,
@@ -24204,6 +24305,7 @@ ${lines.join("\n")}`;
24204
24305
  // https://proofwiki.org/wiki/Square_Root_of_Prime_is_Irrational
24205
24306
  },
24206
24307
  Rational: {
24308
+ description: "Construct a rational number from a numerator and denominator.",
24207
24309
  complexity: 2400,
24208
24310
  signature: "(number, integer?) -> rational",
24209
24311
  sgn: ([n]) => n.sgn,
@@ -24240,6 +24342,7 @@ ${lines.join("\n")}`;
24240
24342
  }
24241
24343
  },
24242
24344
  Root: {
24345
+ description: "n-th root of a value.",
24243
24346
  complexity: 3200,
24244
24347
  broadcastable: true,
24245
24348
  signature: "(number, number) -> number",
@@ -24300,6 +24403,7 @@ ${lines.join("\n")}`;
24300
24403
  )
24301
24404
  },
24302
24405
  Round: {
24406
+ description: "Rounds a number to the nearest integer.",
24303
24407
  complexity: 1250,
24304
24408
  broadcastable: true,
24305
24409
  signature: "(number) -> integer",
@@ -24329,6 +24433,7 @@ ${lines.join("\n")}`;
24329
24433
  },
24330
24434
  /** Heaviside step function: H(x) = 0 for x < 0, 1/2 for x = 0, 1 for x > 0 */
24331
24435
  Heaviside: {
24436
+ description: "Heaviside step function.",
24332
24437
  complexity: 1200,
24333
24438
  broadcastable: true,
24334
24439
  signature: "(number) -> real",
@@ -24342,6 +24447,7 @@ ${lines.join("\n")}`;
24342
24447
  }
24343
24448
  },
24344
24449
  Sign: {
24450
+ description: "Sign of a number: -1, 0, or 1.",
24345
24451
  complexity: 1200,
24346
24452
  broadcastable: true,
24347
24453
  signature: "(number) -> integer",
@@ -24413,6 +24519,7 @@ ${lines.join("\n")}`;
24413
24519
  // https://proofwiki.org/wiki/Square_Root_of_Prime_is_Irrational
24414
24520
  },
24415
24521
  Square: {
24522
+ description: "Square of a number: x^2.",
24416
24523
  wikidata: "Q3075175",
24417
24524
  complexity: 3100,
24418
24525
  broadcastable: true,
@@ -24435,6 +24542,7 @@ ${lines.join("\n")}`;
24435
24542
  }
24436
24543
  },
24437
24544
  Subtract: {
24545
+ description: "Difference between two or more values.",
24438
24546
  wikidata: "Q40754",
24439
24547
  complexity: 1350,
24440
24548
  broadcastable: true,
@@ -24609,9 +24717,11 @@ ${lines.join("\n")}`;
24609
24717
  },
24610
24718
  {
24611
24719
  PreIncrement: {
24720
+ description: "Increment a number by one.",
24612
24721
  signature: "(number) -> number"
24613
24722
  },
24614
24723
  PreDecrement: {
24724
+ description: "Decrement a number by one.",
24615
24725
  signature: "(number) -> number"
24616
24726
  }
24617
24727
  },
@@ -29153,6 +29263,7 @@ ${e.message}
29153
29263
  // with values of the order that can be either fractional or negative
29154
29264
  //
29155
29265
  Derivative: {
29266
+ description: "Derivative operator that returns a derivative function.",
29156
29267
  broadcastable: false,
29157
29268
  lazy: true,
29158
29269
  signature: "(function, order:number?) -> function",
@@ -29180,6 +29291,7 @@ ${e.message}
29180
29291
  //
29181
29292
  // This is equivalent to `["Apply", ["Derivative", "Sin"], "x"]`
29182
29293
  D: {
29294
+ description: "Symbolic partial derivative with respect to one or more variables.",
29183
29295
  broadcastable: false,
29184
29296
  scoped: true,
29185
29297
  lazy: true,
@@ -29224,6 +29336,7 @@ ${e.message}
29224
29336
  },
29225
29337
  // Evaluate a numerical approximation of a derivative at point x
29226
29338
  ND: {
29339
+ description: "Numerical derivative evaluated at a point.",
29227
29340
  broadcastable: false,
29228
29341
  lazy: true,
29229
29342
  signature: "(function, at:number) -> number",
@@ -29242,6 +29355,7 @@ ${e.message}
29242
29355
  }
29243
29356
  },
29244
29357
  Integrate: {
29358
+ description: "Symbolic integral with optional bounds.",
29245
29359
  wikidata: "Q80091",
29246
29360
  broadcastable: false,
29247
29361
  lazy: true,
@@ -29322,6 +29436,7 @@ ${e.message}
29322
29436
  }
29323
29437
  },
29324
29438
  NIntegrate: {
29439
+ description: "Numerical approximation of a definite integral.",
29325
29440
  broadcastable: false,
29326
29441
  lazy: true,
29327
29442
  signature: "(function, limits:(tuple|symbol)?) -> number",
@@ -33166,6 +33281,7 @@ ${e.message}
33166
33281
  var CONTROL_STRUCTURES_LIBRARY = [
33167
33282
  {
33168
33283
  Block: {
33284
+ description: "Evaluate a sequence of expressions in a local scope.",
33169
33285
  lazy: true,
33170
33286
  scoped: true,
33171
33287
  signature: "(unknown*) -> unknown",
@@ -33179,6 +33295,7 @@ ${e.message}
33179
33295
  // A condition expression tests for one or more conditions of an expression
33180
33296
  // ['Condition', value, "positive"]
33181
33297
  Condition: {
33298
+ description: "Test whether a value satisfies one or more conditions.",
33182
33299
  lazy: true,
33183
33300
  signature: "(value, symbol) -> boolean",
33184
33301
  evaluate: ([value, conds], { engine }) => {
@@ -33193,6 +33310,7 @@ ${e.message}
33193
33310
  }
33194
33311
  },
33195
33312
  If: {
33313
+ description: "Conditional branch: evaluate one of two expressions.",
33196
33314
  lazy: true,
33197
33315
  signature: "(expression, expression, expression) -> any",
33198
33316
  type: ([_cond, ifTrue, ifFalse]) => widen(ifTrue.type.type, ifFalse.type.type),
@@ -33209,6 +33327,7 @@ ${e.message}
33209
33327
  }
33210
33328
  },
33211
33329
  Loop: {
33330
+ description: "Evaluate a body expression over elements of a collection.",
33212
33331
  lazy: true,
33213
33332
  signature: "(body:expression, collection:expression) -> any",
33214
33333
  type: ([body]) => body.type,
@@ -33216,6 +33335,7 @@ ${e.message}
33216
33335
  evaluateAsync: async ([body, collection], { engine: ce, signal }) => runAsync(runLoop(body, collection, ce), ce._timeRemaining, signal)
33217
33336
  },
33218
33337
  Which: {
33338
+ description: "Return the value for the first condition that is true.",
33219
33339
  lazy: true,
33220
33340
  signature: "(expression+) -> unknown",
33221
33341
  type: (args) => {
@@ -33233,7 +33353,11 @@ ${e.message}
33233
33353
  },
33234
33354
  evaluate: (ops, options) => evaluateWhich(ops, options)
33235
33355
  },
33236
- FixedPoint: { lazy: true, signature: "(any) -> unknown" }
33356
+ FixedPoint: {
33357
+ description: "Iterate a function until a fixed point is reached.",
33358
+ lazy: true,
33359
+ signature: "(any) -> unknown"
33360
+ }
33237
33361
  }
33238
33362
  ];
33239
33363
  function evaluateWhich(args, options) {
@@ -33313,6 +33437,7 @@ ${e.message}
33313
33437
  var COMBINATORICS_LIBRARY = [
33314
33438
  {
33315
33439
  Choose: {
33440
+ description: "Binomial coefficient: number of ways to choose k items from n.",
33316
33441
  complexity: 1200,
33317
33442
  signature: "(n:number, m:number) -> number",
33318
33443
  type: () => "finite_integer",
@@ -33570,6 +33695,7 @@ ${e.message}
33570
33695
  var COMPLEX_LIBRARY = [
33571
33696
  {
33572
33697
  Real: {
33698
+ description: "Real part of a complex number.",
33573
33699
  // @todo: could be extended to return an expression, i.e. ["Real", ["Add", "x", ["Complex", 0, 5]]] -> "x". Not for any operator, but at least for Add, Multiply, Negate, etc.
33574
33700
  broadcastable: true,
33575
33701
  complexity: 1200,
@@ -33589,6 +33715,7 @@ ${e.message}
33589
33715
  }
33590
33716
  },
33591
33717
  Imaginary: {
33718
+ description: "Imaginary part of a complex number.",
33592
33719
  broadcastable: true,
33593
33720
  complexity: 1200,
33594
33721
  signature: "(number) -> real",
@@ -33607,6 +33734,7 @@ ${e.message}
33607
33734
  }
33608
33735
  },
33609
33736
  Argument: {
33737
+ description: "Complex argument (phase angle) of a number.",
33610
33738
  broadcastable: true,
33611
33739
  complexity: 1200,
33612
33740
  signature: "(number) -> real",
@@ -33621,6 +33749,7 @@ ${e.message}
33621
33749
  },
33622
33750
  // For Abs (magnitude) see src/compute-engine/library/processAbs
33623
33751
  AbsArg: {
33752
+ description: "Tuple of magnitude and argument of a complex number.",
33624
33753
  broadcastable: true,
33625
33754
  complexity: 1200,
33626
33755
  signature: "(number) -> tuple<real, real>",
@@ -33633,6 +33762,7 @@ ${e.message}
33633
33762
  }
33634
33763
  },
33635
33764
  Conjugate: {
33765
+ description: "Complex conjugate of a number.",
33636
33766
  broadcastable: true,
33637
33767
  complexity: 1200,
33638
33768
  signature: "(number) -> number",
@@ -33646,6 +33776,7 @@ ${e.message}
33646
33776
  }
33647
33777
  },
33648
33778
  ComplexRoots: {
33779
+ description: "All n-th complex roots of a number.",
33649
33780
  broadcastable: true,
33650
33781
  complexity: 1200,
33651
33782
  signature: "(number, number) -> list<number>",
@@ -34597,6 +34728,7 @@ ${e.message}
34597
34728
  *
34598
34729
  */
34599
34730
  InvisibleOperator: {
34731
+ description: "Implicit operator used for juxtapositions such as function application or multiplication.",
34600
34732
  complexity: 9e3,
34601
34733
  lazy: true,
34602
34734
  signature: "function",
@@ -34611,6 +34743,7 @@ ${e.message}
34611
34743
  },
34612
34744
  /** See above for a theory of operations */
34613
34745
  Sequence: {
34746
+ description: "Ordered sequence of expressions.",
34614
34747
  lazy: true,
34615
34748
  signature: "function",
34616
34749
  type: (args) => {
@@ -34627,6 +34760,7 @@ ${e.message}
34627
34760
  },
34628
34761
  /** See above for a theory of operations */
34629
34762
  Delimiter: {
34763
+ description: "Group expressions with explicit delimiters.",
34630
34764
  // Use to represent groups of expressions.
34631
34765
  // Named after https://en.wikipedia.org/wiki/Delimiter
34632
34766
  complexity: 9e3,
@@ -34669,6 +34803,7 @@ ${e.message}
34669
34803
  }
34670
34804
  },
34671
34805
  Error: {
34806
+ description: "Represent an error expression.",
34672
34807
  /**
34673
34808
  * - The first argument is either a string or an `["ErrorCode"]`
34674
34809
  * expression indicating the nature of the error.
@@ -34683,6 +34818,7 @@ ${e.message}
34683
34818
  canonical: (args, { engine: ce }) => ce._fn("Error", args)
34684
34819
  },
34685
34820
  ErrorCode: {
34821
+ description: "Structured error code with optional arguments.",
34686
34822
  complexity: 500,
34687
34823
  lazy: true,
34688
34824
  signature: "(string, any*) -> error",
@@ -34739,6 +34875,7 @@ ${e.message}
34739
34875
  }
34740
34876
  },
34741
34877
  HorizontalSpacing: {
34878
+ description: "Horizontal spacing annotation.",
34742
34879
  signature: "(number) -> nothing",
34743
34880
  canonical: (args, { engine: ce }) => {
34744
34881
  if (args.length === 2) return args[0].canonical;
@@ -34746,6 +34883,7 @@ ${e.message}
34746
34883
  }
34747
34884
  },
34748
34885
  Annotated: {
34886
+ description: "Attach metadata or style annotations to an expression.",
34749
34887
  signature: "(expression, dictionary) -> expression",
34750
34888
  type: ([x]) => x.type,
34751
34889
  complexity: 9e3,
@@ -34947,6 +35085,7 @@ ${e.message}
34947
35085
  evaluate: (ops, { engine: ce }) => ce.symbol(ce.assume(ops[0]))
34948
35086
  },
34949
35087
  Declare: {
35088
+ description: "Declare a symbol and optionally assign a type.",
34950
35089
  lazy: true,
34951
35090
  pure: false,
34952
35091
  signature: "(symbol, type: string | symbol) -> nothing",
@@ -34977,11 +35116,13 @@ ${e.message}
34977
35116
  },
34978
35117
  /** Return the type of an expression */
34979
35118
  Type: {
35119
+ description: "Return the type of an expression as a string.",
34980
35120
  lazy: true,
34981
35121
  signature: "(any) -> string",
34982
35122
  evaluate: ([x], { engine: ce }) => ce.string(x.type.toString() ?? "unknown")
34983
35123
  },
34984
35124
  Evaluate: {
35125
+ description: "Evaluate an expression.",
34985
35126
  lazy: true,
34986
35127
  signature: "(any) -> unknown",
34987
35128
  type: ([x]) => x.type,
@@ -34991,6 +35132,7 @@ ${e.message}
34991
35132
  // Evaluate an expression at a specific point, potentially symbolically
34992
35133
  // i.e. it's the `f|_{a}` notation
34993
35134
  EvaluateAt: {
35135
+ description: "Evaluate a function at one point or between two bounds.",
34994
35136
  lazy: true,
34995
35137
  signature: "(function, lower:number, upper:number) -> number",
34996
35138
  type: ([x]) => functionResult(x.type.type) ?? "number",
@@ -35018,6 +35160,7 @@ ${e.message}
35018
35160
  }
35019
35161
  },
35020
35162
  BuiltinFunction: {
35163
+ description: "Return a built-in function symbol by name.",
35021
35164
  complexity: 9876,
35022
35165
  lazy: true,
35023
35166
  signature: "(symbol | string) -> symbol",
@@ -35037,6 +35180,7 @@ ${e.message}
35037
35180
  }
35038
35181
  },
35039
35182
  Rule: {
35183
+ description: "Pattern replacement rule.",
35040
35184
  lazy: true,
35041
35185
  signature: "(match: expression, replace: expression, predicate: function?) -> expression",
35042
35186
  evaluate: ([_match, _replace, _predicate], { engine: _ce }) => {
@@ -35044,6 +35188,7 @@ ${e.message}
35044
35188
  }
35045
35189
  },
35046
35190
  Simplify: {
35191
+ description: "Simplify an expression.",
35047
35192
  lazy: true,
35048
35193
  signature: "(any) -> expression",
35049
35194
  canonical: (ops, { engine: ce }) => ce._fn("Simplify", checkArity(ce, ops, 1)),
@@ -35112,6 +35257,7 @@ ${e.message}
35112
35257
  },
35113
35258
  // @todo: need review
35114
35259
  Signature: {
35260
+ description: "Return the signature string of an operator.",
35115
35261
  lazy: true,
35116
35262
  signature: "(symbol) -> string | nothing",
35117
35263
  evaluate: ([x], { engine: ce }) => {
@@ -35120,6 +35266,7 @@ ${e.message}
35120
35266
  }
35121
35267
  },
35122
35268
  Subscript: {
35269
+ description: "Subscript notation for indexing or compound symbols.",
35123
35270
  /**
35124
35271
  * The `Subscript` function can take several forms:
35125
35272
  *
@@ -35290,6 +35437,7 @@ ${e.message}
35290
35437
  //
35291
35438
  {
35292
35439
  Wildcard: {
35440
+ description: "Single-expression pattern wildcard.",
35293
35441
  signature: "(symbol) -> symbol",
35294
35442
  canonical: (args, { engine: ce }) => {
35295
35443
  if (args.length !== 1) return ce.symbol("_");
@@ -35297,6 +35445,7 @@ ${e.message}
35297
35445
  }
35298
35446
  },
35299
35447
  WildcardSequence: {
35448
+ description: "Pattern wildcard matching one or more expressions.",
35300
35449
  signature: "(symbol) -> symbol",
35301
35450
  canonical: (args, { engine: ce }) => {
35302
35451
  if (args.length !== 1) return ce.symbol("__");
@@ -35304,6 +35453,7 @@ ${e.message}
35304
35453
  }
35305
35454
  },
35306
35455
  WildcardOptionalSequence: {
35456
+ description: "Pattern wildcard matching zero or more expressions.",
35307
35457
  signature: "(symbol) -> symbol",
35308
35458
  canonical: (args, { engine: ce }) => {
35309
35459
  if (args.length !== 1) return ce.symbol("___");
@@ -35524,6 +35674,7 @@ ${e.message}
35524
35674
  },
35525
35675
  {
35526
35676
  RandomExpression: {
35677
+ description: "Generate a random expression.",
35527
35678
  signature: "() -> expression",
35528
35679
  evaluate: (_ops, { engine }) => engine.box(randomExpression())
35529
35680
  }
@@ -35534,6 +35685,7 @@ ${e.message}
35534
35685
  var LINEAR_ALGEBRA_LIBRARY = [
35535
35686
  {
35536
35687
  Matrix: {
35688
+ description: "Matrix constructor and canonicalizer.",
35537
35689
  complexity: 9e3,
35538
35690
  lazy: true,
35539
35691
  signature: "(matrix, string?, string?) -> matrix",
@@ -35544,6 +35696,7 @@ ${e.message}
35544
35696
  // Vector is a specialized collection to represent a column vector.
35545
35697
  // ["Vector", a, b, c] is a shorthand for ["List", ["List", a], ["List", b], ["List", c]]
35546
35698
  Vector: {
35699
+ description: "Construct a column vector.",
35547
35700
  complexity: 9e3,
35548
35701
  lazy: true,
35549
35702
  signature: "(number+) -> vector",
@@ -35564,6 +35717,7 @@ ${e.message}
35564
35717
  {
35565
35718
  // Corresponds to monadic Shape `⍴` in APL
35566
35719
  Shape: {
35720
+ description: "Return the shape tuple of an expression.",
35567
35721
  complexity: 8200,
35568
35722
  signature: "(value) -> tuple",
35569
35723
  evaluate: ([xs], { engine: ce }) => ce.tuple(...xs.shape)
@@ -35578,6 +35732,7 @@ ${e.message}
35578
35732
  // Corresponds to ArrayReshape in Mathematica
35579
35733
  // and dyadic Shape `⍴` in APL
35580
35734
  Reshape: {
35735
+ description: "Reshape a tensor or collection to a target shape.",
35581
35736
  complexity: 8200,
35582
35737
  signature: "(value, tuple) -> value",
35583
35738
  type: ([value, shape]) => {
@@ -35622,6 +35777,7 @@ ${e.message}
35622
35777
  // Corresponds to Ravel `,` in APL
35623
35778
  // Also Enlist `∊``⍋` in APL
35624
35779
  Flatten: {
35780
+ description: "Flatten a tensor or collection into a list.",
35625
35781
  complexity: 8200,
35626
35782
  signature: "(value) -> list",
35627
35783
  evaluate: (ops, { engine: ce }) => {
@@ -35641,6 +35797,7 @@ ${e.message}
35641
35797
  // Ex: Transpose([[a, b, c], [1, 2, 3]]) = [[a, 1], [b, 2], [c, 3]]
35642
35798
  // For rank > 2: Default swaps last two axes, or specify explicit axes
35643
35799
  Transpose: {
35800
+ description: "Transpose a matrix or swap two tensor axes.",
35644
35801
  complexity: 8200,
35645
35802
  signature: "(value, axis1: integer?, axis2: integer?) -> value",
35646
35803
  evaluate: (ops, { engine: ce }) => {
@@ -35669,6 +35826,7 @@ ${e.message}
35669
35826
  // Conjugate transpose (Hermitian adjoint): transpose + complex conjugate
35670
35827
  // For rank > 2: Default swaps last two axes, or specify explicit axes
35671
35828
  ConjugateTranspose: {
35829
+ description: "Conjugate transpose (Hermitian adjoint) of a matrix or tensor.",
35672
35830
  complexity: 8200,
35673
35831
  signature: "(value, axis1: integer?, axis2: integer?) -> value",
35674
35832
  evaluate: (ops, { engine: ce }) => {
@@ -35698,6 +35856,7 @@ ${e.message}
35698
35856
  }
35699
35857
  },
35700
35858
  Determinant: {
35859
+ description: "Determinant of a square matrix.",
35701
35860
  complexity: 8200,
35702
35861
  signature: "(matrix) -> number",
35703
35862
  evaluate: (ops, { engine: ce }) => {
@@ -35717,6 +35876,7 @@ ${e.message}
35717
35876
  }
35718
35877
  },
35719
35878
  Inverse: {
35879
+ description: "Multiplicative inverse of a square matrix.",
35720
35880
  complexity: 8200,
35721
35881
  signature: "(matrix) -> matrix",
35722
35882
  type: ([matrix]) => matrix.type,
@@ -35737,6 +35897,7 @@ ${e.message}
35737
35897
  }
35738
35898
  },
35739
35899
  PseudoInverse: {
35900
+ description: "Moore-Penrose pseudoinverse of a matrix.",
35740
35901
  complexity: 8200,
35741
35902
  signature: "(matrix) -> matrix",
35742
35903
  evaluate: ([matrix], { engine: ce }) => {
@@ -35761,6 +35922,7 @@ ${e.message}
35761
35922
  // },
35762
35923
  // },
35763
35924
  AdjugateMatrix: {
35925
+ description: "Adjugate (classical adjoint) of a square matrix.",
35764
35926
  complexity: 8200,
35765
35927
  signature: "(matrix) -> matrix",
35766
35928
  evaluate: (ops) => {
@@ -35785,6 +35947,7 @@ ${e.message}
35785
35947
  // For rank > 2 tensors: returns tensor of traces over last two axes (batch trace)
35786
35948
  // Optional axis1, axis2 to specify which axes to trace over (default: last two)
35787
35949
  Trace: {
35950
+ description: "Trace of a matrix or pair of tensor axes.",
35788
35951
  complexity: 8200,
35789
35952
  signature: "(value, axis1: integer?, axis2: integer?) -> value",
35790
35953
  evaluate: (ops, { engine: ce }) => {
@@ -35893,6 +36056,7 @@ ${e.message}
35893
36056
  // Matrix multiplication: A (m×n) × B (n×p) → result (m×p)
35894
36057
  // Handles matrix × matrix, matrix × vector, vector × matrix
35895
36058
  MatrixMultiply: {
36059
+ description: "Matrix and vector multiplication.",
35896
36060
  complexity: 8300,
35897
36061
  signature: "(matrix|vector, matrix|vector) -> matrix|vector",
35898
36062
  evaluate: (ops, { engine: ce }) => {
@@ -35978,6 +36142,7 @@ ${e.message}
35978
36142
  // 2. Extract the diagonal from a matrix as a vector
35979
36143
  // 3. For a scalar, return the scalar (or could create 1x1 matrix)
35980
36144
  Diagonal: {
36145
+ description: "Extract a matrix diagonal or build a diagonal matrix.",
35981
36146
  complexity: 8200,
35982
36147
  signature: "(value) -> value",
35983
36148
  evaluate: (ops, { engine: ce }) => {
@@ -36014,6 +36179,7 @@ ${e.message}
36014
36179
  },
36015
36180
  // Creates an n×n identity matrix
36016
36181
  IdentityMatrix: {
36182
+ description: "n-by-n identity matrix.",
36017
36183
  complexity: 8100,
36018
36184
  signature: "(integer) -> matrix",
36019
36185
  evaluate: (ops, { engine: ce }) => {
@@ -36034,6 +36200,7 @@ ${e.message}
36034
36200
  },
36035
36201
  // Creates an m×n matrix of zeros
36036
36202
  ZeroMatrix: {
36203
+ description: "Matrix filled with zeros.",
36037
36204
  complexity: 8100,
36038
36205
  signature: "(integer, integer?) -> matrix",
36039
36206
  evaluate: (ops, { engine: ce }) => {
@@ -36061,6 +36228,7 @@ ${e.message}
36061
36228
  },
36062
36229
  // Creates an m×n matrix of ones
36063
36230
  OnesMatrix: {
36231
+ description: "Matrix filled with ones.",
36064
36232
  complexity: 8100,
36065
36233
  signature: "(integer, integer?) -> matrix",
36066
36234
  evaluate: (ops, { engine: ce }) => {
@@ -36095,6 +36263,7 @@ ${e.message}
36095
36263
  // For matrices:
36096
36264
  // - Frobenius (default): √(ΣΣ|aij|²)
36097
36265
  Norm: {
36266
+ description: "Vector or matrix norm.",
36098
36267
  complexity: 8200,
36099
36268
  signature: "(value, number|string?) -> number",
36100
36269
  evaluate: (ops, { engine: ce }) => {
@@ -36216,6 +36385,7 @@ ${e.message}
36216
36385
  // For 2×2 matrices: uses characteristic polynomial (symbolic)
36217
36386
  // For larger matrices: uses QR algorithm (numeric)
36218
36387
  Eigenvalues: {
36388
+ description: "Eigenvalues of a square matrix.",
36219
36389
  complexity: 8500,
36220
36390
  signature: "(matrix) -> list",
36221
36391
  evaluate: (ops, { engine: ce }) => {
@@ -36261,6 +36431,7 @@ ${e.message}
36261
36431
  // Compute the eigenvectors of a square matrix
36262
36432
  // Returns a list of eigenvectors (as column vectors)
36263
36433
  Eigenvectors: {
36434
+ description: "Eigenvectors of a square matrix.",
36264
36435
  complexity: 8600,
36265
36436
  signature: "(matrix) -> list",
36266
36437
  evaluate: (ops, { engine: ce }) => {
@@ -36291,6 +36462,7 @@ ${e.message}
36291
36462
  // Compute both eigenvalues and eigenvectors
36292
36463
  // Returns a tuple: [eigenvalues, eigenvectors]
36293
36464
  Eigen: {
36465
+ description: "Eigenvalue-eigenvector decomposition of a square matrix.",
36294
36466
  complexity: 8700,
36295
36467
  signature: "(matrix) -> tuple",
36296
36468
  evaluate: (ops, { engine: ce }) => {
@@ -36310,6 +36482,7 @@ ${e.message}
36310
36482
  // LU Decomposition: A = LU (or PA = LU with pivoting)
36311
36483
  // Returns [L, U] for no pivoting or [P, L, U] with pivoting
36312
36484
  LUDecomposition: {
36485
+ description: "LU decomposition of a square matrix.",
36313
36486
  complexity: 8600,
36314
36487
  signature: "(matrix) -> tuple",
36315
36488
  evaluate: (ops, { engine: ce }) => {
@@ -36329,6 +36502,7 @@ ${e.message}
36329
36502
  // QR Decomposition: A = QR
36330
36503
  // Returns [Q, R] where Q is orthogonal and R is upper triangular
36331
36504
  QRDecomposition: {
36505
+ description: "QR decomposition of a matrix.",
36332
36506
  complexity: 8600,
36333
36507
  signature: "(matrix) -> tuple",
36334
36508
  evaluate: (ops, { engine: ce }) => {
@@ -36348,6 +36522,7 @@ ${e.message}
36348
36522
  // Cholesky Decomposition: A = LL^T (for positive definite matrices)
36349
36523
  // Returns L (lower triangular matrix)
36350
36524
  CholeskyDecomposition: {
36525
+ description: "Cholesky decomposition of a positive-definite matrix.",
36351
36526
  complexity: 8600,
36352
36527
  signature: "(matrix) -> matrix",
36353
36528
  evaluate: (ops, { engine: ce }) => {
@@ -36364,6 +36539,7 @@ ${e.message}
36364
36539
  // Singular Value Decomposition: A = UΣV^T
36365
36540
  // Returns [U, Σ, V] where U and V are orthogonal, Σ is diagonal
36366
36541
  SVD: {
36542
+ description: "Singular value decomposition of a matrix.",
36367
36543
  complexity: 8700,
36368
36544
  signature: "(matrix) -> tuple",
36369
36545
  evaluate: (ops, { engine: ce }) => {
@@ -39821,6 +39997,7 @@ ${e.message}
39821
39997
  var STATISTICS_LIBRARY = [
39822
39998
  {
39823
39999
  Erf: {
40000
+ description: "Gauss error function",
39824
40001
  complexity: 7500,
39825
40002
  signature: "(number) -> number",
39826
40003
  type: () => "finite_real",
@@ -39831,6 +40008,7 @@ ${e.message}
39831
40008
  }
39832
40009
  },
39833
40010
  Erfc: {
40011
+ description: "Complementary error function: 1 - Erf(x)",
39834
40012
  complexity: 7500,
39835
40013
  signature: "(number) -> number",
39836
40014
  type: () => "finite_real",
@@ -39841,6 +40019,7 @@ ${e.message}
39841
40019
  }
39842
40020
  },
39843
40021
  ErfInv: {
40022
+ description: "Inverse of the error function",
39844
40023
  complexity: 7500,
39845
40024
  signature: "(number) -> number",
39846
40025
  type: () => "finite_real",
@@ -39859,7 +40038,7 @@ ${e.message}
39859
40038
  broadcastable: false,
39860
40039
  signature: "((collection|number)+) -> number",
39861
40040
  type: () => "finite_real",
39862
- description: "The most frequently occurring value in the collection.",
40041
+ description: "Arithmetic mean of a collection of numbers.",
39863
40042
  evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
39864
40043
  const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
39865
40044
  return engine.number(
@@ -39872,7 +40051,7 @@ ${e.message}
39872
40051
  broadcastable: false,
39873
40052
  signature: "((collection|number)+) -> number",
39874
40053
  type: () => "finite_real",
39875
- description: "The most frequently occurring value in the collection.",
40054
+ description: "Median of a collection of numbers.",
39876
40055
  examples: ["Mode([1, 2, 2, 3]) // Returns 2"],
39877
40056
  evaluate: (ops, { engine, numericApproximation: numericApproximation2 }) => {
39878
40057
  const xs = ops.map((x) => x.evaluate({ numericApproximation: numericApproximation2 }));
@@ -39882,6 +40061,7 @@ ${e.message}
39882
40061
  }
39883
40062
  },
39884
40063
  Variance: {
40064
+ description: "Sample variance of a collection of numbers.",
39885
40065
  complexity: 1200,
39886
40066
  broadcastable: false,
39887
40067
  signature: "((collection|number)+) -> number",
@@ -39894,6 +40074,7 @@ ${e.message}
39894
40074
  }
39895
40075
  },
39896
40076
  PopulationVariance: {
40077
+ description: "Population variance of a collection of numbers.",
39897
40078
  complexity: 1200,
39898
40079
  broadcastable: false,
39899
40080
  signature: "((collection|number)+) -> number",
@@ -39941,6 +40122,7 @@ ${e.message}
39941
40122
  }
39942
40123
  },
39943
40124
  Kurtosis: {
40125
+ description: "Kurtosis of a collection of numbers.",
39944
40126
  complexity: 1200,
39945
40127
  broadcastable: false,
39946
40128
  signature: "((collection|number)+) -> number",
@@ -39953,6 +40135,7 @@ ${e.message}
39953
40135
  }
39954
40136
  },
39955
40137
  Skewness: {
40138
+ description: "Skewness of a collection of numbers.",
39956
40139
  complexity: 1200,
39957
40140
  broadcastable: false,
39958
40141
  signature: "((collection|number)+) -> number",
@@ -39965,6 +40148,7 @@ ${e.message}
39965
40148
  }
39966
40149
  },
39967
40150
  Mode: {
40151
+ description: "Most frequently occurring value in a collection.",
39968
40152
  complexity: 1200,
39969
40153
  broadcastable: false,
39970
40154
  signature: "((collection|number)+) -> number",
@@ -39977,6 +40161,7 @@ ${e.message}
39977
40161
  }
39978
40162
  },
39979
40163
  Quartiles: {
40164
+ description: "Lower quartile, median, and upper quartile of a collection.",
39980
40165
  complexity: 1200,
39981
40166
  broadcastable: false,
39982
40167
  signature: "((collection|number)+) -> tuple<mid:number, lower:number, upper:number>",
@@ -39988,6 +40173,7 @@ ${e.message}
39988
40173
  }
39989
40174
  },
39990
40175
  InterquartileRange: {
40176
+ description: "Interquartile range (Q3 - Q1) of a collection.",
39991
40177
  complexity: 1200,
39992
40178
  broadcastable: false,
39993
40179
  signature: "((collection|number)+) -> number",
@@ -40742,6 +40928,7 @@ ${e.message}
40742
40928
  },
40743
40929
  {
40744
40930
  Degrees: {
40931
+ description: "Convert an angle in degrees.",
40745
40932
  /* = Pi / 180 */
40746
40933
  signature: "(real) -> real",
40747
40934
  type: () => "finite_real",
@@ -40771,6 +40958,7 @@ ${e.message}
40771
40958
  },
40772
40959
  // DMS(degrees, minutes?, seconds?) — programmatic angle construction
40773
40960
  DMS: {
40961
+ description: "Construct an angle from degrees, minutes, and seconds.",
40774
40962
  signature: "(real, real?, real?) -> real",
40775
40963
  type: () => "finite_real",
40776
40964
  canonical: (ops, { engine: ce }) => {
@@ -40794,6 +40982,7 @@ ${e.message}
40794
40982
  },
40795
40983
  // Hypot: sqrt(x*x + y*y)
40796
40984
  Hypot: {
40985
+ description: "Hypotenuse length: sqrt(x^2 + y^2).",
40797
40986
  broadcastable: true,
40798
40987
  signature: "(real, real) -> real",
40799
40988
  type: () => "finite_real",
@@ -40810,6 +40999,7 @@ ${e.message}
40810
40999
  // (may be used in the definition of other functions below)
40811
41000
  //
40812
41001
  Arctan: {
41002
+ description: "Inverse tangent.",
40813
41003
  wikidata: "Q2257242",
40814
41004
  complexity: 5200,
40815
41005
  broadcastable: true,
@@ -40819,6 +41009,7 @@ ${e.message}
40819
41009
  evaluate: ([x], { numericApproximation: numericApproximation2 }) => numericApproximation2 ? evalTrig("Arctan", x) : constructibleValues("Arctan", x) ?? evalTrig("Arctan", x)
40820
41010
  },
40821
41011
  Arctan2: {
41012
+ description: "Two-argument arctangent giving the angle of a vector.",
40822
41013
  wikidata: "Q776598",
40823
41014
  complexity: 5200,
40824
41015
  broadcastable: true,
@@ -40864,6 +41055,7 @@ ${e.message}
40864
41055
  Sinh: trigFunction("Sinh", 6e3),
40865
41056
  /** = sin(z/2)^2 = (1 - cos z) / 2*/
40866
41057
  Haversine: {
41058
+ description: "Haversine function.",
40867
41059
  wikidata: "Q2528380",
40868
41060
  broadcastable: true,
40869
41061
  signature: "(real) -> number",
@@ -40872,6 +41064,7 @@ ${e.message}
40872
41064
  },
40873
41065
  /** = 2 * Arcsin(Sqrt(z)) */
40874
41066
  InverseHaversine: {
41067
+ description: "Inverse haversine function.",
40875
41068
  // Range ['Interval', [['Negate', 'Pi'], 'Pi'],
40876
41069
  broadcastable: true,
40877
41070
  signature: "(real) -> real",
@@ -40895,6 +41088,7 @@ ${e.message}
40895
41088
  Coth: trigFunction("Coth", 6300),
40896
41089
  /** sinc(x) = sin(x)/x with sinc(0) = 1 (unnormalized cardinal sine) */
40897
41090
  Sinc: {
41091
+ description: "Unnormalized sinc function: sin(x)/x with sinc(0)=1.",
40898
41092
  complexity: 5100,
40899
41093
  broadcastable: true,
40900
41094
  signature: "(number) -> real",
@@ -40906,6 +41100,7 @@ ${e.message}
40906
41100
  },
40907
41101
  /** FresnelS(x) = ∫₀ˣ sin(πt²/2) dt — odd function, S(∞) = 1/2 */
40908
41102
  FresnelS: {
41103
+ description: "Fresnel sine integral.",
40909
41104
  complexity: 5200,
40910
41105
  broadcastable: true,
40911
41106
  signature: "(number) -> real",
@@ -40917,6 +41112,7 @@ ${e.message}
40917
41112
  },
40918
41113
  /** FresnelC(x) = ∫₀ˣ cos(πt²/2) dt — odd function, C(∞) = 1/2 */
40919
41114
  FresnelC: {
41115
+ description: "Fresnel cosine integral.",
40920
41116
  complexity: 5200,
40921
41117
  broadcastable: true,
40922
41118
  signature: "(number) -> real",
@@ -40932,6 +41128,7 @@ ${e.message}
40932
41128
  // outputDomain: ['TupleOf', 'RealNumbers', 'RealNumbers'],
40933
41129
  // },
40934
41130
  InverseFunction: {
41131
+ description: "Inverse of a function.",
40935
41132
  lazy: true,
40936
41133
  signature: "(function) -> function",
40937
41134
  canonical: (ops, { engine }) => {
@@ -41308,6 +41505,18 @@ ${e.message}
41308
41505
  if (degree !== null) return ["Root", base, degree];
41309
41506
  return ["Sqrt", base];
41310
41507
  }
41508
+ function negateNumberLiteral(expr) {
41509
+ if (typeof expr === "number") return -expr;
41510
+ if (typeof expr === "string") {
41511
+ if (expr.startsWith("-")) return expr.slice(1);
41512
+ if (expr.startsWith("+")) return "-" + expr.slice(1);
41513
+ return "-" + expr;
41514
+ }
41515
+ const num = expr.num;
41516
+ if (num.startsWith("-")) return { num: num.slice(1) };
41517
+ if (num.startsWith("+")) return { num: "-" + num.slice(1) };
41518
+ return { num: "-" + num };
41519
+ }
41311
41520
  function serializeRoot(serializer, style, base, degree) {
41312
41521
  if (base === null || base === void 0) return "\\sqrt{}";
41313
41522
  degree = degree ?? 2;
@@ -41873,6 +42082,11 @@ ${e.message}
41873
42082
  minPrec: ADDITION_PRECEDENCE
41874
42083
  });
41875
42084
  if (rhs === null) return null;
42085
+ if (operator(rhs) === "Negate") {
42086
+ const value = operand(rhs, 1);
42087
+ if (isNumberExpression(value))
42088
+ return foldAssociativeOperator("Add", lhs, negateNumberLiteral(value));
42089
+ }
41876
42090
  return foldAssociativeOperator("Add", lhs, rhs);
41877
42091
  },
41878
42092
  serialize: serializeAdd
@@ -42531,13 +42745,12 @@ ${e.message}
42531
42745
  associativity: "left",
42532
42746
  precedence: ADDITION_PRECEDENCE + 2,
42533
42747
  parse: (parser, lhs, terminator) => {
42534
- parser.index -= 1;
42535
42748
  const rhs = parser.parseExpression({
42536
42749
  ...terminator,
42537
42750
  minPrec: ADDITION_PRECEDENCE + 3
42538
42751
  });
42539
42752
  if (rhs === null) return null;
42540
- return ["Add", lhs, rhs];
42753
+ return ["Subtract", lhs, rhs];
42541
42754
  },
42542
42755
  serialize: (serializer, expr) => {
42543
42756
  const lhs = serializer.wrap(operand(expr, 1), ADDITION_PRECEDENCE + 2);
@@ -47742,7 +47955,8 @@ Error in definition of "${name}"`,
47742
47955
  const exponent = asSmallInteger(expr.op2);
47743
47956
  if (exponent !== null)
47744
47957
  return [coef.pow(exponent), ce.function("Power", [base, expr.op2])];
47745
- if (expr.op2.isSame(0.5)) return [coef.sqrt(), ce.function("Sqrt", [base])];
47958
+ if (expr.op2.isSame(0.5))
47959
+ return [coef.sqrt(), ce.function("Sqrt", [base])];
47746
47960
  return [ce._numericValue(1), this];
47747
47961
  }
47748
47962
  if (isFunction2(expr, "Sqrt")) {
@@ -50047,7 +50261,7 @@ Error in definition of "${name}"`,
50047
50261
  if (args.length === 1 && locals.length === 0) {
50048
50262
  return _BaseCompiler.compile(args[0], target);
50049
50263
  }
50050
- const result = args.map(
50264
+ const result = args.filter((a) => !isSymbol2(a, "Nothing")).map(
50051
50265
  (arg) => _BaseCompiler.compile(arg, {
50052
50266
  ...target,
50053
50267
  var: (id) => {
@@ -50055,7 +50269,8 @@ Error in definition of "${name}"`,
50055
50269
  return target.var(id);
50056
50270
  }
50057
50271
  })
50058
- );
50272
+ ).filter((s) => s !== "");
50273
+ if (result.length === 0) return "";
50059
50274
  result[result.length - 1] = `return ${result[result.length - 1]}`;
50060
50275
  return `(() => {${target.ws("\n")}${result.join(
50061
50276
  `;${target.ws("\n")}`
@@ -53363,7 +53578,8 @@ Error in definition of "${name}"`,
53363
53578
  if (numBase && denomBase && numBase.isSame(denomBase)) {
53364
53579
  if (!asRational(numExp) || !asRational(denomExp)) {
53365
53580
  const diffExp = ce.function("Add", [numExp, denomExp.neg()]);
53366
- if (diffExp.isSame(0)) return { value: ce.One, because: "x^a/x^a -> 1" };
53581
+ if (diffExp.isSame(0))
53582
+ return { value: ce.One, because: "x^a/x^a -> 1" };
53367
53583
  if (diffExp.isSame(1))
53368
53584
  return { value: numBase, because: "x^a/x^b -> x when a-b=1" };
53369
53585
  return {
@@ -53819,7 +54035,8 @@ Error in definition of "${name}"`,
53819
54035
  const ce = expr.engine;
53820
54036
  if (y.isFinite === false && x.isFinite === false)
53821
54037
  return { value: ce.NaN, because: "arctan2" };
53822
- if (y.isSame(0) && x.isSame(0)) return { value: ce.Zero, because: "arctan2" };
54038
+ if (y.isSame(0) && x.isSame(0))
54039
+ return { value: ce.Zero, because: "arctan2" };
53823
54040
  if (x.isFinite === false)
53824
54041
  return { value: x.isPositive ? ce.Zero : ce.Pi, because: "arctan2" };
53825
54042
  if (y.isFinite === false)
@@ -55237,10 +55454,10 @@ Error in definition of "${name}"`,
55237
55454
  if (this._def) return this;
55238
55455
  return this.engine.symbol(this._id);
55239
55456
  }
55240
- is(other) {
55241
- if (this.isSame(other)) return true;
55457
+ is(other, tolerance) {
55458
+ if (tolerance === void 0 && this.isSame(other)) return true;
55242
55459
  const val = this.value;
55243
- if (val && val !== this) return val.is(other);
55460
+ if (val && val !== this) return val.is(other, tolerance);
55244
55461
  return false;
55245
55462
  }
55246
55463
  isSame(other) {
@@ -57302,21 +57519,23 @@ Error in definition of "${name}"`,
57302
57519
  var GPU_GAMMA_PREAMBLE = `
57303
57520
  float _gpu_gamma(float z) {
57304
57521
  const float PI = 3.14159265358979;
57305
- if (z < 0.5) {
57306
- return PI / (sin(PI * z) * _gpu_gamma(1.0 - z));
57307
- }
57308
- z -= 1.0;
57522
+ // For z < 0.5, use reflection formula with inlined Lanczos (non-recursive)
57523
+ float w = z;
57524
+ if (z < 0.5) w = 1.0 - z;
57525
+ w -= 1.0;
57309
57526
  float x = 0.99999999999980993;
57310
- x += 676.5203681218851 / (z + 1.0);
57311
- x += -1259.1392167224028 / (z + 2.0);
57312
- x += 771.32342877765313 / (z + 3.0);
57313
- x += -176.61502916214059 / (z + 4.0);
57314
- x += 12.507343278686905 / (z + 5.0);
57315
- x += -0.13857109526572012 / (z + 6.0);
57316
- x += 9.9843695780195716e-6 / (z + 7.0);
57317
- x += 1.5056327351493116e-7 / (z + 8.0);
57318
- float t = z + 7.5;
57319
- return sqrt(2.0 * PI) * pow(t, z + 0.5) * exp(-t) * x;
57527
+ x += 676.5203681218851 / (w + 1.0);
57528
+ x += -1259.1392167224028 / (w + 2.0);
57529
+ x += 771.32342877765313 / (w + 3.0);
57530
+ x += -176.61502916214059 / (w + 4.0);
57531
+ x += 12.507343278686905 / (w + 5.0);
57532
+ x += -0.13857109526572012 / (w + 6.0);
57533
+ x += 9.9843695780195716e-6 / (w + 7.0);
57534
+ x += 1.5056327351493116e-7 / (w + 8.0);
57535
+ float t = w + 7.5;
57536
+ float g = sqrt(2.0 * PI) * pow(t, w + 0.5) * exp(-t) * x;
57537
+ if (z < 0.5) return PI / (sin(PI * z) * g);
57538
+ return g;
57320
57539
  }
57321
57540
 
57322
57541
  float _gpu_gammaln(float z) {
@@ -60677,21 +60896,23 @@ IntervalResult ia_asech(IntervalResult x) {
60677
60896
  // Poles at non-positive integers; minimum at x \u2248 1.4616
60678
60897
  float _gpu_gamma(float z) {
60679
60898
  const float PI = 3.14159265358979;
60680
- if (z < 0.5) {
60681
- return PI / (sin(PI * z) * _gpu_gamma(1.0 - z));
60682
- }
60683
- z -= 1.0;
60899
+ // For z < 0.5, use reflection formula with inlined Lanczos (non-recursive)
60900
+ float w = z;
60901
+ if (z < 0.5) w = 1.0 - z;
60902
+ w -= 1.0;
60684
60903
  float x = 0.99999999999980993;
60685
- x += 676.5203681218851 / (z + 1.0);
60686
- x += -1259.1392167224028 / (z + 2.0);
60687
- x += 771.32342877765313 / (z + 3.0);
60688
- x += -176.61502916214059 / (z + 4.0);
60689
- x += 12.507343278686905 / (z + 5.0);
60690
- x += -0.13857109526572012 / (z + 6.0);
60691
- x += 9.9843695780195716e-6 / (z + 7.0);
60692
- x += 1.5056327351493116e-7 / (z + 8.0);
60693
- float t = z + 7.5;
60694
- return sqrt(2.0 * PI) * pow(t, z + 0.5) * exp(-t) * x;
60904
+ x += 676.5203681218851 / (w + 1.0);
60905
+ x += -1259.1392167224028 / (w + 2.0);
60906
+ x += 771.32342877765313 / (w + 3.0);
60907
+ x += -176.61502916214059 / (w + 4.0);
60908
+ x += 12.507343278686905 / (w + 5.0);
60909
+ x += -0.13857109526572012 / (w + 6.0);
60910
+ x += 9.9843695780195716e-6 / (w + 7.0);
60911
+ x += 1.5056327351493116e-7 / (w + 8.0);
60912
+ float t = w + 7.5;
60913
+ float g = sqrt(2.0 * PI) * pow(t, w + 0.5) * exp(-t) * x;
60914
+ if (z < 0.5) return PI / (sin(PI * z) * g);
60915
+ return g;
60695
60916
  }
60696
60917
 
60697
60918
  // Interval gamma function
@@ -60864,6 +61085,128 @@ float ia_notEqual(IntervalResult a, IntervalResult b) {
60864
61085
  return ia_notEqual(a.value, b.value);
60865
61086
  }
60866
61087
  `;
61088
+ var _preambleHeader = "";
61089
+ var _preambleFunctions = /* @__PURE__ */ new Map();
61090
+ var _preambleParsed = false;
61091
+ var GLSL_FUNC_RE = /^(IntervalResult|vec2|float|bool|void)\s+(ia_\w+|_gpu_\w+)\s*\(/;
61092
+ var GLSL_CALL_RE = /\b(ia_\w+|_gpu_\w+)\s*\(/g;
61093
+ var GLSL_CONST_RE = /^const\s+float\s+(IA_\w+)\s*=/;
61094
+ function parsePreamble() {
61095
+ if (_preambleParsed) return;
61096
+ _preambleParsed = true;
61097
+ const lines = GLSL_INTERVAL_LIBRARY.split("\n");
61098
+ let headerDone = false;
61099
+ const headerLines = [];
61100
+ let currentBlock = [];
61101
+ let currentName = null;
61102
+ let braceDepth = 0;
61103
+ let inFunction = false;
61104
+ let pendingComments = [];
61105
+ let pendingConstants = [];
61106
+ for (const line of lines) {
61107
+ const constMatch = !inFunction && GLSL_CONST_RE.exec(line);
61108
+ if (constMatch && headerDone) {
61109
+ pendingConstants.push(line);
61110
+ continue;
61111
+ }
61112
+ const funcMatch = !inFunction && GLSL_FUNC_RE.exec(line);
61113
+ if (funcMatch) {
61114
+ if (!headerDone) {
61115
+ _preambleHeader = headerLines.join("\n");
61116
+ headerDone = true;
61117
+ }
61118
+ currentName = funcMatch[2];
61119
+ currentBlock = [...pendingComments, ...pendingConstants, line];
61120
+ pendingComments = [];
61121
+ pendingConstants = [];
61122
+ inFunction = true;
61123
+ braceDepth = 0;
61124
+ for (const ch of line) {
61125
+ if (ch === "{") braceDepth++;
61126
+ if (ch === "}") braceDepth--;
61127
+ }
61128
+ if (braceDepth <= 0) {
61129
+ finishFunction(currentName, currentBlock.join("\n"));
61130
+ inFunction = false;
61131
+ currentName = null;
61132
+ }
61133
+ } else if (inFunction) {
61134
+ currentBlock.push(line);
61135
+ for (const ch of line) {
61136
+ if (ch === "{") braceDepth++;
61137
+ if (ch === "}") braceDepth--;
61138
+ }
61139
+ if (braceDepth <= 0) {
61140
+ finishFunction(currentName, currentBlock.join("\n"));
61141
+ inFunction = false;
61142
+ currentName = null;
61143
+ }
61144
+ } else if (!headerDone) {
61145
+ headerLines.push(line);
61146
+ } else {
61147
+ const trimmed = line.trim();
61148
+ if (trimmed.startsWith("//") || trimmed === "") {
61149
+ pendingComments.push(line);
61150
+ }
61151
+ }
61152
+ }
61153
+ if (pendingConstants.length > 0) {
61154
+ _preambleHeader += "\n" + pendingConstants.join("\n");
61155
+ }
61156
+ }
61157
+ function finishFunction(name, source) {
61158
+ const deps = /* @__PURE__ */ new Set();
61159
+ let match2;
61160
+ const callRe = new RegExp(GLSL_CALL_RE.source, "g");
61161
+ while ((match2 = callRe.exec(source)) !== null) {
61162
+ const callee = match2[1];
61163
+ if (callee !== name) deps.add(callee);
61164
+ }
61165
+ const existing = _preambleFunctions.get(name);
61166
+ if (existing) {
61167
+ existing.source += "\n\n" + source;
61168
+ for (const d of deps) existing.deps.push(d);
61169
+ } else {
61170
+ _preambleFunctions.set(name, {
61171
+ name,
61172
+ source,
61173
+ deps: [...deps]
61174
+ });
61175
+ }
61176
+ }
61177
+ function buildIntervalPreamble(code) {
61178
+ parsePreamble();
61179
+ const needed = /* @__PURE__ */ new Set();
61180
+ let match2;
61181
+ const callRe = new RegExp(GLSL_CALL_RE.source, "g");
61182
+ while ((match2 = callRe.exec(code)) !== null) {
61183
+ needed.add(match2[1]);
61184
+ }
61185
+ if (needed.size === 0) return _preambleHeader;
61186
+ const resolved = /* @__PURE__ */ new Set();
61187
+ function resolve(name) {
61188
+ if (resolved.has(name)) return;
61189
+ const block = _preambleFunctions.get(name);
61190
+ if (!block) return;
61191
+ for (const dep of block.deps) resolve(dep);
61192
+ resolved.add(name);
61193
+ }
61194
+ for (const name of needed) resolve(name);
61195
+ const parts = [_preambleHeader];
61196
+ const needsComparisonConstants = [...resolved].some(
61197
+ (name) => name.startsWith("ia_less") || name.startsWith("ia_greater") || name.startsWith("ia_equal") || name.startsWith("ia_notEqual") || name === "ia_and" || name === "ia_or" || name === "ia_not"
61198
+ );
61199
+ if (needsComparisonConstants) {
61200
+ parts.push(
61201
+ "\nconst float IA_TRUE = 1.0;\nconst float IA_FALSE = 0.0;\nconst float IA_MAYBE = 0.5;"
61202
+ );
61203
+ }
61204
+ for (const name of resolved) {
61205
+ const block = _preambleFunctions.get(name);
61206
+ if (block) parts.push("\n" + block.source);
61207
+ }
61208
+ return parts.join("\n");
61209
+ }
60867
61210
  var INTERVAL_GLSL_OPERATORS = {
60868
61211
  Add: ["ia_add", 20],
60869
61212
  Negate: ["ia_negate", 20],
@@ -61089,7 +61432,7 @@ float ia_notEqual(IntervalResult a, IntervalResult b) {
61089
61432
  target: "interval-glsl",
61090
61433
  success: true,
61091
61434
  code: glslCode,
61092
- preamble: GLSL_INTERVAL_LIBRARY
61435
+ preamble: buildIntervalPreamble(glslCode)
61093
61436
  };
61094
61437
  }
61095
61438
  /**
@@ -61132,7 +61475,7 @@ float ia_notEqual(IntervalResult a, IntervalResult b) {
61132
61475
  return `#version ${version2}
61133
61476
  precision highp float;
61134
61477
 
61135
- ${GLSL_INTERVAL_LIBRARY}
61478
+ ${buildIntervalPreamble(body)}
61136
61479
 
61137
61480
  IntervalResult ${functionName}(${params}) {
61138
61481
  return ${body};
@@ -62243,6 +62586,122 @@ fn ia_notEqual(a: IntervalResult, b: IntervalResult) -> f32 {
62243
62586
  return ia_notEqual_v(a.value, b.value);
62244
62587
  }
62245
62588
  `;
62589
+ var _wgslPreambleHeader = "";
62590
+ var _wgslPreambleFunctions = /* @__PURE__ */ new Map();
62591
+ var _wgslPreambleParsed = false;
62592
+ var WGSL_FUNC_RE = /^fn\s+(ia_\w+|_gpu_\w+)\s*\(/;
62593
+ var WGSL_CALL_RE = /\b(ia_\w+|_gpu_\w+)\s*\(/g;
62594
+ var WGSL_CONST_RE = /^const\s+(IA_\w+)\s*:/;
62595
+ function parseWGSLPreamble() {
62596
+ if (_wgslPreambleParsed) return;
62597
+ _wgslPreambleParsed = true;
62598
+ const lines = WGSL_INTERVAL_LIBRARY.split("\n");
62599
+ let headerDone = false;
62600
+ const headerLines = [];
62601
+ let currentBlock = [];
62602
+ let currentName = null;
62603
+ let braceDepth = 0;
62604
+ let inFunction = false;
62605
+ let pendingComments = [];
62606
+ let pendingConstants = [];
62607
+ for (const line of lines) {
62608
+ const constMatch = !inFunction && WGSL_CONST_RE.exec(line);
62609
+ if (constMatch && headerDone) {
62610
+ pendingConstants.push(line);
62611
+ continue;
62612
+ }
62613
+ const funcMatch = !inFunction && WGSL_FUNC_RE.exec(line);
62614
+ if (funcMatch) {
62615
+ if (!headerDone) {
62616
+ _wgslPreambleHeader = headerLines.join("\n");
62617
+ headerDone = true;
62618
+ }
62619
+ currentName = funcMatch[1];
62620
+ currentBlock = [...pendingComments, ...pendingConstants, line];
62621
+ pendingComments = [];
62622
+ pendingConstants = [];
62623
+ inFunction = true;
62624
+ braceDepth = 0;
62625
+ for (const ch of line) {
62626
+ if (ch === "{") braceDepth++;
62627
+ if (ch === "}") braceDepth--;
62628
+ }
62629
+ if (braceDepth <= 0) {
62630
+ finishWGSLFunction(currentName, currentBlock.join("\n"));
62631
+ inFunction = false;
62632
+ currentName = null;
62633
+ }
62634
+ } else if (inFunction) {
62635
+ currentBlock.push(line);
62636
+ for (const ch of line) {
62637
+ if (ch === "{") braceDepth++;
62638
+ if (ch === "}") braceDepth--;
62639
+ }
62640
+ if (braceDepth <= 0) {
62641
+ finishWGSLFunction(currentName, currentBlock.join("\n"));
62642
+ inFunction = false;
62643
+ currentName = null;
62644
+ }
62645
+ } else if (!headerDone) {
62646
+ headerLines.push(line);
62647
+ } else {
62648
+ const trimmed = line.trim();
62649
+ if (trimmed.startsWith("//") || trimmed === "") {
62650
+ pendingComments.push(line);
62651
+ }
62652
+ }
62653
+ }
62654
+ if (pendingConstants.length > 0) {
62655
+ _wgslPreambleHeader += "\n" + pendingConstants.join("\n");
62656
+ }
62657
+ }
62658
+ function finishWGSLFunction(name, source) {
62659
+ const deps = /* @__PURE__ */ new Set();
62660
+ let match2;
62661
+ const callRe = new RegExp(WGSL_CALL_RE.source, "g");
62662
+ while ((match2 = callRe.exec(source)) !== null) {
62663
+ const callee = match2[1];
62664
+ if (callee !== name) deps.add(callee);
62665
+ }
62666
+ _wgslPreambleFunctions.set(name, {
62667
+ name,
62668
+ source,
62669
+ deps: [...deps]
62670
+ });
62671
+ }
62672
+ function buildIntervalWGSLPreamble(code) {
62673
+ parseWGSLPreamble();
62674
+ const needed = /* @__PURE__ */ new Set();
62675
+ let match2;
62676
+ const callRe = new RegExp(WGSL_CALL_RE.source, "g");
62677
+ while ((match2 = callRe.exec(code)) !== null) {
62678
+ needed.add(match2[1]);
62679
+ }
62680
+ if (needed.size === 0) return _wgslPreambleHeader;
62681
+ const resolved = /* @__PURE__ */ new Set();
62682
+ function resolve(name) {
62683
+ if (resolved.has(name)) return;
62684
+ const block = _wgslPreambleFunctions.get(name);
62685
+ if (!block) return;
62686
+ for (const dep of block.deps) resolve(dep);
62687
+ resolved.add(name);
62688
+ }
62689
+ for (const name of needed) resolve(name);
62690
+ const parts = [_wgslPreambleHeader];
62691
+ const needsComparisonConstants = [...resolved].some(
62692
+ (name) => name.startsWith("ia_less") || name.startsWith("ia_greater") || name.startsWith("ia_equal") || name.startsWith("ia_notEqual") || name === "ia_and" || name === "ia_or" || name === "ia_not"
62693
+ );
62694
+ if (needsComparisonConstants) {
62695
+ parts.push(
62696
+ "\nconst IA_TRUE: f32 = 1.0;\nconst IA_FALSE: f32 = 0.0;\nconst IA_MAYBE: f32 = 0.5;"
62697
+ );
62698
+ }
62699
+ for (const name of resolved) {
62700
+ const block = _wgslPreambleFunctions.get(name);
62701
+ if (block) parts.push("\n" + block.source);
62702
+ }
62703
+ return parts.join("\n");
62704
+ }
62246
62705
  var INTERVAL_WGSL_OPERATORS = {
62247
62706
  Add: ["ia_add", 20],
62248
62707
  Negate: ["ia_negate", 20],
@@ -62466,7 +62925,7 @@ fn ia_notEqual(a: IntervalResult, b: IntervalResult) -> f32 {
62466
62925
  target: "interval-wgsl",
62467
62926
  success: true,
62468
62927
  code: wgslCode,
62469
- preamble: WGSL_INTERVAL_LIBRARY
62928
+ preamble: buildIntervalWGSLPreamble(wgslCode)
62470
62929
  };
62471
62930
  }
62472
62931
  /**
@@ -62502,7 +62961,8 @@ fn ia_notEqual(a: IntervalResult, b: IntervalResult) -> f32 {
62502
62961
  const target = this.createTarget();
62503
62962
  const body = BaseCompiler.compile(expr, target);
62504
62963
  const params = parameters.map((name) => `${name}: vec2f`).join(", ");
62505
- return `${WGSL_INTERVAL_LIBRARY}
62964
+ const preamble = buildIntervalWGSLPreamble(body);
62965
+ return `${preamble}
62506
62966
 
62507
62967
  fn ${functionName}(${params}) -> IntervalResult {
62508
62968
  return ${body};
@@ -62992,7 +63452,23 @@ fn ${functionName}(${params}) -> IntervalResult {
62992
63452
  if (typeof this._value === "number") return true;
62993
63453
  return isSubtype(this._value.type, "real");
62994
63454
  }
62995
- is(other) {
63455
+ get isExact() {
63456
+ const n = this._value;
63457
+ if (typeof n === "number")
63458
+ return !Number.isFinite(n) || Number.isInteger(n);
63459
+ return n.isExact;
63460
+ }
63461
+ is(other, tolerance) {
63462
+ if (tolerance === void 0) return this.isSame(other);
63463
+ if (typeof other === "number") {
63464
+ return Math.abs(this.re - other) <= tolerance && Math.abs(this.im) <= tolerance;
63465
+ }
63466
+ if (typeof other === "bigint") {
63467
+ return Math.abs(this.re - Number(other)) <= tolerance && Math.abs(this.im) <= tolerance;
63468
+ }
63469
+ if (other instanceof _BoxedExpression && isNumber(other)) {
63470
+ return Math.abs(this.re - other.re) <= tolerance && Math.abs(this.im - other.im) <= tolerance;
63471
+ }
62996
63472
  return this.isSame(other);
62997
63473
  }
62998
63474
  isSame(other) {
@@ -65552,6 +66028,58 @@ fn ${functionName}(${params}) -> IntervalResult {
65552
66028
  return null;
65553
66029
  }
65554
66030
  this.skipSpace();
66031
+ let subscript = null;
66032
+ if (this.peek === "_") {
66033
+ const underIndex = this.index;
66034
+ this.index++;
66035
+ subscript = this.parseGroup();
66036
+ if (subscript === null) {
66037
+ const subStart = this.index;
66038
+ if (!this.atEnd && /^[a-zA-Z]$/.test(this.peek)) {
66039
+ subscript = this.peek;
66040
+ this.index++;
66041
+ } else {
66042
+ let digits = "";
66043
+ while (!this.atEnd && /^[0-9]$/.test(this.peek)) {
66044
+ digits += this.peek;
66045
+ this.index++;
66046
+ }
66047
+ if (digits) subscript = parseInt(digits);
66048
+ }
66049
+ if (subscript === null) {
66050
+ this.index = start;
66051
+ return null;
66052
+ }
66053
+ }
66054
+ this.skipSpace();
66055
+ }
66056
+ let exponent = null;
66057
+ if (this.peek === "^") {
66058
+ const caretIndex = this.index;
66059
+ this.index++;
66060
+ exponent = this.parseGroup();
66061
+ if (exponent === null) {
66062
+ const digitStart = this.index;
66063
+ let neg2 = false;
66064
+ if (this.peek === "-") {
66065
+ neg2 = true;
66066
+ this.index++;
66067
+ }
66068
+ let digits = "";
66069
+ while (!this.atEnd && /^[0-9]$/.test(this.peek)) {
66070
+ digits += this.peek;
66071
+ this.index++;
66072
+ }
66073
+ if (digits) {
66074
+ const num = parseInt(digits);
66075
+ exponent = neg2 ? -num : num;
66076
+ } else {
66077
+ this.index = start;
66078
+ return null;
66079
+ }
66080
+ }
66081
+ this.skipSpace();
66082
+ }
65555
66083
  if (this.peek !== "(") {
65556
66084
  this.index = start;
65557
66085
  return null;
@@ -65626,8 +66154,19 @@ fn ${functionName}(${params}) -> IntervalResult {
65626
66154
  this.index = start;
65627
66155
  return null;
65628
66156
  }
65629
- if (name === "cbrt") return ["Root", args[0] ?? "Nothing", 3];
65630
- return [fnName, ...args];
66157
+ if (name === "cbrt") {
66158
+ const result2 = ["Root", args[0] ?? "Nothing", 3];
66159
+ return exponent !== null ? ["Power", result2, exponent] : result2;
66160
+ }
66161
+ let result;
66162
+ if (name === "log" && subscript !== null) {
66163
+ if (subscript === 2) result = ["Lb", ...args];
66164
+ else if (subscript === 10) result = ["Log", ...args];
66165
+ else result = ["Log", args[0], subscript];
66166
+ } else {
66167
+ result = [fnName, ...args];
66168
+ }
66169
+ return exponent !== null ? ["Power", result, exponent] : result;
65631
66170
  }
65632
66171
  static BARE_SYMBOL_MAP = {
65633
66172
  // Greek lowercase
@@ -69529,10 +70068,10 @@ ${code}`;
69529
70068
  _setComputeEngineClass(ComputeEngine);
69530
70069
 
69531
70070
  // src/compute-engine.ts
69532
- var version = "0.52.0";
70071
+ var version = "0.52.1";
69533
70072
  globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
69534
70073
  ComputeEngine: ComputeEngine.prototype.constructor,
69535
- version: "0.52.0"
70074
+ version: "0.52.1"
69536
70075
  };
69537
70076
  return __toCommonJS(compute_engine_exports);
69538
70077
  })();