@cortex-js/compute-engine 0.34.0 → 0.35.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 (177) hide show
  1. package/dist/compute-engine.esm.js +2337 -695
  2. package/dist/compute-engine.min.esm.js +419 -38
  3. package/dist/compute-engine.min.umd.js +419 -38
  4. package/dist/compute-engine.umd.js +2337 -695
  5. package/dist/math-json.esm.js +2 -2
  6. package/dist/math-json.min.esm.js +2 -2
  7. package/dist/math-json.min.umd.js +2 -2
  8. package/dist/math-json.umd.js +2 -2
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/configuration-change.d.ts +1 -1
  11. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  12. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  13. package/dist/types/common/interruptible.d.ts +1 -1
  14. package/dist/types/common/one-of.d.ts +1 -1
  15. package/dist/types/common/signals.d.ts +1 -1
  16. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  17. package/dist/types/common/type/boxed-type.d.ts +1 -1
  18. package/dist/types/common/type/lexer.d.ts +1 -1
  19. package/dist/types/common/type/parse.d.ts +1 -1
  20. package/dist/types/common/type/parser.d.ts +1 -1
  21. package/dist/types/common/type/primitive.d.ts +1 -1
  22. package/dist/types/common/type/reduce.d.ts +1 -1
  23. package/dist/types/common/type/serialize.d.ts +1 -1
  24. package/dist/types/common/type/subtype.d.ts +1 -1
  25. package/dist/types/common/type/type-builder.d.ts +1 -1
  26. package/dist/types/common/type/types.d.ts +1 -1
  27. package/dist/types/common/type/utils.d.ts +1 -1
  28. package/dist/types/common/utils.d.ts +1 -1
  29. package/dist/types/compute-engine/assume.d.ts +1 -1
  30. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  33. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  34. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  35. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  36. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  37. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  38. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  39. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  40. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  41. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  42. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  43. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  44. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  46. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  47. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  50. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  51. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  53. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  54. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  71. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  72. package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
  73. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  74. package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +51 -0
  75. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +93 -0
  76. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  77. package/dist/types/compute-engine/compilation/types.d.ts +1 -1
  78. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  79. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  80. package/dist/types/compute-engine/global-types.d.ts +2 -2
  81. package/dist/types/compute-engine/index.d.ts +3 -1
  82. package/dist/types/compute-engine/interval/arithmetic.d.ts +56 -0
  83. package/dist/types/compute-engine/interval/comparison.d.ts +70 -0
  84. package/dist/types/compute-engine/interval/elementary.d.ts +100 -0
  85. package/dist/types/compute-engine/interval/index.d.ts +93 -0
  86. package/dist/types/compute-engine/interval/trigonometric.d.ts +105 -0
  87. package/dist/types/compute-engine/interval/types.d.ts +50 -0
  88. package/dist/types/compute-engine/interval/util.d.ts +99 -0
  89. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  90. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  91. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  92. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  93. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  94. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  95. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  96. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  97. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  98. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  99. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  100. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  101. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  102. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  103. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  104. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  105. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  106. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  107. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  108. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  109. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  110. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  111. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  112. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  113. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  114. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  115. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  116. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  117. package/dist/types/compute-engine/library/core.d.ts +1 -1
  118. package/dist/types/compute-engine/library/invisible-operator.d.ts +1 -1
  119. package/dist/types/compute-engine/library/library.d.ts +1 -1
  120. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  121. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  122. package/dist/types/compute-engine/library/logic-utils.d.ts +1 -1
  123. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  124. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  125. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  126. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  127. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  128. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  129. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  130. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  131. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  132. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  133. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  134. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  135. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  136. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  137. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  138. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  139. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  140. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  141. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  142. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  143. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  144. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  145. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  146. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  147. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  148. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  149. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  150. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  151. package/dist/types/compute-engine/oeis.d.ts +1 -1
  152. package/dist/types/compute-engine/sequence.d.ts +1 -1
  153. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  154. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  155. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  156. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  157. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  158. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  159. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  160. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  161. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  162. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  163. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  164. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  165. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  166. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  167. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  168. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  169. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  170. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  171. package/dist/types/compute-engine/types.d.ts +1 -1
  172. package/dist/types/compute-engine.d.ts +1 -1
  173. package/dist/types/math-json/symbols.d.ts +1 -1
  174. package/dist/types/math-json/types.d.ts +1 -1
  175. package/dist/types/math-json/utils.d.ts +1 -1
  176. package/dist/types/math-json.d.ts +2 -2
  177. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.34.0 */
1
+ /** Compute Engine 0.35.0 */
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;
@@ -20,7 +20,7 @@ var ComputeEngine = (() => {
20
20
  }
21
21
  return to;
22
22
  };
23
- var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
23
+ var __toCommonJS = (mod3) => __copyProps(__defProp({}, "__esModule", { value: true }), mod3);
24
24
 
25
25
  // node_modules/complex-esm/dist/src/complex.js
26
26
  function logHypot(a, b) {
@@ -174,8 +174,8 @@ var ComputeEngine = (() => {
174
174
  * @returns {Complex}
175
175
  */
176
176
  sign() {
177
- var abs2 = this["abs"]();
178
- return new _Complex(this["re"] / abs2, this["im"] / abs2);
177
+ var abs3 = this["abs"]();
178
+ return new _Complex(this["re"] / abs3, this["im"] / abs3);
179
179
  }
180
180
  /**
181
181
  * Adds two complex numbers
@@ -894,8 +894,8 @@ var ComputeEngine = (() => {
894
894
  for (; w % 10 === 0; ) w /= 10;
895
895
  return str + w;
896
896
  }
897
- function checkInt32(i, min2, max2) {
898
- if (i !== ~~i || i < min2 || i > max2) {
897
+ function checkInt32(i, min3, max3) {
898
+ if (i !== ~~i || i < min3 || i > max3) {
899
899
  throw Error(invalidArgument + i);
900
900
  }
901
901
  }
@@ -1149,7 +1149,7 @@ var ComputeEngine = (() => {
1149
1149
  return x;
1150
1150
  }
1151
1151
  function naturalExponential(x, sd) {
1152
- var denominator, guard, j, pow3, sum2, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
1152
+ var denominator, guard, j, pow4, sum2, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
1153
1153
  if (!x.d || !x.d[0] || x.e > 17) {
1154
1154
  return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
1155
1155
  }
@@ -1166,19 +1166,19 @@ var ComputeEngine = (() => {
1166
1166
  }
1167
1167
  guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
1168
1168
  wpr += guard;
1169
- denominator = pow3 = sum2 = new Ctor(1);
1169
+ denominator = pow4 = sum2 = new Ctor(1);
1170
1170
  Ctor.precision = wpr;
1171
1171
  for (; ; ) {
1172
- pow3 = finalise(pow3.times(x), wpr, 1);
1172
+ pow4 = finalise(pow4.times(x), wpr, 1);
1173
1173
  denominator = denominator.times(++i);
1174
- t = sum2.plus(divide(pow3, denominator, wpr, 1));
1174
+ t = sum2.plus(divide(pow4, denominator, wpr, 1));
1175
1175
  if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
1176
1176
  j = k;
1177
1177
  while (j--) sum2 = finalise(sum2.times(sum2), wpr, 1);
1178
1178
  if (sd == null) {
1179
1179
  if (rep < 3 && checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
1180
1180
  Ctor.precision = wpr += 10;
1181
- denominator = pow3 = t = new Ctor(1);
1181
+ denominator = pow4 = t = new Ctor(1);
1182
1182
  i = 0;
1183
1183
  rep++;
1184
1184
  } else {
@@ -1570,8 +1570,8 @@ var ComputeEngine = (() => {
1570
1570
  function ceil(x) {
1571
1571
  return finalise(x = new this(x), x.e + 1, 2);
1572
1572
  }
1573
- function clamp(x, min2, max2) {
1574
- return new this(x).clamp(min2, max2);
1573
+ function clamp(x, min3, max3) {
1574
+ return new this(x).clamp(min3, max3);
1575
1575
  }
1576
1576
  function config(obj) {
1577
1577
  if (!obj || typeof obj !== "object") throw Error(decimalError + "Object expected");
@@ -2015,14 +2015,14 @@ var ComputeEngine = (() => {
2015
2015
  P.ceil = function() {
2016
2016
  return finalise(new this.constructor(this), this.e + 1, 2);
2017
2017
  };
2018
- P.clampedTo = P.clamp = function(min2, max2) {
2018
+ P.clampedTo = P.clamp = function(min3, max3) {
2019
2019
  var k, x = this, Ctor = x.constructor;
2020
- min2 = new Ctor(min2);
2021
- max2 = new Ctor(max2);
2022
- if (!min2.s || !max2.s) return new Ctor(NaN);
2023
- if (min2.gt(max2)) throw Error(invalidArgument + max2);
2024
- k = x.cmp(min2);
2025
- return k < 0 ? min2 : x.cmp(max2) > 0 ? max2 : new Ctor(x);
2020
+ min3 = new Ctor(min3);
2021
+ max3 = new Ctor(max3);
2022
+ if (!min3.s || !max3.s) return new Ctor(NaN);
2023
+ if (min3.gt(max3)) throw Error(invalidArgument + max3);
2024
+ k = x.cmp(min3);
2025
+ return k < 0 ? min3 : x.cmp(max3) > 0 ? max3 : new Ctor(x);
2026
2026
  };
2027
2027
  P.comparedTo = P.cmp = function(y) {
2028
2028
  var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
@@ -2920,13 +2920,13 @@ var ComputeEngine = (() => {
2920
2920
  for (; !a[0] && a.length > 1; ) a.shift();
2921
2921
  }
2922
2922
  return function(x, y, pr, rm, dp, base) {
2923
- var cmp2, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign2 = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
2923
+ var cmp2, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign3 = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
2924
2924
  if (!xd || !xd[0] || !yd || !yd[0]) {
2925
2925
  return new Ctor(
2926
2926
  // Return NaN if either NaN, or both Infinity or 0.
2927
2927
  !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : (
2928
2928
  // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
2929
- xd && xd[0] == 0 || !yd ? sign2 * 0 : sign2 / 0
2929
+ xd && xd[0] == 0 || !yd ? sign3 * 0 : sign3 / 0
2930
2930
  )
2931
2931
  );
2932
2932
  }
@@ -2940,7 +2940,7 @@ var ComputeEngine = (() => {
2940
2940
  }
2941
2941
  yL = yd.length;
2942
2942
  xL = xd.length;
2943
- q = new Ctor(sign2);
2943
+ q = new Ctor(sign3);
2944
2944
  qd = q.d = [];
2945
2945
  for (i = 0; yd[i] == (xd[i] || 0); i++) ;
2946
2946
  if (yd[i] > (xd[i] || 0)) e--;
@@ -5448,8 +5448,8 @@ var ComputeEngine = (() => {
5448
5448
  let s = a.toLowerCase();
5449
5449
  const m = s.match(/([+-]?[0-9]*)(?:\.([0-9]+))?e([+-]?[0-9]+)$/);
5450
5450
  if (m) {
5451
- const exp2 = parseInt(m[3]);
5452
- const pad = exp2 - (m[2] ? m[2].length : 0);
5451
+ const exp3 = parseInt(m[3]);
5452
+ const pad = exp3 - (m[2] ? m[2].length : 0);
5453
5453
  if (pad < 0) return null;
5454
5454
  s = (m[1] ?? "") + (m[2] ?? "") + "0".repeat(pad);
5455
5455
  }
@@ -6942,8 +6942,8 @@ var ComputeEngine = (() => {
6942
6942
  denom = machineValue(d) ?? NaN;
6943
6943
  }
6944
6944
  if (h === "Power") {
6945
- const [base, exp2] = operands(expr);
6946
- const exponent = machineValue(exp2);
6945
+ const [base, exp3] = operands(expr);
6946
+ const exponent = machineValue(exp3);
6947
6947
  if (exponent === 1) {
6948
6948
  numer = machineValue(base);
6949
6949
  denom = 1;
@@ -8325,11 +8325,11 @@ var ComputeEngine = (() => {
8325
8325
  if (!fn2) return null;
8326
8326
  const rhs2 = parser.parseExpression({ minPrec: 0 });
8327
8327
  if (rhs2 === null) return null;
8328
- const sub2 = operand(lhs, 2);
8329
- if (stringValue(sub2) !== null) {
8328
+ const sub3 = operand(lhs, 2);
8329
+ if (stringValue(sub3) !== null) {
8330
8330
  return ["Assign", lhs, rhs2];
8331
8331
  }
8332
- if (symbol(sub2)) {
8332
+ if (symbol(sub3)) {
8333
8333
  return ["Assign", lhs, rhs2];
8334
8334
  }
8335
8335
  return ["Assign", lhs, rhs2];
@@ -9645,12 +9645,12 @@ var ComputeEngine = (() => {
9645
9645
  if (extraDigits) digits += options.truncationMarker;
9646
9646
  return digits;
9647
9647
  }
9648
- function formatExponent(exp2, options) {
9649
- if (!exp2 || exp2 === "0") return "";
9648
+ function formatExponent(exp3, options) {
9649
+ if (!exp3 || exp3 === "0") return "";
9650
9650
  if (options.beginExponentMarker) {
9651
- return options.beginExponentMarker + exp2 + (options.endExponentMarker ?? "");
9651
+ return options.beginExponentMarker + exp3 + (options.endExponentMarker ?? "");
9652
9652
  }
9653
- return `10^{${exp2}}`;
9653
+ return `10^{${exp3}}`;
9654
9654
  }
9655
9655
  function serializeNumber(expr, options) {
9656
9656
  if (expr === null) return "";
@@ -9694,9 +9694,9 @@ var ComputeEngine = (() => {
9694
9694
  const [_, body, repeat2, trail] = num.match(/(.+)\(([0-9]+)\)(.*)$/) ?? [];
9695
9695
  num = body + repeat2.repeat(6) + trail;
9696
9696
  }
9697
- let sign2 = "";
9697
+ let sign3 = "";
9698
9698
  if (num[0] === "-") {
9699
- sign2 = "-";
9699
+ sign3 = "-";
9700
9700
  num = num.substring(1);
9701
9701
  } else if (num[0] === "+") {
9702
9702
  num = num.substring(1);
@@ -9712,25 +9712,25 @@ var ComputeEngine = (() => {
9712
9712
  } else if (options.notation === "adaptiveScientific") {
9713
9713
  result = serializeScientificNotationNumber(num, options);
9714
9714
  }
9715
- return sign2 + (result ?? serializeAutoNotationNumber(num, {
9715
+ return sign3 + (result ?? serializeAutoNotationNumber(num, {
9716
9716
  ...options
9717
9717
  }));
9718
9718
  }
9719
9719
  function serializeScientificNotationNumber(valString, options, expMultiple = 1) {
9720
9720
  let m = valString.match(/^(.*)[e|E]([-+]?[0-9]+)$/);
9721
9721
  if (!m) {
9722
- let sign2 = "";
9722
+ let sign3 = "";
9723
9723
  if (valString[0] === "-") {
9724
- sign2 = "-";
9724
+ sign3 = "-";
9725
9725
  valString = valString.substring(1);
9726
9726
  } else if (valString[0] === "+") {
9727
9727
  valString = valString.substring(1);
9728
9728
  }
9729
9729
  if (valString.indexOf(".") < 0) {
9730
9730
  if (valString.length === 1) {
9731
- valString = sign2 + valString + "e+0";
9731
+ valString = sign3 + valString + "e+0";
9732
9732
  } else {
9733
- valString = sign2 + valString[0] + "." + valString.slice(1) + "e+" + (valString.length - 1).toString();
9733
+ valString = sign3 + valString[0] + "." + valString.slice(1) + "e+" + (valString.length - 1).toString();
9734
9734
  }
9735
9735
  } else {
9736
9736
  let [_, whole, fraction] = valString.match(/^(.*)\.(.*)$/);
@@ -9740,20 +9740,20 @@ var ComputeEngine = (() => {
9740
9740
  let leadingZeros = 0;
9741
9741
  while (fraction[leadingZeros] === "0") leadingZeros++;
9742
9742
  if (leadingZeros === fraction.length) {
9743
- valString = sign2 + "0e+0";
9743
+ valString = sign3 + "0e+0";
9744
9744
  } else {
9745
9745
  const significand = fraction.slice(leadingZeros);
9746
9746
  const firstDigit = significand[0];
9747
9747
  const restDigits = significand.slice(1);
9748
9748
  const exponent2 = -(leadingZeros + 1);
9749
9749
  if (restDigits) {
9750
- valString = sign2 + firstDigit + "." + restDigits + "e" + exponent2;
9750
+ valString = sign3 + firstDigit + "." + restDigits + "e" + exponent2;
9751
9751
  } else {
9752
- valString = sign2 + firstDigit + "e" + exponent2;
9752
+ valString = sign3 + firstDigit + "e" + exponent2;
9753
9753
  }
9754
9754
  }
9755
9755
  } else {
9756
- valString = sign2 + whole[0] + "." + whole.slice(1) + fraction + "e+" + (whole.length - 1).toString();
9756
+ valString = sign3 + whole[0] + "." + whole.slice(1) + fraction + "e+" + (whole.length - 1).toString();
9757
9757
  }
9758
9758
  }
9759
9759
  m = valString.match(/^(.*)[e|E]([-+]?[0-9]+)$/);
@@ -9795,11 +9795,11 @@ var ComputeEngine = (() => {
9795
9795
  }
9796
9796
  function serializeAutoNotationNumber(valString, options) {
9797
9797
  let m = valString.match(/^(.*)[e|E]([-+]?[0-9]+)$/i);
9798
- let exp2 = 0;
9798
+ let exp3 = 0;
9799
9799
  let originalExp = 0;
9800
9800
  if (m?.[1] && m[2]) {
9801
- exp2 = parseInt(m[2]);
9802
- originalExp = exp2;
9801
+ exp3 = parseInt(m[2]);
9802
+ originalExp = exp3;
9803
9803
  valString = m[1];
9804
9804
  }
9805
9805
  let wholePart = m?.[1] ?? valString;
@@ -9809,23 +9809,23 @@ var ComputeEngine = (() => {
9809
9809
  wholePart = m[1];
9810
9810
  fractionalPart = m[2];
9811
9811
  }
9812
- if (exp2 !== 0 && fractionalPart) {
9812
+ if (exp3 !== 0 && fractionalPart) {
9813
9813
  wholePart += fractionalPart;
9814
- exp2 -= fractionalPart.length;
9814
+ exp3 -= fractionalPart.length;
9815
9815
  fractionalPart = "";
9816
9816
  }
9817
9817
  const avoid = options.avoidExponentsInRange;
9818
- if (exp2 !== 0 && avoid) {
9818
+ if (exp3 !== 0 && avoid) {
9819
9819
  if (originalExp >= avoid[0] && originalExp <= avoid[1]) {
9820
9820
  [wholePart, fractionalPart] = toDecimalNumber(
9821
9821
  wholePart,
9822
9822
  fractionalPart,
9823
- exp2
9823
+ exp3
9824
9824
  );
9825
- exp2 = 0;
9825
+ exp3 = 0;
9826
9826
  }
9827
9827
  }
9828
- const exponent = formatExponent(exp2.toString(), options);
9828
+ const exponent = formatExponent(exp3.toString(), options);
9829
9829
  if (fractionalPart)
9830
9830
  fractionalPart = options.decimalSeparator + formatFractionalPart(fractionalPart, wholePart.length, options);
9831
9831
  wholePart = insertWholeGroupSeparator(wholePart, options);
@@ -9878,10 +9878,10 @@ var ComputeEngine = (() => {
9878
9878
  function insertWholeGroupSeparator(numberString, options) {
9879
9879
  return insertGroupSeparator(numberString, options, 0);
9880
9880
  }
9881
- function toDecimalNumber(wholePart, fractionalPart, exp2) {
9881
+ function toDecimalNumber(wholePart, fractionalPart, exp3) {
9882
9882
  let combinedNumber = wholePart + fractionalPart;
9883
9883
  const wholeLength = wholePart.length;
9884
- const newDecimalPosition = wholeLength + exp2;
9884
+ const newDecimalPosition = wholeLength + exp3;
9885
9885
  let newWholePart;
9886
9886
  let newFractionalPart;
9887
9887
  if (newDecimalPosition > 0) {
@@ -9993,8 +9993,8 @@ var ComputeEngine = (() => {
9993
9993
  sups.push(sup);
9994
9994
  rest = rest2;
9995
9995
  } else if (rest.startsWith("_")) {
9996
- const [sub2, rest2] = parseSymbolBody2(rest.substring(1), false, "none");
9997
- subs.push(sub2);
9996
+ const [sub3, rest2] = parseSymbolBody2(rest.substring(1), false, "none");
9997
+ subs.push(sub3);
9998
9998
  rest = rest2;
9999
9999
  } else {
10000
10000
  break;
@@ -11542,13 +11542,13 @@ var ComputeEngine = (() => {
11542
11542
  return this.factory(this.bignumRe).pow(exponent);
11543
11543
  if (this.sign < 0) {
11544
11544
  if (Number.isInteger(exponent)) {
11545
- const sign2 = exponent % 2 === 0 ? 1 : -1;
11545
+ const sign3 = exponent % 2 === 0 ? 1 : -1;
11546
11546
  return this.clone({
11547
11547
  rational: isMachineRational(this.rational) ? [
11548
- sign2 * (-this.rational[0]) ** exponent,
11548
+ sign3 * (-this.rational[0]) ** exponent,
11549
11549
  this.rational[1] ** exponent
11550
11550
  ] : [
11551
- BigInt(sign2) * (-this.rational[0]) ** BigInt(exponent),
11551
+ BigInt(sign3) * (-this.rational[0]) ** BigInt(exponent),
11552
11552
  this.rational[1] ** BigInt(exponent)
11553
11553
  ],
11554
11554
  radical: this.radical ** exponent
@@ -11914,34 +11914,34 @@ var ComputeEngine = (() => {
11914
11914
  }
11915
11915
  return prod;
11916
11916
  }
11917
- function* powers(n, exp2) {
11917
+ function* powers(n, exp3) {
11918
11918
  if (n === 1) {
11919
- yield [exp2];
11919
+ yield [exp3];
11920
11920
  return;
11921
11921
  }
11922
- for (let i = 0; i <= exp2; i += 1)
11923
- for (const p of powers(n - 1, exp2 - i)) yield [i, ...p];
11922
+ for (let i = 0; i <= exp3; i += 1)
11923
+ for (const p of powers(n - 1, exp3 - i)) yield [i, ...p];
11924
11924
  }
11925
- function expandPower(base, exp2) {
11925
+ function expandPower(base, exp3) {
11926
11926
  const ce = base.engine;
11927
- if (exp2 < 0) {
11928
- const expr = expandPower(base, -exp2);
11927
+ if (exp3 < 0) {
11928
+ const expr = expandPower(base, -exp3);
11929
11929
  return expr ? expr.inv() : null;
11930
11930
  }
11931
- if (exp2 === 0) return ce.One;
11932
- if (exp2 === 1) return expand2(base);
11931
+ if (exp3 === 0) return ce.One;
11932
+ if (exp3 === 1) return expand2(base);
11933
11933
  if (base.operator === "Negate") {
11934
- if (Number.isInteger(exp2)) {
11935
- const sign2 = exp2 % 2 === 0 ? 1 : -1;
11936
- const result2 = expandPower(base.op1, exp2);
11934
+ if (Number.isInteger(exp3)) {
11935
+ const sign3 = exp3 % 2 === 0 ? 1 : -1;
11936
+ const result2 = expandPower(base.op1, exp3);
11937
11937
  if (result2 === null) return null;
11938
- return sign2 > 0 ? result2 : result2.neg();
11938
+ return sign3 > 0 ? result2 : result2.neg();
11939
11939
  }
11940
11940
  }
11941
11941
  console.assert(base.operator !== "Subtract");
11942
11942
  if (base.operator !== "Add") return null;
11943
11943
  const terms = base.ops;
11944
- const it = powers(terms.length, exp2);
11944
+ const it = powers(terms.length, exp3);
11945
11945
  const result = [];
11946
11946
  for (const val of it) {
11947
11947
  const product = [ce.number(multinomialCoefficient(val))];
@@ -11968,8 +11968,8 @@ var ComputeEngine = (() => {
11968
11968
  if (h === "Negate") return expand2(ops[0])?.neg() ?? null;
11969
11969
  if (h === "Add") return add3(...ops.map((x) => expand2(x) ?? x));
11970
11970
  if (h === "Power") {
11971
- const exp2 = asSmallInteger(ops[1]);
11972
- result = exp2 !== null ? expandPower(ops[0], exp2) : null;
11971
+ const exp3 = asSmallInteger(ops[1]);
11972
+ result = exp3 !== null ? expandPower(ops[0], exp3) : null;
11973
11973
  }
11974
11974
  return result;
11975
11975
  }
@@ -12014,22 +12014,22 @@ var ComputeEngine = (() => {
12014
12014
 
12015
12015
  // src/compute-engine/boxed-expression/negate.ts
12016
12016
  function canonicalNegate(expr) {
12017
- let sign2 = -1;
12017
+ let sign3 = -1;
12018
12018
  while (expr.operator === "Negate") {
12019
12019
  expr = expr.op1;
12020
- sign2 = -sign2;
12020
+ sign3 = -sign3;
12021
12021
  }
12022
- if (sign2 === 1) return expr;
12022
+ if (sign3 === 1) return expr;
12023
12023
  if (expr.isNumberLiteral) return expr.neg();
12024
12024
  return expr.engine._fn("Negate", [expr]);
12025
12025
  }
12026
12026
  function negate(expr) {
12027
- let sign2 = -1;
12027
+ let sign3 = -1;
12028
12028
  while (expr.operator === "Negate") {
12029
12029
  expr = expr.op1;
12030
- sign2 = -sign2;
12030
+ sign3 = -sign3;
12031
12031
  }
12032
- if (sign2 === 1) return expr;
12032
+ if (sign3 === 1) return expr;
12033
12033
  if (expr.numericValue !== null) return expr.neg();
12034
12034
  const ce = expr.engine;
12035
12035
  if (expr.operator === "Subtract") return expr.op2.sub(expr.op1);
@@ -12235,11 +12235,11 @@ var ComputeEngine = (() => {
12235
12235
  return result.asRationalExpression();
12236
12236
  }
12237
12237
  function canonicalMultiply(ce, ops) {
12238
- let sign2 = 1;
12238
+ let sign3 = 1;
12239
12239
  let xs = [];
12240
12240
  for (const op of ops) {
12241
12241
  const [o, s] = unnegate(op);
12242
- sign2 *= s;
12242
+ sign3 *= s;
12243
12243
  xs.push(o);
12244
12244
  }
12245
12245
  xs = xs.filter((x) => !x.is(1));
@@ -12303,7 +12303,7 @@ var ComputeEngine = (() => {
12303
12303
  }
12304
12304
  ys.push(x);
12305
12305
  }
12306
- if (sign2 < 0) {
12306
+ if (sign3 < 0) {
12307
12307
  if (ys.length === 0) return ce.number(-1);
12308
12308
  if (ys.length === 1) return ys[0].neg();
12309
12309
  return negateProduct(ce, ys);
@@ -12313,25 +12313,25 @@ var ComputeEngine = (() => {
12313
12313
  return ce._fn("Multiply", [...ys].sort(order));
12314
12314
  }
12315
12315
  function unnegate(op) {
12316
- let sign2 = 1;
12316
+ let sign3 = 1;
12317
12317
  while (op.operator === "Negate") {
12318
- sign2 = -sign2;
12318
+ sign3 = -sign3;
12319
12319
  op = op.op1;
12320
12320
  }
12321
12321
  if (op.isNumberLiteral && op.isNegative) {
12322
- sign2 = -sign2;
12322
+ sign3 = -sign3;
12323
12323
  op = op.neg();
12324
12324
  }
12325
- return [op, sign2];
12325
+ return [op, sign3];
12326
12326
  }
12327
12327
  function mul3(...xs) {
12328
12328
  console.assert(xs.length > 0);
12329
12329
  if (xs.length === 1) return xs[0];
12330
12330
  const ce = xs[0].engine;
12331
- const exp2 = expandProducts(ce, xs);
12332
- if (exp2) {
12333
- if (exp2.operator !== "Multiply") return exp2;
12334
- xs = exp2.ops;
12331
+ const exp3 = expandProducts(ce, xs);
12332
+ if (exp3) {
12333
+ if (exp3.operator !== "Multiply") return exp3;
12334
+ xs = exp3.ops;
12335
12335
  }
12336
12336
  return new Product(ce, xs).asRationalExpression();
12337
12337
  }
@@ -12339,10 +12339,10 @@ var ComputeEngine = (() => {
12339
12339
  console.assert(xs.length > 0);
12340
12340
  const ce = xs[0].engine;
12341
12341
  xs = xs.map((x) => x.N());
12342
- const exp2 = expandProducts(ce, xs);
12343
- if (exp2) {
12344
- if (exp2.operator !== "Multiply") return exp2;
12345
- xs = exp2.ops;
12342
+ const exp3 = expandProducts(ce, xs);
12343
+ if (exp3) {
12344
+ if (exp3.operator !== "Multiply") return exp3;
12345
+ xs = exp3.ops;
12346
12346
  }
12347
12347
  return new Product(ce, xs).asExpression({ numericApproximation: true });
12348
12348
  }
@@ -12670,25 +12670,25 @@ var ComputeEngine = (() => {
12670
12670
  im: chop2(newModulus.mul(newArgument.sin()).toNumber())
12671
12671
  });
12672
12672
  }
12673
- root(exp2) {
12674
- if (!Number.isInteger(exp2)) return this._makeExact(NaN);
12675
- if (exp2 === 0) return this._makeExact(NaN);
12676
- if (exp2 === 1) return this;
12673
+ root(exp3) {
12674
+ if (!Number.isInteger(exp3)) return this._makeExact(NaN);
12675
+ if (exp3 === 0) return this._makeExact(NaN);
12676
+ if (exp3 === 1) return this;
12677
12677
  if (this.isZero) return this;
12678
12678
  if (this.isOne) return this;
12679
12679
  if (this.isNegativeOne) return this;
12680
12680
  if (this.im === 0) {
12681
12681
  if (this.decimal.isNegative()) return this._makeExact(NaN);
12682
- if (exp2 === 2) return this.clone(this.decimal.sqrt());
12683
- if (exp2 === 3) return this.clone(this.decimal.cbrt());
12684
- return this.clone(this.decimal.pow(1 / exp2));
12682
+ if (exp3 === 2) return this.clone(this.decimal.sqrt());
12683
+ if (exp3 === 3) return this.clone(this.decimal.cbrt());
12684
+ return this.clone(this.decimal.pow(1 / exp3));
12685
12685
  }
12686
12686
  const a = this.decimal;
12687
12687
  const b = this.im;
12688
12688
  const modulus = a.mul(a).add(b * b).sqrt();
12689
12689
  const argument = Decimal.atan2(b, a);
12690
- const newModulus = modulus.pow(1 / exp2);
12691
- const newArgument = argument.div(exp2);
12690
+ const newModulus = modulus.pow(1 / exp3);
12691
+ const newArgument = argument.div(exp3);
12692
12692
  return this.clone({
12693
12693
  re: newModulus.mul(newArgument.cos()),
12694
12694
  im: chop2(newModulus.mul(newArgument.sin()).toNumber())
@@ -14103,12 +14103,12 @@ var ComputeEngine = (() => {
14103
14103
  const [m, n] = this.shape;
14104
14104
  if (m !== n) return void 0;
14105
14105
  if (m === 1) return this.data[0];
14106
- const add4 = this.field.add.bind(this.field);
14107
- const mul4 = this.field.mul.bind(this.field);
14106
+ const add5 = this.field.add.bind(this.field);
14107
+ const mul5 = this.field.mul.bind(this.field);
14108
14108
  const neg2 = this.field.neg.bind(this.field);
14109
14109
  if (m === 2) {
14110
14110
  const [a, b, c, d] = this.data;
14111
- return add4(mul4(a, d), neg2(mul4(b, c)));
14111
+ return add5(mul5(a, d), neg2(mul5(b, c)));
14112
14112
  }
14113
14113
  const addn = this.field.addn.bind(this.field);
14114
14114
  const muln = this.field.muln.bind(this.field);
@@ -14125,8 +14125,8 @@ var ComputeEngine = (() => {
14125
14125
  }
14126
14126
  const rows = this.shape[0];
14127
14127
  let negated = false;
14128
- const div3 = this.field.div.bind(this.field);
14129
- const sub2 = this.field.sub.bind(this.field);
14128
+ const div4 = this.field.div.bind(this.field);
14129
+ const sub3 = this.field.sub.bind(this.field);
14130
14130
  const rowIndices = new Array(rows).fill(0).map((_, i) => i);
14131
14131
  const matrix = [...this.data];
14132
14132
  for (let k = 0; k < rows; k++) {
@@ -14149,8 +14149,8 @@ var ComputeEngine = (() => {
14149
14149
  for (let i = k + 1; i < rows; i++) {
14150
14150
  const i_ = rowIndices[i - 1];
14151
14151
  for (let j = k + 1; j < rows; j++) {
14152
- matrix[i_][j] = div3(
14153
- sub2(mul4(matrix[i_][j], piv), mul4(matrix[i_][k], matrix[k_][j])),
14152
+ matrix[i_][j] = div4(
14153
+ sub3(mul5(matrix[i_][j], piv), mul5(matrix[i_][k], matrix[k_][j])),
14154
14154
  piv_
14155
14155
  );
14156
14156
  }
@@ -14167,13 +14167,13 @@ var ComputeEngine = (() => {
14167
14167
  const [a, b, c, d] = this.data;
14168
14168
  const det = this.determinant();
14169
14169
  if (det === void 0 || this.field.isZero(det)) return void 0;
14170
- const div4 = this.field.div.bind(this.field);
14170
+ const div5 = this.field.div.bind(this.field);
14171
14171
  const neg2 = this.field.neg.bind(this.field);
14172
14172
  const inverseData2 = [
14173
- div4(d, det),
14174
- neg2(div4(b, det)),
14175
- neg2(div4(c, det)),
14176
- div4(a, det)
14173
+ div5(d, det),
14174
+ neg2(div5(b, det)),
14175
+ neg2(div5(c, det)),
14176
+ div5(a, det)
14177
14177
  ];
14178
14178
  return makeTensor(this.ce, {
14179
14179
  dtype: this.dtype,
@@ -14182,9 +14182,9 @@ var ComputeEngine = (() => {
14182
14182
  });
14183
14183
  }
14184
14184
  const rows = this.shape[0];
14185
- const div3 = this.field.div.bind(this.field);
14186
- const sub2 = this.field.sub.bind(this.field);
14187
- const mul4 = this.field.mul.bind(this.field);
14185
+ const div4 = this.field.div.bind(this.field);
14186
+ const sub3 = this.field.sub.bind(this.field);
14187
+ const mul5 = this.field.mul.bind(this.field);
14188
14188
  const matrix = this.array;
14189
14189
  const identity = new Array(rows).fill(0).map((_, i) => {
14190
14190
  const row = new Array(rows).fill(0);
@@ -14212,9 +14212,9 @@ var ComputeEngine = (() => {
14212
14212
  for (let i = k + 1; i < rows; i++) {
14213
14213
  const i_ = rowIndices[i - 1];
14214
14214
  for (let j = k + 1; j < rows * 2; j++) {
14215
- augmented[i_][j] = sub2(
14215
+ augmented[i_][j] = sub3(
14216
14216
  augmented[i_][j],
14217
- mul4(div3(mul4(augmented[i_][k], augmented[k_][j]), piv), piv_)
14217
+ mul5(div4(mul5(augmented[i_][k], augmented[k_][j]), piv), piv_)
14218
14218
  );
14219
14219
  }
14220
14220
  }
@@ -14224,14 +14224,14 @@ var ComputeEngine = (() => {
14224
14224
  for (let i = 0; i < k; i++) {
14225
14225
  const i_ = rowIndices[i];
14226
14226
  for (let j = rows; j < rows * 2; j++) {
14227
- augmented[i_][j] = sub2(
14227
+ augmented[i_][j] = sub3(
14228
14228
  augmented[i_][j],
14229
- mul4(div3(mul4(augmented[i_][k], augmented[k][j]), piv), piv)
14229
+ mul5(div4(mul5(augmented[i_][k], augmented[k][j]), piv), piv)
14230
14230
  );
14231
14231
  }
14232
14232
  }
14233
14233
  for (let j = rows; j < rows * 2; j++) {
14234
- augmented[k][j] = div3(augmented[k][j], piv);
14234
+ augmented[k][j] = div4(augmented[k][j], piv);
14235
14235
  }
14236
14236
  }
14237
14237
  const inverseData = augmented.map(
@@ -14597,11 +14597,11 @@ var ComputeEngine = (() => {
14597
14597
  div(rhs) {
14598
14598
  return this.structural.div(rhs);
14599
14599
  }
14600
- pow(exp2) {
14601
- return this.structural.pow(exp2);
14600
+ pow(exp3) {
14601
+ return this.structural.pow(exp3);
14602
14602
  }
14603
- root(exp2) {
14604
- return this.structural.root(exp2);
14603
+ root(exp3) {
14604
+ return this.structural.root(exp3);
14605
14605
  }
14606
14606
  sqrt() {
14607
14607
  return this.structural.sqrt();
@@ -14936,9 +14936,9 @@ var ComputeEngine = (() => {
14936
14936
  if (expr.op2.has(variable)) return -1;
14937
14937
  return 0;
14938
14938
  }
14939
- const exp2 = asSmallInteger(expr.op2);
14940
- if (exp2 === null || exp2 < 0) return -1;
14941
- return baseDeg * exp2;
14939
+ const exp3 = asSmallInteger(expr.op2);
14940
+ if (exp3 === null || exp3 < 0) return -1;
14941
+ return baseDeg * exp3;
14942
14942
  }
14943
14943
  if (expr.has(variable)) return -1;
14944
14944
  return 0;
@@ -14979,9 +14979,9 @@ var ComputeEngine = (() => {
14979
14979
  }
14980
14980
  if (term.operator === "Power") {
14981
14981
  if (term.op1.symbol === variable) {
14982
- const exp2 = asSmallInteger(term.op2);
14983
- if (exp2 !== null && exp2 >= 0) {
14984
- return addCoefficient(ce.One, exp2);
14982
+ const exp3 = asSmallInteger(term.op2);
14983
+ if (exp3 !== null && exp3 >= 0) {
14984
+ return addCoefficient(ce.One, exp3);
14985
14985
  }
14986
14986
  }
14987
14987
  if (!term.op1.has(variable)) {
@@ -14999,9 +14999,9 @@ var ComputeEngine = (() => {
14999
14999
  } else if (factor3.symbol === variable) {
15000
15000
  varDeg += 1;
15001
15001
  } else if (factor3.operator === "Power" && factor3.op1.symbol === variable) {
15002
- const exp2 = asSmallInteger(factor3.op2);
15003
- if (exp2 !== null && exp2 >= 0) {
15004
- varDeg += exp2;
15002
+ const exp3 = asSmallInteger(factor3.op2);
15003
+ if (exp3 !== null && exp3 >= 0) {
15004
+ varDeg += exp3;
15005
15005
  } else {
15006
15006
  return false;
15007
15007
  }
@@ -15360,13 +15360,13 @@ var ComputeEngine = (() => {
15360
15360
  }
15361
15361
  function canonicalRoot(a, b) {
15362
15362
  const ce = a.engine;
15363
- let exp2 = void 0;
15364
- if (typeof b === "number") exp2 = b;
15363
+ let exp3 = void 0;
15364
+ if (typeof b === "number") exp3 = b;
15365
15365
  else {
15366
- if (b.isNumberLiteral && b.im === 0) exp2 = b.re;
15366
+ if (b.isNumberLiteral && b.im === 0) exp3 = b.re;
15367
15367
  }
15368
- if (exp2 === 1) return a;
15369
- if (exp2 === 2) {
15368
+ if (exp3 === 1) return a;
15369
+ if (exp3 === 2) {
15370
15370
  if (a.isNumberLiteral && a.type.matches("rational")) {
15371
15371
  if (a.re < SMALL_INTEGER) {
15372
15372
  const v = a.sqrt();
@@ -15380,86 +15380,86 @@ var ComputeEngine = (() => {
15380
15380
  canonical: a.isCanonical && (typeof b === "number" || b.isCanonical)
15381
15381
  });
15382
15382
  }
15383
- function pow2(x, exp2, { numericApproximation }) {
15384
- if (!x.isCanonical || typeof exp2 !== "number" && !exp2.isCanonical)
15385
- return x.engine._fn("Power", [x, x.engine.box(exp2)], { canonical: false });
15383
+ function pow2(x, exp3, { numericApproximation }) {
15384
+ if (!x.isCanonical || typeof exp3 !== "number" && !exp3.isCanonical)
15385
+ return x.engine._fn("Power", [x, x.engine.box(exp3)], { canonical: false });
15386
15386
  if (numericApproximation) {
15387
15387
  if (x.isNumberLiteral) {
15388
- if (typeof exp2 === "number") {
15388
+ if (typeof exp3 === "number") {
15389
15389
  return apply(
15390
15390
  x,
15391
- (x2) => Math.pow(x2, exp2),
15392
- (x2) => x2.pow(exp2),
15393
- (x2) => x2.pow(exp2)
15394
- ) ?? pow2(x, exp2, { numericApproximation: false });
15395
- } else if (exp2.isNumberLiteral)
15391
+ (x2) => Math.pow(x2, exp3),
15392
+ (x2) => x2.pow(exp3),
15393
+ (x2) => x2.pow(exp3)
15394
+ ) ?? pow2(x, exp3, { numericApproximation: false });
15395
+ } else if (exp3.isNumberLiteral)
15396
15396
  return apply2(
15397
15397
  x,
15398
- exp2,
15399
- (x2, exp3) => Math.pow(x2, exp3),
15400
- (x2, exp3) => x2.pow(exp3),
15401
- (x2, exp3) => x2.pow(exp3)
15402
- ) ?? pow2(x, exp2, { numericApproximation: false });
15398
+ exp3,
15399
+ (x2, exp4) => Math.pow(x2, exp4),
15400
+ (x2, exp4) => x2.pow(exp4),
15401
+ (x2, exp4) => x2.pow(exp4)
15402
+ ) ?? pow2(x, exp3, { numericApproximation: false });
15403
15403
  }
15404
15404
  }
15405
15405
  const ce = x.engine;
15406
- if (typeof exp2 !== "number") exp2 = exp2.canonical;
15407
- const canonicalResult = canonicalPower(x, ce.box(exp2));
15406
+ if (typeof exp3 !== "number") exp3 = exp3.canonical;
15407
+ const canonicalResult = canonicalPower(x, ce.box(exp3));
15408
15408
  if (canonicalResult.operator !== "Power") return canonicalResult;
15409
- const e = typeof exp2 === "number" ? exp2 : exp2.im === 0 ? exp2.re : void 0;
15409
+ const e = typeof exp3 === "number" ? exp3 : exp3.im === 0 ? exp3.re : void 0;
15410
15410
  if (x.symbol === "ComplexInfinity") return ce.NaN;
15411
15411
  if (x.symbol === "ExponentialE") {
15412
- let theta = getImaginaryFactor(exp2);
15412
+ let theta = getImaginaryFactor(exp3);
15413
15413
  if (theta !== void 0) {
15414
15414
  theta = canonicalAngle(theta);
15415
15415
  if (theta !== void 0) {
15416
15416
  return ce.function("Cos", [theta]).add(ce.function("Sin", [theta]).mul(ce.I)).simplify();
15417
15417
  }
15418
15418
  } else {
15419
- if (typeof exp2 === "number") {
15420
- return ce.number(ce._numericValue(ce.E.N().numericValue).pow(exp2));
15421
- } else if (exp2.isNumberLiteral) {
15419
+ if (typeof exp3 === "number") {
15420
+ return ce.number(ce._numericValue(ce.E.N().numericValue).pow(exp3));
15421
+ } else if (exp3.isNumberLiteral) {
15422
15422
  return ce.number(
15423
- ce._numericValue(ce.E.N().numericValue).pow(exp2.numericValue)
15423
+ ce._numericValue(ce.E.N().numericValue).pow(exp3.numericValue)
15424
15424
  );
15425
15425
  }
15426
15426
  }
15427
15427
  }
15428
15428
  if (x.operator === "Power") {
15429
15429
  const [base, power] = x.ops;
15430
- return pow2(base, power.mul(exp2), { numericApproximation });
15430
+ return pow2(base, power.mul(exp3), { numericApproximation });
15431
15431
  }
15432
15432
  if (x.operator === "Divide") {
15433
15433
  const [num, denom] = x.ops;
15434
- return pow2(num, exp2, { numericApproximation }).div(
15435
- pow2(denom, exp2, { numericApproximation })
15434
+ return pow2(num, exp3, { numericApproximation }).div(
15435
+ pow2(denom, exp3, { numericApproximation })
15436
15436
  );
15437
15437
  }
15438
15438
  if (x.operator === "Negate") {
15439
15439
  if (e !== void 0) {
15440
- if (e % 2 === 0) return pow2(x.op1, exp2, { numericApproximation });
15441
- return pow2(x.op1, exp2, { numericApproximation }).neg();
15440
+ if (e % 2 === 0) return pow2(x.op1, exp3, { numericApproximation });
15441
+ return pow2(x.op1, exp3, { numericApproximation }).neg();
15442
15442
  }
15443
15443
  }
15444
15444
  if (x.operator === "Sqrt") {
15445
15445
  if (e === 2) return x.op1;
15446
15446
  if (e !== void 0 && e % 2 === 0) return x.op1.pow(e / 2);
15447
- return pow2(x.op1, exp2, { numericApproximation }).sqrt();
15447
+ return pow2(x.op1, exp3, { numericApproximation }).sqrt();
15448
15448
  }
15449
15449
  if (x.operator === "Exp")
15450
- return pow2(ce.E, x.op1.mul(exp2), { numericApproximation });
15450
+ return pow2(ce.E, x.op1.mul(exp3), { numericApproximation });
15451
15451
  if (x.operator === "Multiply") {
15452
- const ops = x.ops.map((x2) => pow2(x2, exp2, { numericApproximation }));
15452
+ const ops = x.ops.map((x2) => pow2(x2, exp3, { numericApproximation }));
15453
15453
  return ce._fn("Multiply", ops);
15454
15454
  }
15455
- if (typeof exp2 !== "number" && exp2.isNumberLiteral) {
15456
- const r = asRational(exp2);
15455
+ if (typeof exp3 !== "number" && exp3.isNumberLiteral) {
15456
+ const r = asRational(exp3);
15457
15457
  if (r !== void 0 && r[0] === 1)
15458
15458
  return root(x, ce.number(r[1]), { numericApproximation });
15459
15459
  }
15460
15460
  if (x.operator === "Root") {
15461
15461
  const [base, root2] = x.ops;
15462
- return pow2(base, ce.box(exp2).div(root2), { numericApproximation });
15462
+ return pow2(base, ce.box(exp3).div(root2), { numericApproximation });
15463
15463
  }
15464
15464
  if (x.isNumberLiteral && Number.isInteger(e)) {
15465
15465
  const n = x.numericValue;
@@ -15469,37 +15469,37 @@ var ComputeEngine = (() => {
15469
15469
  (x2) => Math.pow(x2, e),
15470
15470
  (x2) => x2.pow(e),
15471
15471
  (x2) => x2.pow(e)
15472
- ) ?? ce._fn("Power", [x, ce.box(exp2)]);
15472
+ ) ?? ce._fn("Power", [x, ce.box(exp3)]);
15473
15473
  } else {
15474
15474
  return ce.number(n.pow(e));
15475
15475
  }
15476
15476
  }
15477
- return ce._fn("Power", [x, ce.box(exp2)]);
15477
+ return ce._fn("Power", [x, ce.box(exp3)]);
15478
15478
  }
15479
15479
  function root(a, b, { numericApproximation }) {
15480
15480
  if (!a.isCanonical || !b.isCanonical)
15481
15481
  return a.engine._fn("Root", [a, b], { canonical: false });
15482
15482
  if (numericApproximation) {
15483
15483
  if (a.isNumberLiteral && b.isNumberLiteral) {
15484
- const isNegative = a.isNegative;
15484
+ const isNegative2 = a.isNegative;
15485
15485
  const isEven = b.isEven;
15486
- if (isNegative) a = a.neg();
15486
+ if (isNegative2) a = a.neg();
15487
15487
  return apply2(
15488
15488
  a,
15489
15489
  b,
15490
15490
  (a2, b2) => {
15491
15491
  const result = Math.pow(a2, 1 / b2);
15492
- if (isNegative && !isEven) return -result;
15492
+ if (isNegative2 && !isEven) return -result;
15493
15493
  return result;
15494
15494
  },
15495
15495
  (a2, b2) => {
15496
15496
  const result = a2.pow(b2.pow(-1));
15497
- if (isNegative && !isEven) return result.neg();
15497
+ if (isNegative2 && !isEven) return result.neg();
15498
15498
  return result;
15499
15499
  },
15500
15500
  (a2, b2) => {
15501
15501
  const result = a2.pow(typeof b2 === "number" ? 1 / b2 : b2.inverse());
15502
- if (isNegative && !isEven) return result.neg();
15502
+ if (isNegative2 && !isEven) return result.neg();
15503
15503
  return result;
15504
15504
  }
15505
15505
  ) ?? root(a, b, { numericApproximation: false });
@@ -15845,7 +15845,7 @@ var ComputeEngine = (() => {
15845
15845
  * If `this._isCanonical` a running product of exact terms is kept.
15846
15846
  * Otherwise, terms and their exponent are tallied.
15847
15847
  */
15848
- mul(term, exp2) {
15848
+ mul(term, exp3) {
15849
15849
  console.assert(term.isCanonical || term.isStructural);
15850
15850
  if (this.coefficient.isNaN) return;
15851
15851
  if (term.isNaN) {
@@ -15853,17 +15853,17 @@ var ComputeEngine = (() => {
15853
15853
  return;
15854
15854
  }
15855
15855
  if (term.operator === "Multiply") {
15856
- for (const t of term.ops) this.mul(t, exp2);
15856
+ for (const t of term.ops) this.mul(t, exp3);
15857
15857
  return;
15858
15858
  }
15859
15859
  if (term.operator === "Negate") {
15860
- this.mul(term.op1, exp2);
15860
+ this.mul(term.op1, exp3);
15861
15861
  this.coefficient = this.coefficient.neg();
15862
15862
  return;
15863
15863
  }
15864
15864
  if (this._isCanonical) {
15865
15865
  if (term.symbol === "Nothing") return;
15866
- exp2 ??= [1, 1];
15866
+ exp3 ??= [1, 1];
15867
15867
  const num = term.numericValue;
15868
15868
  if (num !== null) {
15869
15869
  if (term.is(1)) return;
@@ -15872,14 +15872,14 @@ var ComputeEngine = (() => {
15872
15872
  this.coefficient = this.engine._numericValue(NaN);
15873
15873
  return;
15874
15874
  }
15875
- this.coefficient = this.engine._numericValue(isZero(exp2) ? NaN : 0);
15875
+ this.coefficient = this.engine._numericValue(isZero(exp3) ? NaN : 0);
15876
15876
  return;
15877
15877
  }
15878
15878
  if (term.is(-1)) {
15879
- if (isOne(exp2)) this.coefficient = this.coefficient.neg();
15879
+ if (isOne(exp3)) this.coefficient = this.coefficient.neg();
15880
15880
  else {
15881
15881
  this.coefficient = this.coefficient.mul(
15882
- this.engine._numericValue(-1).pow(this.engine._numericValue(exp2))
15882
+ this.engine._numericValue(-1).pow(this.engine._numericValue(exp3))
15883
15883
  );
15884
15884
  }
15885
15885
  return;
@@ -15889,21 +15889,21 @@ var ComputeEngine = (() => {
15889
15889
  this.coefficient = this.engine._numericValue(NaN);
15890
15890
  return;
15891
15891
  }
15892
- if (isOne(exp2)) {
15892
+ if (isOne(exp3)) {
15893
15893
  const coefSign = this.coefficient.sgn();
15894
15894
  const termSign = term.isNegative ? -1 : 1;
15895
15895
  const resultSign = coefSign * termSign;
15896
15896
  this.coefficient = this.engine._numericValue(
15897
15897
  resultSign < 0 ? -Infinity : Infinity
15898
15898
  );
15899
- } else this.terms.push({ term, exponent: exp2 });
15899
+ } else this.terms.push({ term, exponent: exp3 });
15900
15900
  return;
15901
15901
  }
15902
- if (isOne(exp2)) {
15902
+ if (isOne(exp3)) {
15903
15903
  this.coefficient = this.coefficient.mul(num);
15904
15904
  } else
15905
15905
  this.coefficient = this.coefficient.mul(
15906
- this.engine._numericValue(num).pow(this.engine._numericValue(exp2))
15906
+ this.engine._numericValue(num).pow(this.engine._numericValue(exp3))
15907
15907
  );
15908
15908
  return;
15909
15909
  }
@@ -15913,7 +15913,7 @@ var ComputeEngine = (() => {
15913
15913
  this.engine._numericValue({
15914
15914
  radical: radical[0] * radical[1],
15915
15915
  rational: [1, Number(radical[1])]
15916
- }).pow(this.engine._numericValue(exp2))
15916
+ }).pow(this.engine._numericValue(exp3))
15917
15917
  );
15918
15918
  return;
15919
15919
  }
@@ -15922,20 +15922,20 @@ var ComputeEngine = (() => {
15922
15922
  if (!isSymbolicRadical) {
15923
15923
  let coef;
15924
15924
  [coef, term] = term.toNumericValue();
15925
- if (exp2 && !isOne(exp2))
15926
- coef = coef.pow(this.engine._numericValue(exp2));
15925
+ if (exp3 && !isOne(exp3))
15926
+ coef = coef.pow(this.engine._numericValue(exp3));
15927
15927
  this.coefficient = this.coefficient.mul(coef);
15928
15928
  }
15929
15929
  }
15930
15930
  }
15931
- if (term.is(1) && (!exp2 || isOne(exp2))) return;
15932
- if (term.is(0) === false && exp2 && isZero(exp2)) return;
15931
+ if (term.is(1) && (!exp3 || isOne(exp3))) return;
15932
+ if (term.is(0) === false && exp3 && isZero(exp3)) return;
15933
15933
  if (term.is(0)) {
15934
- if (exp2 && isZero(exp2)) this.coefficient = this.engine._numericValue(NaN);
15934
+ if (exp3 && isZero(exp3)) this.coefficient = this.engine._numericValue(NaN);
15935
15935
  else this.coefficient = this.engine._numericValue(0);
15936
15936
  return;
15937
15937
  }
15938
- const exponent = exp2 ?? [1, 1];
15938
+ const exponent = exp3 ?? [1, 1];
15939
15939
  if (term.operator === "Power") {
15940
15940
  const r = asRational(term.op2);
15941
15941
  if (r) {
@@ -16135,8 +16135,8 @@ var ComputeEngine = (() => {
16135
16135
  function serializePrettyJsonFunction(ce, name, args, options, metadata) {
16136
16136
  const exclusions = options.exclude;
16137
16137
  if (name === "Add" && args.length === 2 && !exclusions.includes("Subtract")) {
16138
- const sub2 = serializeSubtract(ce, args[0], args[1], options, metadata) ?? serializeSubtract(ce, args[1], args[0], options, metadata);
16139
- if (sub2) return sub2;
16138
+ const sub3 = serializeSubtract(ce, args[0], args[1], options, metadata) ?? serializeSubtract(ce, args[1], args[0], options, metadata);
16139
+ if (sub3) return sub3;
16140
16140
  }
16141
16141
  if (name === "Divide" && args.length === 2 && exclusions.includes("Divide")) {
16142
16142
  return serializeJsonFunction(
@@ -16177,8 +16177,8 @@ var ComputeEngine = (() => {
16177
16177
  if (!exclusions.includes("Exp") && args[0]?.symbol === "ExponentialE")
16178
16178
  return serializeJsonFunction(ce, "Exp", [args[1]], options, metadata);
16179
16179
  if (args[1]?.numericValue !== null) {
16180
- const exp2 = asSmallInteger(args[1]);
16181
- if (exp2 === 2 && !exclusions.includes("Square"))
16180
+ const exp3 = asSmallInteger(args[1]);
16181
+ if (exp3 === 2 && !exclusions.includes("Square"))
16182
16182
  return serializeJsonFunction(
16183
16183
  ce,
16184
16184
  "Square",
@@ -16186,11 +16186,11 @@ var ComputeEngine = (() => {
16186
16186
  options,
16187
16187
  metadata
16188
16188
  );
16189
- if (exp2 !== null && exp2 < 0 && !exclusions.includes("Divide")) {
16189
+ if (exp3 !== null && exp3 < 0 && !exclusions.includes("Divide")) {
16190
16190
  return serializeJsonFunction(
16191
16191
  ce,
16192
16192
  "Divide",
16193
- [ce.One, exp2 === -1 ? args[0] : args[0].pow(-exp2)],
16193
+ [ce.One, exp3 === -1 ? args[0] : args[0].pow(-exp3)],
16194
16194
  options,
16195
16195
  metadata
16196
16196
  );
@@ -20529,10 +20529,10 @@ var ComputeEngine = (() => {
20529
20529
  div(rhs) {
20530
20530
  return this.engine.NaN;
20531
20531
  }
20532
- pow(exp2) {
20532
+ pow(exp3) {
20533
20533
  return this.engine.NaN;
20534
20534
  }
20535
- root(exp2) {
20535
+ root(exp3) {
20536
20536
  return this.engine.NaN;
20537
20537
  }
20538
20538
  sqrt() {
@@ -21073,7 +21073,7 @@ var ComputeEngine = (() => {
21073
21073
  `Invalid rule "${rule}"
21074
21074
  | The condition expression contains wildcards not present in the match expression`
21075
21075
  );
21076
- condFn = (sub2) => condition.subs(sub2).canonical.evaluate()?.symbol === "True";
21076
+ condFn = (sub3) => condition.subs(sub3).canonical.evaluate()?.symbol === "True";
21077
21077
  }
21078
21078
  return boxRule(ce, { match: match2, replace: replace2, condition: condFn, id: rule }, options);
21079
21079
  }
@@ -21219,19 +21219,19 @@ ${e.message}
21219
21219
  const useVariations = rule.useVariations ?? options?.useVariations ?? false;
21220
21220
  const matchPermutations = options?.matchPermutations ?? true;
21221
21221
  onBeforeMatch?.(rule, expr);
21222
- const sub2 = match2 ? expr.match(match2, {
21222
+ const sub3 = match2 ? expr.match(match2, {
21223
21223
  substitution,
21224
21224
  useVariations,
21225
21225
  recursive: false,
21226
21226
  matchPermutations
21227
21227
  }) : {};
21228
- if (sub2 === null) return operandsMatched ? { value: expr, because } : null;
21228
+ if (sub3 === null) return operandsMatched ? { value: expr, because } : null;
21229
21229
  if (typeof condition === "function") {
21230
21230
  const conditionSub = {
21231
21231
  ...Object.fromEntries(
21232
- Object.entries(sub2).map(([k, v]) => [k.slice(1), v])
21232
+ Object.entries(sub3).map(([k, v]) => [k.slice(1), v])
21233
21233
  ),
21234
- ...sub2
21234
+ ...sub3
21235
21235
  };
21236
21236
  try {
21237
21237
  if (!condition(conditionSub, expr.engine))
@@ -21248,7 +21248,7 @@ ${e.message}
21248
21248
  }
21249
21249
  if (!canonical2 && options?.canonical === void 0 && replace2 instanceof _BoxedExpression && replace2.isCanonical)
21250
21250
  canonical2 = true;
21251
- const result = typeof replace2 === "function" ? replace2(expr, sub2) : replace2.subs(sub2, { canonical: canonical2 });
21251
+ const result = typeof replace2 === "function" ? replace2(expr, sub3) : replace2.subs(sub3, { canonical: canonical2 });
21252
21252
  if (!result) return null;
21253
21253
  onMatch?.(rule, expr, result);
21254
21254
  if (isRuleStep(result))
@@ -21293,10 +21293,10 @@ ${e.message}`);
21293
21293
  }
21294
21294
  return steps;
21295
21295
  }
21296
- function matchAnyRules(expr, rules, sub2, options) {
21296
+ function matchAnyRules(expr, rules, sub3, options) {
21297
21297
  const results = [];
21298
21298
  for (const rule of rules.rules) {
21299
- const r = applyRule(rule, expr, sub2, options);
21299
+ const r = applyRule(rule, expr, sub3, options);
21300
21300
  if (r !== null && !results.some((x) => x.isSame(r.value)))
21301
21301
  results.push(r.value);
21302
21302
  }
@@ -21393,8 +21393,8 @@ ${e.message}`);
21393
21393
  });
21394
21394
 
21395
21395
  // src/compute-engine/boxed-expression/solve.ts
21396
- function filter(sub2) {
21397
- for (const [k, v] of Object.entries(sub2)) {
21396
+ function filter(sub3) {
21397
+ for (const [k, v] of Object.entries(sub3)) {
21398
21398
  if (k !== "x" && k !== "_x" && v.has("_x")) return false;
21399
21399
  }
21400
21400
  return true;
@@ -21788,7 +21788,7 @@ ${e.message}`);
21788
21788
  ["Divide", 1, "_n"]
21789
21789
  ],
21790
21790
  useVariations: true,
21791
- condition: (sub2) => filter(sub2) && !sub2._n.is(0)
21791
+ condition: (sub3) => filter(sub3) && !sub3._n.is(0)
21792
21792
  },
21793
21793
  {
21794
21794
  match: ["Add", ["Multiply", "_a", ["Power", "_x", "_n"]], "__b"],
@@ -21797,7 +21797,7 @@ ${e.message}`);
21797
21797
  ["Power", ["Divide", ["Negate", "__b"], "_a"], ["Divide", 1, "_n"]]
21798
21798
  ],
21799
21799
  useVariations: true,
21800
- condition: (sub2) => filter(sub2) && !sub2._n.is(0) && (sub2._n.isEven ?? false)
21800
+ condition: (sub3) => filter(sub3) && !sub3._n.is(0) && (sub3._n.isEven ?? false)
21801
21801
  },
21802
21802
  //
21803
21803
  // Quadratic without constant: ax^2 + bx = 0
@@ -21879,7 +21879,7 @@ ${e.message}`);
21879
21879
  useVariations: true,
21880
21880
  onBeforeMatch: () => {
21881
21881
  },
21882
- condition: (sub2) => filter(sub2) && (sub2._a.isPositive ?? false) && (sub2.__b.isNegative ?? false)
21882
+ condition: (sub3) => filter(sub3) && (sub3._a.isPositive ?? false) && (sub3.__b.isNegative ?? false)
21883
21883
  },
21884
21884
  // a * e^(bx) + c = 0
21885
21885
  {
@@ -21890,42 +21890,42 @@ ${e.message}`);
21890
21890
  ],
21891
21891
  replace: ["Divide", ["Ln", ["Negate", ["Divide", "__c", "__a"]]], "__b"],
21892
21892
  useVariations: true,
21893
- condition: (sub2) => filter(sub2) && ((!sub2.__a.is(0) && sub2.__c.div(sub2.__a).isNegative) ?? false)
21893
+ condition: (sub3) => filter(sub3) && ((!sub3.__a.is(0) && sub3.__c.div(sub3.__a).isNegative) ?? false)
21894
21894
  },
21895
21895
  // a * e^(x) + c = 0
21896
21896
  {
21897
21897
  match: ["Add", ["Multiply", "__a", ["Exp", "_x"]], "__c"],
21898
21898
  replace: ["Ln", ["Negate", ["Divide", "__c", "__a"]]],
21899
21899
  useVariations: true,
21900
- condition: (sub2) => filter(sub2) && ((!sub2.__a.is(0) && sub2.__c.div(sub2.__a).isNegative) ?? false) && !sub2.__a.has("_x") && !sub2.__c.has("_x")
21900
+ condition: (sub3) => filter(sub3) && ((!sub3.__a.is(0) && sub3.__c.div(sub3.__a).isNegative) ?? false) && !sub3.__a.has("_x") && !sub3.__c.has("_x")
21901
21901
  },
21902
21902
  // e^(x) + c = 0
21903
21903
  {
21904
21904
  match: ["Add", ["Exp", "_x"], "__c"],
21905
21905
  replace: ["Ln", ["Negate", "__c"]],
21906
21906
  useVariations: true,
21907
- condition: (sub2) => filter(sub2) && (sub2.__c.isNegative ?? false)
21907
+ condition: (sub3) => filter(sub3) && (sub3.__c.isNegative ?? false)
21908
21908
  },
21909
21909
  // e^(bx) + c = 0
21910
21910
  {
21911
21911
  match: ["Add", ["Exp", ["Multiply", "__b", "_x"]], "__c"],
21912
21912
  replace: ["Divide", ["Ln", ["Negate", "__c"]], "__b"],
21913
21913
  useVariations: true,
21914
- condition: (sub2) => filter(sub2) && (sub2.__c.isNegative ?? false)
21914
+ condition: (sub3) => filter(sub3) && (sub3.__c.isNegative ?? false)
21915
21915
  },
21916
21916
  // a * log_b(x) + c = 0
21917
21917
  {
21918
21918
  match: ["Add", ["Multiply", "__a", ["Log", "_x", "__b"]], "__c"],
21919
21919
  replace: ["Power", "__b", ["Negate", ["Divide", "__c", "__a"]]],
21920
21920
  useVariations: true,
21921
- condition: (sub2) => (filter(sub2) && !sub2.__a.is(0) && sub2.__b.isPositive) ?? false
21921
+ condition: (sub3) => (filter(sub3) && !sub3.__a.is(0) && sub3.__b.isPositive) ?? false
21922
21922
  },
21923
21923
  // a * log_b(x) = 0
21924
21924
  {
21925
21925
  match: ["Multiply", "__a", ["Log", "_x", "__b"]],
21926
21926
  replace: ["Power", "__b", ["Negate", ["Divide", "__c", "__a"]]],
21927
21927
  useVariations: true,
21928
- condition: (sub2) => (filter(sub2) && !sub2.__a.is(0) && sub2.__b.isPositive) ?? false
21928
+ condition: (sub3) => (filter(sub3) && !sub3.__a.is(0) && sub3.__b.isPositive) ?? false
21929
21929
  },
21930
21930
  // |ax + b| + c = 0
21931
21931
  {
@@ -22055,10 +22055,10 @@ ${e.message}`);
22055
22055
  match: ["Add", ["Multiply", "__a", ["Sqrt", "_x"]], "__b"],
22056
22056
  replace: ["Square", ["Divide", ["Negate", "__b"], "__a"]],
22057
22057
  useVariations: true,
22058
- condition: (sub2) => {
22059
- if (!filter(sub2)) return false;
22060
- const a = sub2.__a;
22061
- const b = sub2.__b;
22058
+ condition: (sub3) => {
22059
+ if (!filter(sub3)) return false;
22060
+ const a = sub3.__a;
22061
+ const b = sub3.__b;
22062
22062
  if (!a || !b) return false;
22063
22063
  const ratio = b.div(a);
22064
22064
  return ratio.isNonPositive ?? true;
@@ -22090,10 +22090,10 @@ ${e.message}`);
22090
22090
  match: ["Add", ["Multiply", "__a", ["Sin", "_x"]], "__b"],
22091
22091
  replace: ["Arcsin", ["Divide", ["Negate", "__b"], "__a"]],
22092
22092
  useVariations: true,
22093
- condition: (sub2) => {
22094
- if (!filter(sub2)) return false;
22095
- const a = sub2.__a;
22096
- const b = sub2.__b;
22093
+ condition: (sub3) => {
22094
+ if (!filter(sub3)) return false;
22095
+ const a = sub3.__a;
22096
+ const b = sub3.__b;
22097
22097
  if (!a || a.is(0)) return false;
22098
22098
  const ratio = b.div(a).neg();
22099
22099
  const val = ratio.numericValue;
@@ -22111,10 +22111,10 @@ ${e.message}`);
22111
22111
  ["Arcsin", ["Divide", ["Negate", "__b"], "__a"]]
22112
22112
  ],
22113
22113
  useVariations: true,
22114
- condition: (sub2) => {
22115
- if (!filter(sub2)) return false;
22116
- const a = sub2.__a;
22117
- const b = sub2.__b;
22114
+ condition: (sub3) => {
22115
+ if (!filter(sub3)) return false;
22116
+ const a = sub3.__a;
22117
+ const b = sub3.__b;
22118
22118
  if (!a || a.is(0)) return false;
22119
22119
  const ratio = b.div(a).neg();
22120
22120
  const val = ratio.numericValue;
@@ -22128,9 +22128,9 @@ ${e.message}`);
22128
22128
  match: ["Add", ["Sin", "_x"], "__b"],
22129
22129
  replace: ["Arcsin", ["Negate", "__b"]],
22130
22130
  useVariations: true,
22131
- condition: (sub2) => {
22132
- if (!filter(sub2)) return false;
22133
- const b = sub2.__b;
22131
+ condition: (sub3) => {
22132
+ if (!filter(sub3)) return false;
22133
+ const b = sub3.__b;
22134
22134
  const val = b.numericValue;
22135
22135
  if (val === null) return true;
22136
22136
  if (typeof val === "number") return Math.abs(val) <= 1;
@@ -22142,9 +22142,9 @@ ${e.message}`);
22142
22142
  match: ["Add", ["Sin", "_x"], "__b"],
22143
22143
  replace: ["Subtract", "Pi", ["Arcsin", ["Negate", "__b"]]],
22144
22144
  useVariations: true,
22145
- condition: (sub2) => {
22146
- if (!filter(sub2)) return false;
22147
- const b = sub2.__b;
22145
+ condition: (sub3) => {
22146
+ if (!filter(sub3)) return false;
22147
+ const b = sub3.__b;
22148
22148
  const val = b.numericValue;
22149
22149
  if (val === null) return true;
22150
22150
  if (typeof val === "number") return Math.abs(val) <= 1;
@@ -22157,10 +22157,10 @@ ${e.message}`);
22157
22157
  match: ["Add", ["Multiply", "__a", ["Cos", "_x"]], "__b"],
22158
22158
  replace: ["Arccos", ["Divide", ["Negate", "__b"], "__a"]],
22159
22159
  useVariations: true,
22160
- condition: (sub2) => {
22161
- if (!filter(sub2)) return false;
22162
- const a = sub2.__a;
22163
- const b = sub2.__b;
22160
+ condition: (sub3) => {
22161
+ if (!filter(sub3)) return false;
22162
+ const a = sub3.__a;
22163
+ const b = sub3.__b;
22164
22164
  if (!a || a.is(0)) return false;
22165
22165
  const ratio = b.div(a).neg();
22166
22166
  const val = ratio.numericValue;
@@ -22174,10 +22174,10 @@ ${e.message}`);
22174
22174
  match: ["Add", ["Multiply", "__a", ["Cos", "_x"]], "__b"],
22175
22175
  replace: ["Negate", ["Arccos", ["Divide", ["Negate", "__b"], "__a"]]],
22176
22176
  useVariations: true,
22177
- condition: (sub2) => {
22178
- if (!filter(sub2)) return false;
22179
- const a = sub2.__a;
22180
- const b = sub2.__b;
22177
+ condition: (sub3) => {
22178
+ if (!filter(sub3)) return false;
22179
+ const a = sub3.__a;
22180
+ const b = sub3.__b;
22181
22181
  if (!a || a.is(0)) return false;
22182
22182
  const ratio = b.div(a).neg();
22183
22183
  const val = ratio.numericValue;
@@ -22191,9 +22191,9 @@ ${e.message}`);
22191
22191
  match: ["Add", ["Cos", "_x"], "__b"],
22192
22192
  replace: ["Arccos", ["Negate", "__b"]],
22193
22193
  useVariations: true,
22194
- condition: (sub2) => {
22195
- if (!filter(sub2)) return false;
22196
- const b = sub2.__b;
22194
+ condition: (sub3) => {
22195
+ if (!filter(sub3)) return false;
22196
+ const b = sub3.__b;
22197
22197
  const val = b.numericValue;
22198
22198
  if (val === null) return true;
22199
22199
  if (typeof val === "number") return Math.abs(val) <= 1;
@@ -22205,9 +22205,9 @@ ${e.message}`);
22205
22205
  match: ["Add", ["Cos", "_x"], "__b"],
22206
22206
  replace: ["Negate", ["Arccos", ["Negate", "__b"]]],
22207
22207
  useVariations: true,
22208
- condition: (sub2) => {
22209
- if (!filter(sub2)) return false;
22210
- const b = sub2.__b;
22208
+ condition: (sub3) => {
22209
+ if (!filter(sub3)) return false;
22210
+ const b = sub3.__b;
22211
22211
  const val = b.numericValue;
22212
22212
  if (val === null) return true;
22213
22213
  if (typeof val === "number") return Math.abs(val) <= 1;
@@ -22220,9 +22220,9 @@ ${e.message}`);
22220
22220
  match: ["Add", ["Multiply", "__a", ["Tan", "_x"]], "__b"],
22221
22221
  replace: ["Arctan", ["Divide", ["Negate", "__b"], "__a"]],
22222
22222
  useVariations: true,
22223
- condition: (sub2) => {
22224
- if (!filter(sub2)) return false;
22225
- return !sub2.__a.is(0);
22223
+ condition: (sub3) => {
22224
+ if (!filter(sub3)) return false;
22225
+ return !sub3.__a.is(0);
22226
22226
  }
22227
22227
  },
22228
22228
  // tan(x) + b = 0 => x = arctan(-b) (when a = 1)
@@ -22237,9 +22237,9 @@ ${e.message}`);
22237
22237
  match: ["Add", ["Multiply", "__a", ["Cot", "_x"]], "__b"],
22238
22238
  replace: ["Arccot", ["Divide", ["Negate", "__b"], "__a"]],
22239
22239
  useVariations: true,
22240
- condition: (sub2) => {
22241
- if (!filter(sub2)) return false;
22242
- return !sub2.__a.is(0);
22240
+ condition: (sub3) => {
22241
+ if (!filter(sub3)) return false;
22242
+ return !sub3.__a.is(0);
22243
22243
  }
22244
22244
  },
22245
22245
  // cot(x) + b = 0 => x = arccot(-b)
@@ -24167,11 +24167,11 @@ ${lines.join("\n")}`;
24167
24167
  const a4 = -1.453152027;
24168
24168
  const a5 = 1.061405429;
24169
24169
  const p = 0.3275911;
24170
- const sign2 = x < 0 ? -1 : 1;
24170
+ const sign3 = x < 0 ? -1 : 1;
24171
24171
  x = Math.abs(x);
24172
24172
  const t = 1 / (1 + p * x);
24173
24173
  const y = ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t;
24174
- return sign2 * (1 - y * Math.exp(-x * x));
24174
+ return sign3 * (1 - y * Math.exp(-x * x));
24175
24175
  }
24176
24176
  function bigGammaln(ce, z) {
24177
24177
  if (z.isNegative()) return ce._BIGNUM_NAN;
@@ -25007,19 +25007,19 @@ ${lines.join("\n")}`;
25007
25007
  broadcastable: true,
25008
25008
  complexity: 3500,
25009
25009
  signature: "(number, number) -> number",
25010
- type: ([base, exp2]) => {
25011
- if (base.isNaN || exp2.isNaN) return "number";
25012
- if (!exp2.isFinite) return "non_finite_number";
25013
- if (base.isInteger && exp2.isInteger) return "finite_integer";
25014
- if (base.isRational && exp2.isInteger) return "finite_rational";
25015
- if (base.isReal && exp2.isReal) return "finite_real";
25010
+ type: ([base, exp3]) => {
25011
+ if (base.isNaN || exp3.isNaN) return "number";
25012
+ if (!exp3.isFinite) return "non_finite_number";
25013
+ if (base.isInteger && exp3.isInteger) return "finite_integer";
25014
+ if (base.isRational && exp3.isInteger) return "finite_rational";
25015
+ if (base.isReal && exp3.isReal) return "finite_real";
25016
25016
  return "finite_number";
25017
25017
  },
25018
25018
  canonical: (args, { engine }) => {
25019
25019
  args = checkNumericArgs(engine, args, 2);
25020
25020
  if (args.length !== 2) return engine._fn("Power", args);
25021
- const [base, exp2] = args;
25022
- return canonicalPower(base, exp2);
25021
+ const [base, exp3] = args;
25022
+ return canonicalPower(base, exp3);
25023
25023
  },
25024
25024
  sgn: ([a, b]) => {
25025
25025
  const aSgn = a.sgn;
@@ -25092,13 +25092,13 @@ ${lines.join("\n")}`;
25092
25092
  complexity: 3200,
25093
25093
  broadcastable: true,
25094
25094
  signature: "(number, number) -> number",
25095
- type: ([base, exp2]) => {
25096
- if (base.isNaN || exp2.isNaN) return "number";
25097
- if (base.isFinite === false || exp2.isFinite === false)
25095
+ type: ([base, exp3]) => {
25096
+ if (base.isNaN || exp3.isNaN) return "number";
25097
+ if (base.isFinite === false || exp3.isFinite === false)
25098
25098
  return "non_finite_number";
25099
- if (exp2.is(0)) return "finite_integer";
25100
- if (exp2.is(1)) return base.type;
25101
- if (base.isReal && exp2.isReal) {
25099
+ if (exp3.is(0)) return "finite_integer";
25100
+ if (exp3.is(1)) return base.type;
25101
+ if (base.isReal && exp3.isReal) {
25102
25102
  if (base.isPositive === true) return "finite_real";
25103
25103
  return "finite_number";
25104
25104
  }
@@ -25122,8 +25122,8 @@ ${lines.join("\n")}`;
25122
25122
  },
25123
25123
  canonical: (args, { engine }) => {
25124
25124
  args = checkNumericArgs(engine, args, 2);
25125
- const [base, exp2] = args;
25126
- return canonicalRoot(base, exp2);
25125
+ const [base, exp3] = args;
25126
+ return canonicalRoot(base, exp3);
25127
25127
  },
25128
25128
  evaluate: ([x, n], { numericApproximation }) => root(x, n, { numericApproximation })
25129
25129
  },
@@ -25994,9 +25994,9 @@ ${lines.join("\n")}`;
25994
25994
  for (let i = 2; i < last; i++) {
25995
25995
  arg = ops[i - 1];
25996
25996
  if (serializer.options.prettify) {
25997
- const [newArg, sign2] = unsign(arg);
25997
+ const [newArg, sign3] = unsign(arg);
25998
25998
  const term = serializer.wrap(newArg, ADDITION_PRECEDENCE);
25999
- if (sign2 > 0) {
25999
+ if (sign3 > 0) {
26000
26000
  if (term.startsWith("+") || term.startsWith("-")) result += term;
26001
26001
  else result += "+" + term;
26002
26002
  } else {
@@ -26038,7 +26038,7 @@ ${lines.join("\n")}`;
26038
26038
  serializer.level += 1;
26039
26039
  return result;
26040
26040
  }
26041
- let isNegative = false;
26041
+ let isNegative2 = false;
26042
26042
  let arg = null;
26043
26043
  const count = nops(expr) + 1;
26044
26044
  let xs = operands(expr);
@@ -26058,11 +26058,11 @@ ${lines.join("\n")}`;
26058
26058
  term = serializer.serialize(arg);
26059
26059
  if (term === "-1" && !result) {
26060
26060
  result = "";
26061
- isNegative = !isNegative;
26061
+ isNegative2 = !isNegative2;
26062
26062
  } else {
26063
26063
  if (term[0] === "-") {
26064
26064
  term = term.slice(1);
26065
- isNegative = !isNegative;
26065
+ isNegative2 = !isNegative2;
26066
26066
  }
26067
26067
  if (!result) result = term;
26068
26068
  else result = latexTemplate(serializer.options.multiply, result, term);
@@ -26095,7 +26095,7 @@ ${lines.join("\n")}`;
26095
26095
  }
26096
26096
  if (operator(arg) === "Negate") {
26097
26097
  arg = operand(arg, 1);
26098
- isNegative = !isNegative;
26098
+ isNegative2 = !isNegative2;
26099
26099
  }
26100
26100
  term = serializer.wrap(arg, MULTIPLICATION_PRECEDENCE);
26101
26101
  if (!result) {
@@ -26117,7 +26117,7 @@ ${lines.join("\n")}`;
26117
26117
  prevWasNumber = false;
26118
26118
  }
26119
26119
  serializer.level += 1;
26120
- return isNegative ? "-" + result : result;
26120
+ return isNegative2 ? "-" + result : result;
26121
26121
  }
26122
26122
  function parseFraction(parser) {
26123
26123
  let numer = parser.parseGroup();
@@ -26221,26 +26221,26 @@ ${lines.join("\n")}`;
26221
26221
  2
26222
26222
  );
26223
26223
  }
26224
- const exp2 = missingIfEmpty(operand(expr, 2));
26224
+ const exp3 = missingIfEmpty(operand(expr, 2));
26225
26225
  if (name === "Root")
26226
26226
  return serializeRoot(
26227
26227
  serializer,
26228
26228
  serializer.rootStyle(expr, serializer.level - 1),
26229
26229
  base,
26230
- exp2
26230
+ exp3
26231
26231
  );
26232
26232
  if (serializer.options.prettify) {
26233
- const val2 = machineValue(exp2) ?? 1;
26233
+ const val2 = machineValue(exp3) ?? 1;
26234
26234
  if (val2 === -1) {
26235
26235
  return serializer.serialize(["Divide", "1", base]);
26236
26236
  } else if (val2 < 0) {
26237
26237
  return serializer.serialize(["Divide", "1", ["Power", base, -val2]]);
26238
- } else if (operator(exp2) === "Divide" || operator(exp2) === "Rational") {
26239
- const num = machineValue(operand(exp2, 1));
26240
- const denom = machineValue(operand(exp2, 2));
26238
+ } else if (operator(exp3) === "Divide" || operator(exp3) === "Rational") {
26239
+ const num = machineValue(operand(exp3, 1));
26240
+ const denom = machineValue(operand(exp3, 2));
26241
26241
  if (num === 1) {
26242
26242
  const style = serializer.rootStyle(expr, serializer.level);
26243
- return serializeRoot(serializer, style, base, operand(exp2, 2));
26243
+ return serializeRoot(serializer, style, base, operand(exp3, 2));
26244
26244
  }
26245
26245
  if (num === -1) {
26246
26246
  if (denom === 2) {
@@ -26249,18 +26249,18 @@ ${lines.join("\n")}`;
26249
26249
  return serializer.serialize([
26250
26250
  "Divide",
26251
26251
  "1",
26252
- ["Root", base, operand(exp2, 2)]
26252
+ ["Root", base, operand(exp3, 2)]
26253
26253
  ]);
26254
26254
  }
26255
26255
  if (denom === 2) {
26256
26256
  return `${serializer.serialize(["Sqrt", base])}^{${serializer.serialize(
26257
- operand(exp2, 1)
26257
+ operand(exp3, 1)
26258
26258
  )}}`;
26259
26259
  }
26260
- } else if (operator(exp2) === "Power") {
26261
- if (machineValue(operand(exp2, 2)) === -1) {
26260
+ } else if (operator(exp3) === "Power") {
26261
+ if (machineValue(operand(exp3, 2)) === -1) {
26262
26262
  const style = serializer.rootStyle(expr, serializer.level);
26263
- return serializeRoot(serializer, style, base, operand(exp2, 1));
26263
+ return serializeRoot(serializer, style, base, operand(exp3, 1));
26264
26264
  }
26265
26265
  }
26266
26266
  }
@@ -26271,12 +26271,12 @@ ${lines.join("\n")}`;
26271
26271
  const baseBodyLatex = wrapNegativeBase(serializer.wrapShort(baseBody));
26272
26272
  const baseExponentLatex = serializer.wrapShort(baseExponent);
26273
26273
  return `
26274
- ${baseBodyLatex}^{${supsub("^", baseExponentLatex, serializer.serialize(exp2))}}`;
26274
+ ${baseBodyLatex}^{${supsub("^", baseExponentLatex, serializer.serialize(exp3))}}`;
26275
26275
  }
26276
26276
  return supsub(
26277
26277
  "^",
26278
26278
  wrapNegativeBase(serializer.wrapShort(base)),
26279
- serializer.serialize(exp2)
26279
+ serializer.serialize(exp3)
26280
26280
  );
26281
26281
  }
26282
26282
  var DEFINITIONS_ARITHMETIC = [
@@ -27093,10 +27093,10 @@ ${lines.join("\n")}`;
27093
27093
  }
27094
27094
  return [expr];
27095
27095
  }
27096
- function getIndexes(sub2, sup) {
27097
- if (isEmptySequence(sub2)) sub2 = null;
27096
+ function getIndexes(sub3, sup) {
27097
+ if (isEmptySequence(sub3)) sub3 = null;
27098
27098
  if (isEmptySequence(sup)) sup = null;
27099
- const subs = getSequenceOrTuple(sub2);
27099
+ const subs = getSequenceOrTuple(sub3);
27100
27100
  const sups = getSequenceOrTuple(sup);
27101
27101
  const results = [];
27102
27102
  let i = 0;
@@ -27130,20 +27130,20 @@ ${lines.join("\n")}`;
27130
27130
  parser.skipSpace();
27131
27131
  parser.pushSymbolTable();
27132
27132
  let sup = null;
27133
- let sub2 = null;
27134
- while (!(sub2 && sup) && (parser.peek === "_" || parser.peek === "^")) {
27135
- if (parser.match("_")) sub2 = parser.parseGroup() ?? parser.parseToken();
27133
+ let sub3 = null;
27134
+ while (!(sub3 && sup) && (parser.peek === "_" || parser.peek === "^")) {
27135
+ if (parser.match("_")) sub3 = parser.parseGroup() ?? parser.parseToken();
27136
27136
  else if (parser.match("^"))
27137
27137
  sup = parser.parseGroup() ?? parser.parseToken();
27138
27138
  parser.skipSpace();
27139
27139
  }
27140
- if (!sup && !sub2) {
27140
+ if (!sup && !sub3) {
27141
27141
  const collection = parser.parseExpression({ minPrec });
27142
27142
  parser.popSymbolTable();
27143
27143
  if (collection) return ["Reduce", collection, reduceOp];
27144
27144
  return null;
27145
27145
  }
27146
- const indexes = getIndexes(sub2, sup);
27146
+ const indexes = getIndexes(sub3, sup);
27147
27147
  const fn = parser.parseExpression({ minPrec });
27148
27148
  parser.popSymbolTable();
27149
27149
  if (fn === null) return [name];
@@ -27237,47 +27237,47 @@ ${lines.join("\n")}`;
27237
27237
  };
27238
27238
  }
27239
27239
  function parseLog(command, parser) {
27240
- let sub2 = null;
27241
- if (parser.match("_")) sub2 = parser.parseGroup() ?? parser.parseToken();
27240
+ let sub3 = null;
27241
+ if (parser.match("_")) sub3 = parser.parseGroup() ?? parser.parseToken();
27242
27242
  const args = parser.parseArguments("implicit");
27243
- if (args === null && sub2 === null) return [command];
27244
- if (args === null) return [command, sub2];
27245
- if (sub2 === null) return [command, ...args];
27246
- if (sub2 === 10) return ["Log", args[0]];
27247
- if (sub2 === 2) return ["Lb", ...args];
27248
- return ["Log", args[0], sub2];
27243
+ if (args === null && sub3 === null) return [command];
27244
+ if (args === null) return [command, sub3];
27245
+ if (sub3 === null) return [command, ...args];
27246
+ if (sub3 === 10) return ["Log", args[0]];
27247
+ if (sub3 === 2) return ["Lb", ...args];
27248
+ return ["Log", args[0], sub3];
27249
27249
  }
27250
27250
  function unsign(expr) {
27251
- let sign2 = 1;
27251
+ let sign3 = 1;
27252
27252
  let newExpr = expr;
27253
27253
  do {
27254
27254
  expr = newExpr;
27255
27255
  const fnName = operator(expr);
27256
27256
  if (fnName === "Negate") {
27257
- sign2 *= -1;
27257
+ sign3 *= -1;
27258
27258
  newExpr = operand(expr, 1);
27259
27259
  } else if (fnName === "Multiply") {
27260
27260
  const [first, firstSign] = unsign(operand(expr, 1));
27261
27261
  if (firstSign < 0) {
27262
- sign2 *= -1;
27262
+ sign3 *= -1;
27263
27263
  if (first === 1) newExpr = ["Multiply", ...operands(expr).slice(1)];
27264
27264
  else newExpr = ["Multiply", first, ...operands(expr).slice(1)];
27265
27265
  }
27266
27266
  } else if (fnName === "Divide" || fnName === "Rational") {
27267
27267
  const [numer, numerSign] = unsign(operand(expr, 1));
27268
27268
  if (numerSign < 0) {
27269
- sign2 *= -1;
27269
+ sign3 *= -1;
27270
27270
  newExpr = [fnName, numer, operand(expr, 2)];
27271
27271
  }
27272
27272
  } else {
27273
27273
  const val = machineValue(expr);
27274
27274
  if (val !== null && val < 0) {
27275
- sign2 *= -1;
27275
+ sign3 *= -1;
27276
27276
  newExpr = -val;
27277
27277
  }
27278
27278
  }
27279
27279
  } while (newExpr !== expr);
27280
- return [expr, sign2];
27280
+ return [expr, sign3];
27281
27281
  }
27282
27282
 
27283
27283
  // src/compute-engine/latex-syntax/dictionary/definitions.ts
@@ -28101,26 +28101,26 @@ ${lines.join("\n")}`;
28101
28101
  parse: (parser) => {
28102
28102
  let done = false;
28103
28103
  let sup = "Nothing";
28104
- let sub2 = "Nothing";
28104
+ let sub3 = "Nothing";
28105
28105
  while (!done) {
28106
28106
  parser.skipSpace();
28107
28107
  if (parser.match("_")) {
28108
- sub2 = parser.parseGroup() ?? parser.parseToken();
28108
+ sub3 = parser.parseGroup() ?? parser.parseToken();
28109
28109
  } else if (parser.match("^")) {
28110
28110
  sup = parser.parseGroup() ?? parser.parseToken();
28111
28111
  } else {
28112
28112
  done = true;
28113
28113
  }
28114
28114
  }
28115
- const seq = getSequence(sub2);
28116
- if (seq) sub2 = ["List", ...seq];
28117
- if (sub2 === null || sup === null) return null;
28115
+ const seq = getSequence(sub3);
28116
+ if (seq) sub3 = ["List", ...seq];
28117
+ if (sub3 === null || sup === null) return null;
28118
28118
  let rhs = parser.parseGroup() ?? "Nothing";
28119
28119
  if (!isEmptySequence(rhs)) {
28120
28120
  const args = parser.parseArguments() ?? ["Nothing"];
28121
28121
  rhs = [rhs, ...args];
28122
28122
  }
28123
- return ["PartialDerivative", rhs, sub2, sup];
28123
+ return ["PartialDerivative", rhs, sub3, sup];
28124
28124
  },
28125
28125
  serialize: (serializer, expr) => {
28126
28126
  let result = "\\partial";
@@ -29351,17 +29351,17 @@ ${lines.join("\n")}`;
29351
29351
  parser.match("\\limits");
29352
29352
  parser.skipSpace();
29353
29353
  let sup = null;
29354
- let sub2 = null;
29355
- while (!(sub2 !== null && sup !== null) && (parser.peek === "_" || parser.peek === "^")) {
29356
- if (parser.match("_")) sub2 = parser.parseGroup() ?? parser.parseToken();
29354
+ let sub3 = null;
29355
+ while (!(sub3 !== null && sup !== null) && (parser.peek === "_" || parser.peek === "^")) {
29356
+ if (parser.match("_")) sub3 = parser.parseGroup() ?? parser.parseToken();
29357
29357
  else if (parser.match("^")) {
29358
29358
  sup = parser.parseGroup() ?? parser.parseToken();
29359
29359
  }
29360
29360
  parser.skipSpace();
29361
29361
  }
29362
- if (isEmptySequence(sub2)) sub2 = null;
29362
+ if (isEmptySequence(sub3)) sub3 = null;
29363
29363
  if (isEmptySequence(sup)) sup = null;
29364
- subs.push(sub2 ?? "Nothing");
29364
+ subs.push(sub3 ?? "Nothing");
29365
29365
  sups.push(sup ?? "Nothing");
29366
29366
  parser.skipVisualSpace();
29367
29367
  done = !parser.match(command);
@@ -29428,9 +29428,9 @@ ${lines.join("\n")}`;
29428
29428
  }
29429
29429
  const tuples = indexes.map((idx, i) => {
29430
29430
  const sup = limits.sups[i];
29431
- const sub2 = limits.subs[i];
29432
- if (sub2 === "Nothing" && sup === "Nothing") return idx;
29433
- return ["Tuple", idx, sub2, sup];
29431
+ const sub3 = limits.subs[i];
29432
+ if (sub3 === "Nothing" && sup === "Nothing") return idx;
29433
+ return ["Tuple", idx, sub3, sup];
29434
29434
  });
29435
29435
  return [command, fn, ...tuples];
29436
29436
  }
@@ -30465,9 +30465,9 @@ ${lines.join("\n")}`;
30465
30465
  while (!parser.atEnd) {
30466
30466
  if (parser.match("_")) {
30467
30467
  const hasBrace = parser.match("<{>");
30468
- const sub2 = parseSymbolBody(parser);
30469
- if (hasBrace && !parser.match("<}>") || sub2 === null) return null;
30470
- subs.push(sub2);
30468
+ const sub3 = parseSymbolBody(parser);
30469
+ if (hasBrace && !parser.match("<}>") || sub3 === null) return null;
30470
+ subs.push(sub3);
30471
30471
  } else if (parser.match("^")) {
30472
30472
  const hasBrace = parser.match("<{>");
30473
30473
  const sup = parseSymbolBody(parser);
@@ -30532,14 +30532,14 @@ ${lines.join("\n")}`;
30532
30532
  parser.index = underscoreIndex;
30533
30533
  break;
30534
30534
  }
30535
- const sub2 = parseSymbolBody(parser);
30536
- const hasOperators = sub2 !== null && /plus|minus|times|ast/.test(sub2);
30537
- if (sub2 === null || sub2.includes(",") || hasOperators || parser.peek !== "<}>") {
30535
+ const sub3 = parseSymbolBody(parser);
30536
+ const hasOperators = sub3 !== null && /plus|minus|times|ast/.test(sub3);
30537
+ if (sub3 === null || sub3.includes(",") || hasOperators || parser.peek !== "<}>") {
30538
30538
  parser.index = underscoreIndex;
30539
30539
  break;
30540
30540
  }
30541
30541
  parser.match("<}>");
30542
- id2 += "_" + sub2;
30542
+ id2 += "_" + sub3;
30543
30543
  } else {
30544
30544
  const subToken = parser.peek;
30545
30545
  if (/^[a-zA-Z0-9]$/.test(subToken) || /^\p{XIDS}$/u.test(subToken)) {
@@ -31371,10 +31371,10 @@ ${lines.join("\n")}`;
31371
31371
  *
31372
31372
  */
31373
31373
  parseOptionalSign() {
31374
- let isNegative = !!this.matchAny(["-", "\u2212"]);
31374
+ let isNegative2 = !!this.matchAny(["-", "\u2212"]);
31375
31375
  while (this.matchAny(["+", "\uFE62"]) || this.skipSpace())
31376
- if (this.matchAny(["-", "\u2212"])) isNegative = !isNegative;
31377
- return isNegative ? "-" : "+";
31376
+ if (this.matchAny(["-", "\u2212"])) isNegative2 = !isNegative2;
31377
+ return isNegative2 ? "-" : "+";
31378
31378
  }
31379
31379
  /** Parse a sequence of decimal digits. The part indicates which
31380
31380
  * grouping separator should be expected.
@@ -31406,9 +31406,9 @@ ${lines.join("\n")}`;
31406
31406
  */
31407
31407
  parseSignedInteger(part) {
31408
31408
  const start = this.index;
31409
- const sign2 = this.parseOptionalSign();
31409
+ const sign3 = this.parseOptionalSign();
31410
31410
  const result = this.parseDecimalDigits(part);
31411
- if (result) return sign2 === "-" ? "-" + result : result;
31411
+ if (result) return sign3 === "-" ? "-" + result : result;
31412
31412
  this.index = start;
31413
31413
  return "";
31414
31414
  }
@@ -31511,9 +31511,9 @@ ${lines.join("\n")}`;
31511
31511
  return null;
31512
31512
  const start = this.index;
31513
31513
  this.skipVisualSpace();
31514
- let sign2 = 1;
31514
+ let sign3 = 1;
31515
31515
  while (this.peek === "-" || this.peek === "+") {
31516
- if (this.match("-")) sign2 = -sign2;
31516
+ if (this.match("-")) sign3 = -sign3;
31517
31517
  else this.match("+");
31518
31518
  this.skipVisualSpace();
31519
31519
  }
@@ -31550,34 +31550,66 @@ ${lines.join("\n")}`;
31550
31550
  if (hasFractionalPart && !fractionalPart) {
31551
31551
  this.index = fractionalIndex;
31552
31552
  if (wholePart.length < 10)
31553
- return numberExpression(sign2 * parseInt(wholePart, 10));
31554
- return { num: sign2 < 0 ? "-" + wholePart : wholePart };
31553
+ return numberExpression(sign3 * parseInt(wholePart, 10));
31554
+ return { num: sign3 < 0 ? "-" + wholePart : wholePart };
31555
31555
  }
31556
31556
  const exponent = this.parseExponent();
31557
31557
  if (!hasFractionalPart && !exponent && wholePart.length < 10)
31558
- return numberExpression(sign2 * parseInt(wholePart, 10));
31558
+ return numberExpression(sign3 * parseInt(wholePart, 10));
31559
31559
  if (!hasRepeatingPart && this.options.parseNumbers === "rational") {
31560
- const whole = parseInt(wholePart, 10);
31560
+ const isLargeInteger = wholePart.length > 16 || wholePart.length === 16 && wholePart > "9007199254740991";
31561
31561
  if (!fractionalPart) {
31562
+ if (isLargeInteger) {
31563
+ const numStr = sign3 < 0 ? "-" + wholePart : wholePart;
31564
+ if (exponent)
31565
+ return ["Multiply", { num: numStr }, ["Power", 10, exponent]];
31566
+ return { num: numStr };
31567
+ }
31568
+ const whole2 = parseInt(wholePart, 10);
31562
31569
  if (exponent)
31563
- return ["Multiply", sign2 * whole, ["Power", 10, exponent]];
31564
- return numberExpression(sign2 * whole);
31570
+ return ["Multiply", sign3 * whole2, ["Power", 10, exponent]];
31571
+ return numberExpression(sign3 * whole2);
31565
31572
  }
31566
- const fraction = parseInt(fractionalPart, 10);
31567
31573
  const n = fractionalPart.length;
31574
+ const numeratorDigits = wholePart.length + n;
31575
+ if (numeratorDigits > 15) {
31576
+ const wholeBig = BigInt(wholePart);
31577
+ const fractionBig = BigInt(fractionalPart);
31578
+ const denominatorBig = BigInt(10) ** BigInt(n);
31579
+ const numeratorBig = wholeBig * denominatorBig + fractionBig;
31580
+ const signedNumerator = sign3 < 0 ? -numeratorBig : numeratorBig;
31581
+ if (exponent) {
31582
+ return [
31583
+ "Multiply",
31584
+ [
31585
+ "Rational",
31586
+ { num: signedNumerator.toString() },
31587
+ Number(denominatorBig)
31588
+ ],
31589
+ ["Power", 10, exponent]
31590
+ ];
31591
+ }
31592
+ return [
31593
+ "Rational",
31594
+ { num: signedNumerator.toString() },
31595
+ Number(denominatorBig)
31596
+ ];
31597
+ }
31598
+ const whole = parseInt(wholePart, 10);
31599
+ const fraction = parseInt(fractionalPart, 10);
31568
31600
  const numerator = whole * 10 ** n + fraction;
31569
31601
  const denominator = 10 ** n;
31570
31602
  if (exponent) {
31571
31603
  return [
31572
31604
  "Multiply",
31573
- ["Rational", sign2 * numerator, denominator],
31605
+ ["Rational", sign3 * numerator, denominator],
31574
31606
  ["Power", 10, exponent]
31575
31607
  ];
31576
31608
  }
31577
- return ["Rational", sign2 * numerator, denominator];
31609
+ return ["Rational", sign3 * numerator, denominator];
31578
31610
  }
31579
31611
  return {
31580
- num: (sign2 < 0 ? "-" : "") + wholePart + (hasFractionalPart ? "." + fractionalPart : "") + (exponent ? "e" + exponent : "")
31612
+ num: (sign3 < 0 ? "-" : "") + wholePart + (hasFractionalPart ? "." + fractionalPart : "") + (exponent ? "e" + exponent : "")
31581
31613
  };
31582
31614
  }
31583
31615
  parsePrefixOperator(until) {
@@ -31903,12 +31935,12 @@ ${lines.join("\n")}`;
31903
31935
  if (this.match("_") || this.match("^"))
31904
31936
  subscripts.push(this.error("syntax-error", subIndex));
31905
31937
  else {
31906
- let sub2 = this.parseGroup() ?? this.parseToken();
31907
- if (sub2 === null && this.options.strict === false && this.peek === "(")
31908
- sub2 = this.parseEnclosure();
31909
- sub2 ??= this.parseStringGroup();
31910
- if (sub2 === null) return this.error("missing", index);
31911
- subscripts.push(sub2);
31938
+ let sub3 = this.parseGroup() ?? this.parseToken();
31939
+ if (sub3 === null && this.options.strict === false && this.peek === "(")
31940
+ sub3 = this.parseEnclosure();
31941
+ sub3 ??= this.parseStringGroup();
31942
+ if (sub3 === null) return this.error("missing", index);
31943
+ subscripts.push(sub3);
31912
31944
  }
31913
31945
  } else if (this.match("^")) {
31914
31946
  subIndex = this.index;
@@ -33019,8 +33051,8 @@ ${lines.join("\n")}`;
33019
33051
  }
33020
33052
  return null;
33021
33053
  }
33022
- function filter2(sub2) {
33023
- for (const [k, v] of Object.entries(sub2)) {
33054
+ function filter2(sub3) {
33055
+ for (const [k, v] of Object.entries(sub3)) {
33024
33056
  if (k !== "x" && k !== "_x" && v.has("_x")) return false;
33025
33057
  }
33026
33058
  return true;
@@ -33034,7 +33066,7 @@ ${lines.join("\n")}`;
33034
33066
  ["Power", ["Add", ["Multiply", "_a", "_x"], "__b"], ["Add", "_n", 1]],
33035
33067
  ["Multiply", "_a", ["Add", "_n", 1]]
33036
33068
  ],
33037
- condition: (sub2) => filter2(sub2) && !sub2._n.is(-1)
33069
+ condition: (sub3) => filter2(sub3) && !sub3._n.is(-1)
33038
33070
  },
33039
33071
  // \sqrt{ax + b} -> \frac{2}{3a} (ax + b)^{3/2}
33040
33072
  {
@@ -33044,7 +33076,7 @@ ${lines.join("\n")}`;
33044
33076
  ["Multiply", 2, ["Power", ["Add", ["Multiply", "_a", "_x"], "__b"], 3]],
33045
33077
  ["Multiply", 3, "_a"]
33046
33078
  ],
33047
- condition: (sub2) => filter2(sub2) && sub2._a.isNumberLiteral
33079
+ condition: (sub3) => filter2(sub3) && sub3._a.isNumberLiteral
33048
33080
  },
33049
33081
  // \sqrt[3]{ax + b} -> \frac{3}{4a} (ax + b)^{4/3}
33050
33082
  {
@@ -33054,13 +33086,13 @@ ${lines.join("\n")}`;
33054
33086
  ["Multiply", 3, ["Power", ["Add", ["Multiply", "_a", "_x"], "__b"], 4]],
33055
33087
  ["Multiply", 4, "_a"]
33056
33088
  ],
33057
- condition: (sub2) => filter2(sub2) && sub2._a.isNumberLiteral
33089
+ condition: (sub3) => filter2(sub3) && sub3._a.isNumberLiteral
33058
33090
  },
33059
33091
  // a^x -> \frac{a^x}{\ln(a)} where a is a constant (doesn't contain x)
33060
33092
  {
33061
33093
  match: ["Power", "_a", "_x"],
33062
33094
  replace: ["Divide", ["Power", "_a", "_x"], ["Ln", "_a"]],
33063
- condition: (sub2) => filter2(sub2) && !sub2._a.has("_x")
33095
+ condition: (sub3) => filter2(sub3) && !sub3._a.has("_x")
33064
33096
  },
33065
33097
  // (ax+b)^{-1} -> \ln(ax + b) / a
33066
33098
  {
@@ -33076,7 +33108,7 @@ ${lines.join("\n")}`;
33076
33108
  {
33077
33109
  match: ["Power", ["Add", "_x", "__b"], -1],
33078
33110
  replace: ["Ln", ["Abs", ["Add", "_x", "__b"]]],
33079
- condition: (sub2) => filter2(sub2) && sub2._x.symbol !== null
33111
+ condition: (sub3) => filter2(sub3) && sub3._x.symbol !== null
33080
33112
  },
33081
33113
  // 1/(ax + b) -> \ln(ax + b) / a
33082
33114
  {
@@ -33092,7 +33124,7 @@ ${lines.join("\n")}`;
33092
33124
  {
33093
33125
  match: ["Divide", 1, ["Add", "_x", "__b"]],
33094
33126
  replace: ["Ln", ["Abs", ["Add", "_x", "__b"]]],
33095
- condition: (sub2) => filter2(sub2) && sub2._x.symbol !== null
33127
+ condition: (sub3) => filter2(sub3) && sub3._x.symbol !== null
33096
33128
  },
33097
33129
  // \ln(ax + b) -> (ax + b) \ln(ax + b) - ax - b
33098
33130
  {
@@ -33691,7 +33723,7 @@ ${lines.join("\n")}`;
33691
33723
  ["Exp", "_x"],
33692
33724
  ["Subtract", ["Sin", "_x"], ["Cos", "_x"]]
33693
33725
  ],
33694
- condition: (sub2) => filter2(sub2) && sub2._x.symbol !== null
33726
+ condition: (sub3) => filter2(sub3) && sub3._x.symbol !== null
33695
33727
  },
33696
33728
  // e^x * cos(x) -> (e^x/2)(sin(x) + cos(x))
33697
33729
  {
@@ -33702,7 +33734,7 @@ ${lines.join("\n")}`;
33702
33734
  ["Exp", "_x"],
33703
33735
  ["Add", ["Sin", "_x"], ["Cos", "_x"]]
33704
33736
  ],
33705
- condition: (sub2) => filter2(sub2) && sub2._x.symbol !== null
33737
+ condition: (sub3) => filter2(sub3) && sub3._x.symbol !== null
33706
33738
  },
33707
33739
  // sin(x) * e^x -> (e^x/2)(sin(x) - cos(x)) (commuted order)
33708
33740
  {
@@ -33713,7 +33745,7 @@ ${lines.join("\n")}`;
33713
33745
  ["Exp", "_x"],
33714
33746
  ["Subtract", ["Sin", "_x"], ["Cos", "_x"]]
33715
33747
  ],
33716
- condition: (sub2) => filter2(sub2) && sub2._x.symbol !== null
33748
+ condition: (sub3) => filter2(sub3) && sub3._x.symbol !== null
33717
33749
  },
33718
33750
  // cos(x) * e^x -> (e^x/2)(sin(x) + cos(x)) (commuted order)
33719
33751
  {
@@ -33724,7 +33756,7 @@ ${lines.join("\n")}`;
33724
33756
  ["Exp", "_x"],
33725
33757
  ["Add", ["Sin", "_x"], ["Cos", "_x"]]
33726
33758
  ],
33727
- condition: (sub2) => filter2(sub2) && sub2._x.symbol !== null
33759
+ condition: (sub3) => filter2(sub3) && sub3._x.symbol !== null
33728
33760
  },
33729
33761
  // e^x * sin(ax) -> (e^x/(a² + 1))(sin(ax) - a*cos(ax)) (no constant term)
33730
33762
  {
@@ -34115,8 +34147,8 @@ ${lines.join("\n")}`;
34115
34147
  const denom = fn.op2;
34116
34148
  if (denom.operator === "Power") {
34117
34149
  const base = denom.op1;
34118
- const exp2 = denom.op2;
34119
- const n = exp2.re;
34150
+ const exp3 = denom.op2;
34151
+ const n = exp3.re;
34120
34152
  if (n !== null && Number.isInteger(n) && n > 1) {
34121
34153
  const linearCoeffs = getLinearCoefficients(base, index);
34122
34154
  if (linearCoeffs) {
@@ -34156,8 +34188,8 @@ ${lines.join("\n")}`;
34156
34188
  const denom = fn.op2;
34157
34189
  if (denom.operator === "Power") {
34158
34190
  const base = denom.op1;
34159
- const exp2 = denom.op2;
34160
- const n = exp2.re;
34191
+ const exp3 = denom.op2;
34192
+ const n = exp3.re;
34161
34193
  if (n !== null && Number.isInteger(n) && n > 1) {
34162
34194
  const quadCoeffs = getQuadraticCoefficients(base, index);
34163
34195
  if (quadCoeffs && quadCoeffs.b.is(0) && quadCoeffs.a.is(1)) {
@@ -35280,10 +35312,10 @@ ${lines.join("\n")}`;
35280
35312
  const roots = [];
35281
35313
  const im = ops[0].im ?? 0;
35282
35314
  const arg = Math.atan2(im, re);
35283
- const mod2 = Math.sqrt(re * re + im * im);
35315
+ const mod3 = Math.sqrt(re * re + im * im);
35284
35316
  for (let k = 0; k < n; k++) {
35285
35317
  const theta = (arg + 2 * Math.PI * k) / n;
35286
- const r = Math.pow(mod2, 1 / n);
35318
+ const r = Math.pow(mod3, 1 / n);
35287
35319
  roots.push([r * Math.cos(theta), r * Math.sin(theta)]);
35288
35320
  }
35289
35321
  return ce.function(
@@ -36790,8 +36822,8 @@ ${lines.join("\n")}`;
36790
36822
  if (isValueDef(symbolDef) && symbolDef.value.subscriptEvaluate) {
36791
36823
  return "number";
36792
36824
  }
36793
- const sub2 = op2.string ?? op2.symbol ?? asSmallInteger(op2)?.toString();
36794
- if (sub2) return "symbol";
36825
+ const sub3 = op2.string ?? op2.symbol ?? asSmallInteger(op2)?.toString();
36826
+ if (sub3) return "symbol";
36795
36827
  if (op2.operator === "InvisibleOperator" && op2.ops) {
36796
36828
  const parts = op2.ops.map(
36797
36829
  (x) => x.symbol ?? asSmallInteger(x)?.toString()
@@ -36832,8 +36864,8 @@ ${lines.join("\n")}`;
36832
36864
  }
36833
36865
  }
36834
36866
  if (op1.symbol) {
36835
- const sub3 = op2.string ?? op2.symbol ?? asSmallInteger(op2)?.toString();
36836
- if (sub3) return ce.symbol(op1.symbol + "_" + sub3);
36867
+ const sub4 = op2.string ?? op2.symbol ?? asSmallInteger(op2)?.toString();
36868
+ if (sub4) return ce.symbol(op1.symbol + "_" + sub4);
36837
36869
  if (op2.operator === "InvisibleOperator" && op2.ops) {
36838
36870
  const parts = op2.ops.map(
36839
36871
  (x) => x.symbol ?? asSmallInteger(x)?.toString()
@@ -36845,9 +36877,9 @@ ${lines.join("\n")}`;
36845
36877
  }
36846
36878
  if (op2.operator === "Sequence")
36847
36879
  ce._fn("Subscript", [op1, ce._fn("List", op2.ops)]);
36848
- let sub2 = op2;
36849
- if (op2.operator === "Delimiter" && op2.op1) sub2 = op2.op1.canonical;
36850
- return ce._fn("Subscript", [op1, sub2]);
36880
+ let sub3 = op2;
36881
+ if (op2.operator === "Delimiter" && op2.op1) sub3 = op2.op1.canonical;
36882
+ return ce._fn("Subscript", [op1, sub3]);
36851
36883
  },
36852
36884
  evaluate: (ops, { engine: ce, numericApproximation }) => {
36853
36885
  const [base, subscript] = ops;
@@ -36909,11 +36941,11 @@ ${lines.join("\n")}`;
36909
36941
  timings.push(1e3 * (globalThis.performance.now() - start));
36910
36942
  n -= 1;
36911
36943
  }
36912
- const max2 = Math.max(...timings);
36913
- const min2 = Math.min(...timings);
36914
- timings = timings.filter((x) => x > min2 && x < max2);
36944
+ const max3 = Math.max(...timings);
36945
+ const min3 = Math.min(...timings);
36946
+ timings = timings.filter((x) => x > min3 && x < max3);
36915
36947
  const sum2 = timings.reduce((acc, v) => acc + v, 0);
36916
- if (sum2 === 0) return ce.tuple(ce.number(max2), result);
36948
+ if (sum2 === 0) return ce.tuple(ce.number(max3), result);
36917
36949
  return ce.tuple(ce.number(sum2 / timings.length), result);
36918
36950
  }
36919
36951
  }
@@ -38025,8 +38057,8 @@ ${lines.join("\n")}`;
38025
38057
  }
38026
38058
  norm = Math.sqrt(norm);
38027
38059
  if (norm < 1e-10) continue;
38028
- const sign2 = R[k][k] >= 0 ? 1 : -1;
38029
- const u0 = R[k][k] + sign2 * norm;
38060
+ const sign3 = R[k][k] >= 0 ? 1 : -1;
38061
+ const u0 = R[k][k] + sign3 * norm;
38030
38062
  const v = Array(m).fill(0);
38031
38063
  v[k] = 1;
38032
38064
  for (let i = k + 1; i < m; i++) {
@@ -39141,8 +39173,8 @@ ${lines.join("\n")}`;
39141
39173
  const pent1 = k * (3n * k - 1n) / 2n;
39142
39174
  const pent2 = k * (3n * k + 1n) / 2n;
39143
39175
  if (pent1 > n2 && pent2 > n2) break;
39144
- const sign2 = k % 2n === 0n ? -1n : 1n;
39145
- total += sign2 * (P2(n2 - pent1) + P2(n2 - pent2));
39176
+ const sign3 = k % 2n === 0n ? -1n : 1n;
39177
+ total += sign3 * (P2(n2 - pent1) + P2(n2 - pent2));
39146
39178
  }
39147
39179
  memo.set(n2, total);
39148
39180
  return total;
@@ -39157,9 +39189,9 @@ ${lines.join("\n")}`;
39157
39189
  const k = toBigint(n);
39158
39190
  if (k === null || k < 1n) return ce.False;
39159
39191
  const D = 8n * k + 1n;
39160
- const sqrt2 = BigInt(decimal_default.sqrt(ce.bignum(D)).toFixed(0));
39192
+ const sqrt3 = BigInt(decimal_default.sqrt(ce.bignum(D)).toFixed(0));
39161
39193
  return ce.symbol(
39162
- sqrt2 * sqrt2 === D && (sqrt2 - 1n) % 2n === 0n ? "True" : "False"
39194
+ sqrt3 * sqrt3 === D && (sqrt3 - 1n) % 2n === 0n ? "True" : "False"
39163
39195
  );
39164
39196
  }
39165
39197
  },
@@ -39169,8 +39201,8 @@ ${lines.join("\n")}`;
39169
39201
  evaluate: ([n], { engine: ce }) => {
39170
39202
  const k = toBigint(n);
39171
39203
  if (k === null || k < 0n) return ce.False;
39172
- const sqrt2 = BigInt(decimal_default.sqrt(ce.bignum(k)).toFixed(0));
39173
- return ce.symbol(sqrt2 * sqrt2 === k ? "True" : "False");
39204
+ const sqrt3 = BigInt(decimal_default.sqrt(ce.bignum(k)).toFixed(0));
39205
+ return ce.symbol(sqrt3 * sqrt3 === k ? "True" : "False");
39174
39206
  }
39175
39207
  },
39176
39208
  IsOctahedral: {
@@ -39180,8 +39212,8 @@ ${lines.join("\n")}`;
39180
39212
  const k = toBigint(n);
39181
39213
  if (k === null || k < 1n) return ce.False;
39182
39214
  const discriminant = 3n * k + 1n;
39183
- const sqrt2 = BigInt(decimal_default.sqrt(ce.bignum(discriminant)).toFixed(0));
39184
- return ce.symbol(sqrt2 * sqrt2 === discriminant ? "True" : "False");
39215
+ const sqrt3 = BigInt(decimal_default.sqrt(ce.bignum(discriminant)).toFixed(0));
39216
+ return ce.symbol(sqrt3 * sqrt3 === discriminant ? "True" : "False");
39185
39217
  }
39186
39218
  },
39187
39219
  IsCenteredSquare: {
@@ -39192,8 +39224,8 @@ ${lines.join("\n")}`;
39192
39224
  if (k === null || k < 1n) return ce.False;
39193
39225
  if ((k - 1n) % 4n !== 0n) return ce.False;
39194
39226
  const t = (k - 1n) / 4n;
39195
- const sqrt2 = BigInt(decimal_default.sqrt(ce.bignum(t)).toFixed(0));
39196
- return ce.symbol(sqrt2 * sqrt2 * 4n + 1n === k ? "True" : "False");
39227
+ const sqrt3 = BigInt(decimal_default.sqrt(ce.bignum(t)).toFixed(0));
39228
+ return ce.symbol(sqrt3 * sqrt3 * 4n + 1n === k ? "True" : "False");
39197
39229
  }
39198
39230
  },
39199
39231
  IsHappy: {
@@ -39275,39 +39307,39 @@ ${lines.join("\n")}`;
39275
39307
  const term2 = terms[j];
39276
39308
  const crossTerm = terms[crossIdx];
39277
39309
  const sqrt1 = extractSquareRoot(term1, ce);
39278
- const sqrt2 = extractSquareRoot(term2, ce);
39279
- if (sqrt1 === null || sqrt2 === null) continue;
39280
- const positiveCross = ce.number(2).mul(sqrt1).mul(sqrt2);
39310
+ const sqrt22 = extractSquareRoot(term2, ce);
39311
+ if (sqrt1 === null || sqrt22 === null) continue;
39312
+ const positiveCross = ce.number(2).mul(sqrt1).mul(sqrt22);
39281
39313
  const negativeCross = positiveCross.neg();
39282
39314
  if (crossTerm.isSame(positiveCross)) {
39283
- return ce.box(["Square", sqrt1.add(sqrt2).json]);
39315
+ return ce.box(["Square", sqrt1.add(sqrt22).json]);
39284
39316
  } else if (crossTerm.isSame(negativeCross)) {
39285
- return ce.box(["Square", sqrt1.sub(sqrt2).json]);
39317
+ return ce.box(["Square", sqrt1.sub(sqrt22).json]);
39286
39318
  }
39287
39319
  }
39288
39320
  }
39289
39321
  return null;
39290
39322
  }
39291
39323
  function extractSquareRoot(term, ce) {
39292
- const sqrt2 = term.sqrt().simplify();
39293
- if (sqrt2.operator === "Sqrt") return null;
39294
- if (sqrt2.isNumberLiteral && sqrt2.numericValue) {
39295
- const nv = sqrt2.numericValue;
39324
+ const sqrt3 = term.sqrt().simplify();
39325
+ if (sqrt3.operator === "Sqrt") return null;
39326
+ if (sqrt3.isNumberLiteral && sqrt3.numericValue) {
39327
+ const nv = sqrt3.numericValue;
39296
39328
  if (nv.radical !== void 0 && nv.radical !== 1) return null;
39297
39329
  }
39298
- if (sqrt2.operator === "Abs") {
39299
- return sqrt2.op1;
39330
+ if (sqrt3.operator === "Abs") {
39331
+ return sqrt3.op1;
39300
39332
  }
39301
- if (sqrt2.operator === "Multiply") {
39302
- const absFactors = sqrt2.ops.filter((op) => op.operator === "Abs");
39333
+ if (sqrt3.operator === "Multiply") {
39334
+ const absFactors = sqrt3.ops.filter((op) => op.operator === "Abs");
39303
39335
  if (absFactors.length > 0) {
39304
- const newOps = sqrt2.ops.map(
39336
+ const newOps = sqrt3.ops.map(
39305
39337
  (op) => op.operator === "Abs" ? op.op1 : op
39306
39338
  );
39307
39339
  return ce.box(["Multiply", ...newOps.map((op) => op.json)]);
39308
39340
  }
39309
39341
  }
39310
- return sqrt2;
39342
+ return sqrt3;
39311
39343
  }
39312
39344
  function factorDifferenceOfSquares(expr) {
39313
39345
  const ce = expr.engine;
@@ -39330,9 +39362,9 @@ ${lines.join("\n")}`;
39330
39362
  absTerm = ce.box(["Multiply", ...newOps.map((op) => op.json)]);
39331
39363
  }
39332
39364
  }
39333
- const sqrt2 = extractSquareRoot(absTerm, ce);
39334
- if (sqrt2 === null) return null;
39335
- results.push({ sqrt: sqrt2, isNegative: isNeg });
39365
+ const sqrt3 = extractSquareRoot(absTerm, ce);
39366
+ if (sqrt3 === null) return null;
39367
+ results.push({ sqrt: sqrt3, isNegative: isNeg });
39336
39368
  }
39337
39369
  const posSquares = results.filter((r) => !r.isNegative);
39338
39370
  const negSquares = results.filter((r) => r.isNegative);
@@ -39649,10 +39681,10 @@ ${lines.join("\n")}`;
39649
39681
  let constantRatio = void 0;
39650
39682
  const tolerance = ce.tolerance;
39651
39683
  for (const testVal of testValues) {
39652
- const sub2 = {};
39653
- for (const u of unknowns) sub2[u] = testVal;
39654
- const v1 = expr1.subs(sub2).N();
39655
- const v2 = expr2.subs(sub2).N();
39684
+ const sub3 = {};
39685
+ for (const u of unknowns) sub3[u] = testVal;
39686
+ const v1 = expr1.subs(sub3).N();
39687
+ const v2 = expr2.subs(sub3).N();
39656
39688
  const n1 = v1.re;
39657
39689
  const n2 = v2.re;
39658
39690
  if (!Number.isFinite(n1) || !Number.isFinite(n2)) continue;
@@ -40889,9 +40921,9 @@ ${lines.join("\n")}`;
40889
40921
  if (signOpt === "+-") {
40890
40922
  yield self.engine.number(value);
40891
40923
  } else {
40892
- const sign2 = signOpt === "-" ? -1 : 1;
40924
+ const sign3 = signOpt === "-" ? -1 : 1;
40893
40925
  const [n, d] = value;
40894
- yield self.engine.number([sign2 * n, d]);
40926
+ yield self.engine.number([sign3 * n, d]);
40895
40927
  }
40896
40928
  }
40897
40929
  }
@@ -41141,12 +41173,12 @@ ${lines.join("\n")}`;
41141
41173
  for (const v of values) {
41142
41174
  counts[v] = (counts[v] ?? 0) + 1;
41143
41175
  }
41144
- let max2 = 0;
41176
+ let max3 = 0;
41145
41177
  let mode2 = NaN;
41146
41178
  for (const v in counts) {
41147
41179
  const c = counts[v];
41148
- if (c > max2) {
41149
- max2 = c;
41180
+ if (c > max3) {
41181
+ max3 = c;
41150
41182
  mode2 = +v;
41151
41183
  }
41152
41184
  }
@@ -41157,12 +41189,12 @@ ${lines.join("\n")}`;
41157
41189
  for (const v of values) {
41158
41190
  counts[v.toString()] = (counts[v.toString()] ?? 0) + 1;
41159
41191
  }
41160
- let max2 = 0;
41192
+ let max3 = 0;
41161
41193
  let mode2 = bignum(NaN);
41162
41194
  for (const v in counts) {
41163
41195
  const c = counts[v];
41164
- if (c > max2) {
41165
- max2 = c;
41196
+ if (c > max3) {
41197
+ max3 = c;
41166
41198
  mode2 = bignum(v);
41167
41199
  }
41168
41200
  }
@@ -41350,18 +41382,18 @@ ${lines.join("\n")}`;
41350
41382
  if (!xs.isFiniteCollection) return void 0;
41351
41383
  const data = Array.from(xs.each()).map((x) => x.re).filter(Number.isFinite);
41352
41384
  if (data.length === 0) return void 0;
41353
- const min2 = Math.min(...data);
41354
- const max2 = Math.max(...data);
41385
+ const min3 = Math.min(...data);
41386
+ const max3 = Math.max(...data);
41355
41387
  let binEdges;
41356
41388
  if (binsArg?.operator === "List") {
41357
41389
  binEdges = binsArg.ops.map((op) => op.re);
41358
41390
  } else {
41359
41391
  const binCount = toInteger(binsArg);
41360
41392
  if (binCount === null || binCount <= 0) return void 0;
41361
- const binWidth = (max2 - min2) / binCount;
41393
+ const binWidth = (max3 - min3) / binCount;
41362
41394
  binEdges = Array.from(
41363
41395
  { length: binCount + 1 },
41364
- (_, i) => min2 + i * binWidth
41396
+ (_, i) => min3 + i * binWidth
41365
41397
  );
41366
41398
  }
41367
41399
  const counts = Array(binEdges.length - 1).fill(0);
@@ -41390,18 +41422,18 @@ ${lines.join("\n")}`;
41390
41422
  if (!xs.isFiniteCollection) return void 0;
41391
41423
  const data = Array.from(xs.each()).map((x) => x.re).filter(Number.isFinite);
41392
41424
  if (data.length === 0) return void 0;
41393
- const min2 = Math.min(...data);
41394
- const max2 = Math.max(...data);
41425
+ const min3 = Math.min(...data);
41426
+ const max3 = Math.max(...data);
41395
41427
  let binEdges;
41396
41428
  if (binsArg.isCollection) {
41397
41429
  binEdges = [...binsArg.each()].map((op) => op.re);
41398
41430
  } else {
41399
41431
  const binCount = toInteger(binsArg);
41400
41432
  if (binCount === null || binCount <= 0) return void 0;
41401
- const binWidth = (max2 - min2) / binCount;
41433
+ const binWidth = (max3 - min3) / binCount;
41402
41434
  binEdges = Array.from(
41403
41435
  { length: binCount + 1 },
41404
- (_, i) => min2 + i * binWidth
41436
+ (_, i) => min3 + i * binWidth
41405
41437
  );
41406
41438
  }
41407
41439
  const counts = Array(binEdges.length - 1).fill(0);
@@ -42051,13 +42083,13 @@ ${lines.join("\n")}`;
42051
42083
  theta = Math.abs(theta % (2 * Math.PI));
42052
42084
  const quadrant3 = Math.floor(theta * 2 / Math.PI);
42053
42085
  theta = theta % (Math.PI / 2);
42054
- let sign2;
42055
- [sign2, operator2] = TRIG_IDENTITIES[operator2]?.[quadrant3] ?? [1, operator2];
42086
+ let sign3;
42087
+ [sign3, operator2] = TRIG_IDENTITIES[operator2]?.[quadrant3] ?? [1, operator2];
42056
42088
  for (const [[n, d], value] of specialValues) {
42057
42089
  const r = value[operator2];
42058
42090
  if (r && Math.abs(theta - Math.PI * n / d) <= 1e-12) {
42059
42091
  if (r.symbol === "ComplexInfinity") return r;
42060
- return identitySign * sign2 < 0 ? r.neg() : r;
42092
+ return identitySign * sign3 < 0 ? r.neg() : r;
42061
42093
  }
42062
42094
  }
42063
42095
  return void 0;
@@ -42473,8 +42505,8 @@ Error in definition of "${name}"`,
42473
42505
  return 5 + costFunction(arg) + 6;
42474
42506
  }
42475
42507
  if (arg?.operator === "Power" && arg.op2?.isOdd === true && arg.op2?.isInteger === true) {
42476
- const exp2 = arg.op2;
42477
- const n = exp2.numericValue;
42508
+ const exp3 = arg.op2;
42509
+ const n = exp3.numericValue;
42478
42510
  if (typeof n === "number" && n > 1) {
42479
42511
  return 5 + costFunction(arg) + 10;
42480
42512
  }
@@ -42483,8 +42515,8 @@ Error in definition of "${name}"`,
42483
42515
  } else if (["Square", "Abs"].includes(name)) nameCost = 5;
42484
42516
  else if (name === "Power") {
42485
42517
  const base = expr.ops[0];
42486
- const exp2 = expr.ops[1];
42487
- const expCost = costFunction(exp2);
42518
+ const exp3 = expr.ops[1];
42519
+ const expCost = costFunction(exp3);
42488
42520
  if (base.operator === "Negate") {
42489
42521
  return expCost + 4;
42490
42522
  }
@@ -42492,7 +42524,7 @@ Error in definition of "${name}"`,
42492
42524
  const hasNegativeCoef = base.ops.some(
42493
42525
  (f) => f.isNumberLiteral && f.isNegative === true
42494
42526
  );
42495
- if (hasNegativeCoef && exp2.isRational === true && !exp2.isInteger) {
42527
+ if (hasNegativeCoef && exp3.isRational === true && !exp3.isInteger) {
42496
42528
  return expCost + costFunction(base) + 15;
42497
42529
  }
42498
42530
  return expCost + costFunction(base);
@@ -43404,10 +43436,10 @@ Error in definition of "${name}"`,
43404
43436
  const ce = expr.engine;
43405
43437
  if (expr.operator !== "Power") return void 0;
43406
43438
  const base = expr.op1;
43407
- const exp2 = expr.op2;
43408
- if (!base || !exp2) return void 0;
43439
+ const exp3 = expr.op2;
43440
+ if (!base || !exp3) return void 0;
43409
43441
  if (base.operator !== "Sin") return void 0;
43410
- if (!exp2.is(2)) return void 0;
43442
+ if (!exp3.is(2)) return void 0;
43411
43443
  const arg = base.op1;
43412
43444
  if (!arg) return void 0;
43413
43445
  return ce.One.sub(ce._fn("Cos", [arg]).pow(2));
@@ -43419,10 +43451,10 @@ Error in definition of "${name}"`,
43419
43451
  const ce = expr.engine;
43420
43452
  if (expr.operator !== "Power") return void 0;
43421
43453
  const base = expr.op1;
43422
- const exp2 = expr.op2;
43423
- if (!base || !exp2) return void 0;
43454
+ const exp3 = expr.op2;
43455
+ if (!base || !exp3) return void 0;
43424
43456
  if (base.operator !== "Cos") return void 0;
43425
- if (!exp2.is(2)) return void 0;
43457
+ if (!exp3.is(2)) return void 0;
43426
43458
  const arg = base.op1;
43427
43459
  if (!arg) return void 0;
43428
43460
  return ce.One.sub(ce._fn("Sin", [arg]).pow(2));
@@ -43434,10 +43466,10 @@ Error in definition of "${name}"`,
43434
43466
  const ce = expr.engine;
43435
43467
  if (expr.operator !== "Power") return void 0;
43436
43468
  const base = expr.op1;
43437
- const exp2 = expr.op2;
43438
- if (!base || !exp2) return void 0;
43469
+ const exp3 = expr.op2;
43470
+ if (!base || !exp3) return void 0;
43439
43471
  if (base.operator !== "Cos") return void 0;
43440
- if (!exp2.is(2)) return void 0;
43472
+ if (!exp3.is(2)) return void 0;
43441
43473
  const arg = base.op1;
43442
43474
  if (!arg) return void 0;
43443
43475
  return ce.One.add(ce._fn("Cos", [arg.mul(2)])).div(2);
@@ -44205,9 +44237,9 @@ Error in definition of "${name}"`,
44205
44237
  const ce = expr.engine;
44206
44238
  if (expr.operator !== "Power") return void 0;
44207
44239
  const base = expr.op1;
44208
- const exp2 = expr.op2;
44209
- if (!base || !exp2) return void 0;
44210
- if (!exp2.is(2)) return void 0;
44240
+ const exp3 = expr.op2;
44241
+ if (!base || !exp3) return void 0;
44242
+ if (!exp3.is(2)) return void 0;
44211
44243
  const arg = base.op1;
44212
44244
  if (!arg) return void 0;
44213
44245
  if (base.operator === "Tan") {
@@ -45230,9 +45262,9 @@ Error in definition of "${name}"`,
45230
45262
  (a, b) => anchorSpecificity(b) - anchorSpecificity(a)
45231
45263
  );
45232
45264
  return tryMatchAnchors(0, exprOps, substitution);
45233
- function tryMatchAnchors(anchorIndex, remainingOps, sub2) {
45265
+ function tryMatchAnchors(anchorIndex, remainingOps, sub3) {
45234
45266
  if (anchorIndex >= sortedAnchors.length) {
45235
- return assignWildcards(remainingOps, sub2);
45267
+ return assignWildcards(remainingOps, sub3);
45236
45268
  }
45237
45269
  const anchorsLeft = sortedAnchors.length - anchorIndex;
45238
45270
  const minWildcardNeeds = universalWildcards.length + sequenceWildcards.length;
@@ -45241,7 +45273,7 @@ Error in definition of "${name}"`,
45241
45273
  }
45242
45274
  const anchor = sortedAnchors[anchorIndex];
45243
45275
  for (let i = 0; i < remainingOps.length; i++) {
45244
- const matchResult = matchOnce(remainingOps[i], anchor, sub2, options);
45276
+ const matchResult = matchOnce(remainingOps[i], anchor, sub3, options);
45245
45277
  if (matchResult !== null) {
45246
45278
  const newRemaining = [...remainingOps];
45247
45279
  newRemaining.splice(i, 1);
@@ -45255,8 +45287,8 @@ Error in definition of "${name}"`,
45255
45287
  }
45256
45288
  return null;
45257
45289
  }
45258
- function assignWildcards(remainingOps, sub2) {
45259
- const result = sub2;
45290
+ function assignWildcards(remainingOps, sub3) {
45291
+ const result = sub3;
45260
45292
  const neededForUniversal = universalWildcards.length;
45261
45293
  const minNeededForSequence = sequenceWildcards.length;
45262
45294
  const totalNeeded = neededForUniversal + minNeededForSequence;
@@ -45267,16 +45299,16 @@ Error in definition of "${name}"`,
45267
45299
  result
45268
45300
  );
45269
45301
  }
45270
- function tryAssignWildcards(wildcards, remaining, sub2) {
45302
+ function tryAssignWildcards(wildcards, remaining, sub3) {
45271
45303
  if (wildcards.length === 0) {
45272
- return remaining.length === 0 ? sub2 : null;
45304
+ return remaining.length === 0 ? sub3 : null;
45273
45305
  }
45274
45306
  const [wc, ...restWildcards] = wildcards;
45275
45307
  const wcType = wildcardType(wc);
45276
45308
  const wcName = wildcardName(wc);
45277
45309
  if (wcType === "Wildcard") {
45278
45310
  for (let i = 0; i < remaining.length; i++) {
45279
- const newSub = captureWildcard(wcName, remaining[i], sub2);
45311
+ const newSub = captureWildcard(wcName, remaining[i], sub3);
45280
45312
  if (newSub !== null) {
45281
45313
  const newRemaining = [...remaining];
45282
45314
  newRemaining.splice(i, 1);
@@ -45298,7 +45330,7 @@ Error in definition of "${name}"`,
45298
45330
  for (const indices of combinations) {
45299
45331
  const captured = indices.map((i) => remaining[i]);
45300
45332
  const capturedExpr = wrapCaptured(captured);
45301
- const newSub = captureWildcard(wcName, capturedExpr, sub2);
45333
+ const newSub = captureWildcard(wcName, capturedExpr, sub3);
45302
45334
  if (newSub !== null) {
45303
45335
  const newRemaining = remaining.filter(
45304
45336
  (_, i) => !indices.includes(i)
@@ -45318,7 +45350,7 @@ Error in definition of "${name}"`,
45318
45350
  for (let count = maxCapture; count >= 0; count--) {
45319
45351
  if (count === 0) {
45320
45352
  const identity = expr.operator === "Add" ? ce.Zero : expr.operator === "Multiply" ? ce.One : ce.Nothing;
45321
- const newSub = captureWildcard(wcName, identity, sub2);
45353
+ const newSub = captureWildcard(wcName, identity, sub3);
45322
45354
  if (newSub !== null) {
45323
45355
  const result = tryAssignWildcards(restWildcards, remaining, newSub);
45324
45356
  if (result !== null) return result;
@@ -45328,7 +45360,7 @@ Error in definition of "${name}"`,
45328
45360
  for (const indices of combinations) {
45329
45361
  const captured = indices.map((i) => remaining[i]);
45330
45362
  const capturedExpr = wrapCaptured(captured);
45331
- const newSub = captureWildcard(wcName, capturedExpr, sub2);
45363
+ const newSub = captureWildcard(wcName, capturedExpr, sub3);
45332
45364
  if (newSub !== null) {
45333
45365
  const newRemaining = remaining.filter(
45334
45366
  (_, i) => !indices.includes(i)
@@ -45799,11 +45831,11 @@ Error in definition of "${name}"`,
45799
45831
  return [coef.sqrt(), ce.function("Sqrt", [rest])];
45800
45832
  }
45801
45833
  if (expr.operator === "Root") {
45802
- const exp2 = expr.op2.re;
45803
- if (isNaN(exp2) || expr.op2.im !== 0) return [ce._numericValue(1), this];
45834
+ const exp3 = expr.op2.re;
45835
+ if (isNaN(exp3) || expr.op2.im !== 0) return [ce._numericValue(1), this];
45804
45836
  const [coef, rest] = expr.op1.toNumericValue();
45805
- if (exp2 === 2) return [coef.sqrt(), ce.function("Sqrt", [rest])];
45806
- return [coef.root(exp2), ce.function("Root", [rest, expr.op2])];
45837
+ if (exp3 === 2) return [coef.sqrt(), ce.function("Sqrt", [rest])];
45838
+ return [coef.root(exp3), ce.function("Root", [rest, expr.op2])];
45807
45839
  }
45808
45840
  if (expr.operator === "Abs") {
45809
45841
  const [coef, rest] = expr.op1.toNumericValue();
@@ -45820,11 +45852,11 @@ Error in definition of "${name}"`,
45820
45852
  * original expression.
45821
45853
  * <!-- This may or may not be desirable -->
45822
45854
  */
45823
- subs(sub2, options) {
45855
+ subs(sub3, options) {
45824
45856
  options ??= { canonical: void 0 };
45825
45857
  if (options.canonical === void 0)
45826
45858
  options = { canonical: this.isCanonical };
45827
- const ops = this._ops.map((x) => x.subs(sub2, options));
45859
+ const ops = this._ops.map((x) => x.subs(sub3, options));
45828
45860
  if (!ops.every((x) => x.isValid))
45829
45861
  return this.engine.function(this._operator, ops, { canonical: false });
45830
45862
  return this.engine.function(this._operator, ops, options);
@@ -45985,13 +46017,13 @@ Error in definition of "${name}"`,
45985
46017
  if (!this.isCanonical) throw new Error("Not canonical");
45986
46018
  return div2(this, rhs);
45987
46019
  }
45988
- pow(exp2) {
45989
- return pow2(this, exp2, { numericApproximation: false });
46020
+ pow(exp3) {
46021
+ return pow2(this, exp3, { numericApproximation: false });
45990
46022
  }
45991
- root(exp2) {
45992
- if (!this.isCanonical || typeof exp2 !== "number" && !exp2.isCanonical)
46023
+ root(exp3) {
46024
+ if (!this.isCanonical || typeof exp3 !== "number" && !exp3.isCanonical)
45993
46025
  throw new Error("Not canonical");
45994
- const e = typeof exp2 === "number" ? exp2 : exp2.im === 0 ? exp2.re : void 0;
46026
+ const e = typeof exp3 === "number" ? exp3 : exp3.im === 0 ? exp3.re : void 0;
45995
46027
  if (e === 0) return this.engine.NaN;
45996
46028
  if (e === 1) return this;
45997
46029
  if (e === -1) return this.inv();
@@ -46002,24 +46034,24 @@ Error in definition of "${name}"`,
46002
46034
  }
46003
46035
  if (this.operator === "Divide") {
46004
46036
  const [num, denom] = this.ops;
46005
- return num.root(exp2).div(denom.root(exp2));
46037
+ return num.root(exp3).div(denom.root(exp3));
46006
46038
  }
46007
46039
  if (this.operator === "Negate") {
46008
46040
  if (e !== void 0) {
46009
- if (e % 2 === 0) return this.op1.root(exp2);
46010
- return this.op1.root(exp2).neg();
46041
+ if (e % 2 === 0) return this.op1.root(exp3);
46042
+ return this.op1.root(exp3).neg();
46011
46043
  }
46012
46044
  }
46013
46045
  if (this.operator === "Sqrt") {
46014
46046
  if (e !== void 0) return this.op1.root(e * 2);
46015
- if (typeof exp2 !== "number") return this.op1.root(exp2.mul(2));
46047
+ if (typeof exp3 !== "number") return this.op1.root(exp3.mul(2));
46016
46048
  }
46017
46049
  if (this.operator === "Root") {
46018
46050
  const [base, root2] = this.ops;
46019
- return base.root(root2.mul(exp2));
46051
+ return base.root(root2.mul(exp3));
46020
46052
  }
46021
46053
  if (this.operator === "Multiply") {
46022
- const ops = this.ops.map((x) => x.root(exp2));
46054
+ const ops = this.ops.map((x) => x.root(exp3));
46023
46055
  return mul3(...ops);
46024
46056
  }
46025
46057
  if (this.isNumberLiteral) {
@@ -46041,7 +46073,7 @@ Error in definition of "${name}"`,
46041
46073
  }
46042
46074
  }
46043
46075
  }
46044
- return this.engine._fn("Root", [this, this.engine.box(exp2)]);
46076
+ return this.engine._fn("Root", [this, this.engine.box(exp3)]);
46045
46077
  }
46046
46078
  sqrt() {
46047
46079
  return this.root(2);
@@ -46060,12 +46092,12 @@ Error in definition of "${name}"`,
46060
46092
  return this.engine.One.div(base.ln());
46061
46093
  }
46062
46094
  if (this.operator === "Power") {
46063
- const [b, exp2] = this.ops;
46095
+ const [b, exp3] = this.ops;
46064
46096
  if (b.isSame(this.engine.E)) {
46065
- if (!base) return exp2;
46066
- return exp2.div(base.ln());
46097
+ if (!base) return exp3;
46098
+ return exp3.div(base.ln());
46067
46099
  }
46068
- return exp2.mul(b.ln(base));
46100
+ return exp3.mul(b.ln(base));
46069
46101
  }
46070
46102
  if (this.operator === "Root") {
46071
46103
  const [a, b] = this.ops;
@@ -47403,31 +47435,31 @@ Error in definition of "${name}"`,
47403
47435
  div(rhs) {
47404
47436
  return div2(this, rhs);
47405
47437
  }
47406
- pow(exp2) {
47407
- return pow2(this, exp2, { numericApproximation: false });
47438
+ pow(exp3) {
47439
+ return pow2(this, exp3, { numericApproximation: false });
47408
47440
  }
47409
- root(exp2) {
47410
- if (typeof exp2 === "number") {
47411
- if (exp2 === 0) return this.engine.NaN;
47412
- if (exp2 === 1) return this;
47413
- if (exp2 === -1) return this.inv();
47414
- if (exp2 === 2) return this.sqrt();
47441
+ root(exp3) {
47442
+ if (typeof exp3 === "number") {
47443
+ if (exp3 === 0) return this.engine.NaN;
47444
+ if (exp3 === 1) return this;
47445
+ if (exp3 === -1) return this.inv();
47446
+ if (exp3 === 2) return this.sqrt();
47415
47447
  if (this.isNegative) {
47416
- if (exp2 % 2 === 1) return this.neg().root(exp2).neg();
47417
- if (exp2 % 2 === 0) return this.neg().root(exp2);
47448
+ if (exp3 % 2 === 1) return this.neg().root(exp3).neg();
47449
+ if (exp3 % 2 === 0) return this.neg().root(exp3);
47418
47450
  }
47419
47451
  } else {
47420
- exp2 = exp2.canonical;
47421
- if (exp2.is(0)) return this.engine.NaN;
47422
- if (exp2.is(1)) return this;
47423
- if (exp2.is(-1)) return this.inv();
47424
- if (exp2.is(2)) return this.sqrt();
47452
+ exp3 = exp3.canonical;
47453
+ if (exp3.is(0)) return this.engine.NaN;
47454
+ if (exp3.is(1)) return this;
47455
+ if (exp3.is(-1)) return this.inv();
47456
+ if (exp3.is(2)) return this.sqrt();
47425
47457
  if (this.isNegative) {
47426
- if (exp2.isOdd) return this.neg().root(exp2).neg();
47427
- if (exp2.isEven) return this.neg().root(exp2);
47458
+ if (exp3.isOdd) return this.neg().root(exp3).neg();
47459
+ if (exp3.isEven) return this.neg().root(exp3);
47428
47460
  }
47429
47461
  }
47430
- const n = typeof exp2 === "number" ? exp2 : exp2.re;
47462
+ const n = typeof exp3 === "number" ? exp3 : exp3.re;
47431
47463
  if (Number.isInteger(n)) {
47432
47464
  if (typeof this._value === "number") {
47433
47465
  const r = this._value ** (1 / n);
@@ -47437,7 +47469,7 @@ Error in definition of "${name}"`,
47437
47469
  if (isSubtype(r.type, "integer")) return this.engine.number(r);
47438
47470
  }
47439
47471
  }
47440
- return this.engine._fn("Root", [this, this.engine.box(exp2)]);
47472
+ return this.engine._fn("Root", [this, this.engine.box(exp3)]);
47441
47473
  }
47442
47474
  sqrt() {
47443
47475
  if (typeof this._value === "number") {
@@ -47518,9 +47550,9 @@ Error in definition of "${name}"`,
47518
47550
  ce.number(this._value.denominator)
47519
47551
  ];
47520
47552
  }
47521
- subs(sub2, options) {
47553
+ subs(sub3, options) {
47522
47554
  if (this.isStructural) return this;
47523
- return this.structural.subs(sub2, options);
47555
+ return this.structural.subs(sub3, options);
47524
47556
  }
47525
47557
  replace(rules, options) {
47526
47558
  return replace(this.structural, rules, options).at(-1)?.value ?? null;
@@ -47684,9 +47716,9 @@ Error in definition of "${name}"`,
47684
47716
  return 0;
47685
47717
  }
47686
47718
  if (typeof value[0] === "number" && !Number.isFinite(value[0])) {
47687
- const sign2 = value[0] > 0 ? 1 : -1;
47688
- if (value[0] > 0) return sign2 > 0 ? Infinity : -Infinity;
47689
- if (value[0] < 0) return sign2 > 0 ? -Infinity : Infinity;
47719
+ const sign3 = value[0] > 0 ? 1 : -1;
47720
+ if (value[0] > 0) return sign3 > 0 ? Infinity : -Infinity;
47721
+ if (value[0] < 0) return sign3 > 0 ? -Infinity : Infinity;
47690
47722
  return NaN;
47691
47723
  }
47692
47724
  return ce._numericValue(value);
@@ -47830,8 +47862,8 @@ Error in definition of "${name}"`,
47830
47862
  div(rhs) {
47831
47863
  return div2(this, rhs);
47832
47864
  }
47833
- pow(exp2) {
47834
- return pow2(this, exp2, { numericApproximation: false });
47865
+ pow(exp3) {
47866
+ return pow2(this, exp3, { numericApproximation: false });
47835
47867
  }
47836
47868
  root(n) {
47837
47869
  const e = typeof n === "number" ? n : n.im === 0 ? n.re : void 0;
@@ -48157,10 +48189,10 @@ Error in definition of "${name}"`,
48157
48189
  replace(rules, options) {
48158
48190
  return replace(this, rules, options).at(-1)?.value ?? null;
48159
48191
  }
48160
- subs(sub2, options) {
48192
+ subs(sub3, options) {
48161
48193
  const canonical2 = options?.canonical ?? this.isCanonical;
48162
- if (sub2[this._id] === void 0) return canonical2 ? this.canonical : this;
48163
- return this.engine.box(sub2[this._id], { canonical: canonical2 });
48194
+ if (sub3[this._id] === void 0) return canonical2 ? this.canonical : this;
48195
+ return this.engine.box(sub3[this._id], { canonical: canonical2 });
48164
48196
  }
48165
48197
  get _asCollection() {
48166
48198
  if (isValueDef(this._def)) return this._def.value.collection;
@@ -48874,38 +48906,38 @@ Error in definition of "${name}"`,
48874
48906
  }
48875
48907
  if (opOperator === "Power") {
48876
48908
  const base = op.op1;
48877
- const exp2 = op.op2;
48878
- if (base && exp2) {
48879
- if (exp2.isEven === true) {
48909
+ const exp3 = op.op2;
48910
+ if (base && exp3) {
48911
+ if (exp3.isEven === true) {
48880
48912
  return {
48881
- value: base.pow(exp2),
48913
+ value: base.pow(exp3),
48882
48914
  because: "|x^n| -> x^n when n is even"
48883
48915
  };
48884
48916
  }
48885
- if (exp2.isOdd === true) {
48917
+ if (exp3.isOdd === true) {
48886
48918
  return {
48887
- value: ce._fn("Abs", [base]).pow(exp2),
48919
+ value: ce._fn("Abs", [base]).pow(exp3),
48888
48920
  because: "|x^n| -> |x|^n when n is odd"
48889
48921
  };
48890
48922
  }
48891
- if (exp2.isRational === false) {
48923
+ if (exp3.isRational === false) {
48892
48924
  return {
48893
- value: ce._fn("Abs", [base]).pow(exp2),
48925
+ value: ce._fn("Abs", [base]).pow(exp3),
48894
48926
  because: "|x^n| -> |x|^n when n is irrational"
48895
48927
  };
48896
48928
  }
48897
- if (exp2.isRational === true && exp2.isInteger === false) {
48898
- const num = exp2.numerator;
48929
+ if (exp3.isRational === true && exp3.isInteger === false) {
48930
+ const num = exp3.numerator;
48899
48931
  if (num) {
48900
48932
  if (num.isEven === true) {
48901
48933
  return {
48902
- value: base.pow(exp2),
48934
+ value: base.pow(exp3),
48903
48935
  because: "|x^(p/q)| -> x^(p/q) when p is even"
48904
48936
  };
48905
48937
  }
48906
48938
  if (num.isOdd === true) {
48907
48939
  return {
48908
- value: ce._fn("Abs", [base]).pow(exp2),
48940
+ value: ce._fn("Abs", [base]).pow(exp3),
48909
48941
  because: "|x^(p/q)| -> |x|^(p/q) when p is odd"
48910
48942
  };
48911
48943
  }
@@ -48927,22 +48959,22 @@ Error in definition of "${name}"`,
48927
48959
  function simplifyAbsPower(x) {
48928
48960
  if (x.operator !== "Power") return void 0;
48929
48961
  const base = x.op1;
48930
- const exp2 = x.op2;
48931
- if (!base || !exp2 || base.operator !== "Abs") return void 0;
48962
+ const exp3 = x.op2;
48963
+ if (!base || !exp3 || base.operator !== "Abs") return void 0;
48932
48964
  const innerBase = base.op1;
48933
48965
  if (!innerBase) return void 0;
48934
- if (exp2.isEven === true) {
48966
+ if (exp3.isEven === true) {
48935
48967
  return {
48936
- value: innerBase.pow(exp2),
48968
+ value: innerBase.pow(exp3),
48937
48969
  because: "|x|^n -> x^n when n is even"
48938
48970
  };
48939
48971
  }
48940
- if (exp2.operator === "Divide") {
48941
- const n = exp2.op1;
48942
- const m = exp2.op2;
48972
+ if (exp3.operator === "Divide") {
48973
+ const n = exp3.op1;
48974
+ const m = exp3.op2;
48943
48975
  if (n && m && n.isEven === true && m.isOdd === true) {
48944
48976
  return {
48945
- value: innerBase.pow(exp2),
48977
+ value: innerBase.pow(exp3),
48946
48978
  because: "|x|^(n/m) -> x^(n/m) when n even, m odd"
48947
48979
  };
48948
48980
  }
@@ -49097,27 +49129,27 @@ Error in definition of "${name}"`,
49097
49129
  }
49098
49130
  if (op === "Power") {
49099
49131
  const base = x.op1;
49100
- const exp2 = x.op2;
49101
- if (base && exp2) {
49132
+ const exp3 = x.op2;
49133
+ if (base && exp3) {
49102
49134
  const baseIsInf = base.isInfinity === true;
49103
- const expIsInf = exp2.isInfinity === true;
49135
+ const expIsInf = exp3.isInfinity === true;
49104
49136
  const baseIsPosInf = baseIsInf && base.isPositive === true;
49105
49137
  const baseIsNegInf = baseIsInf && base.isNegative === true;
49106
- const expIsPosInf = expIsInf && exp2.isPositive === true;
49107
- const expIsNegInf = expIsInf && exp2.isNegative === true;
49138
+ const expIsPosInf = expIsInf && exp3.isPositive === true;
49139
+ const expIsNegInf = expIsInf && exp3.isNegative === true;
49108
49140
  if (base.symbol === "ExponentialE" && expIsPosInf) {
49109
49141
  return { value: ce.PositiveInfinity, because: "e^(+inf) -> +inf" };
49110
49142
  }
49111
49143
  if (base.symbol === "ExponentialE" && expIsNegInf) {
49112
49144
  return { value: ce.Zero, because: "e^(-inf) -> 0" };
49113
49145
  }
49114
- if (base.is(1) && exp2.isFinite === true) {
49146
+ if (base.is(1) && exp3.isFinite === true) {
49115
49147
  return { value: ce.One, because: "1^finite -> 1" };
49116
49148
  }
49117
- if (exp2.is(0) && baseIsInf) {
49149
+ if (exp3.is(0) && baseIsInf) {
49118
49150
  return { value: ce.NaN, because: "inf^0 -> NaN" };
49119
49151
  }
49120
- if (exp2.is(0) && base.is(0) === false && base.isFinite === true) {
49152
+ if (exp3.is(0) && base.is(0) === false && base.isFinite === true) {
49121
49153
  return { value: ce.One, because: "x^0 -> 1" };
49122
49154
  }
49123
49155
  if (expIsPosInf) {
@@ -49143,28 +49175,28 @@ Error in definition of "${name}"`,
49143
49175
  }
49144
49176
  }
49145
49177
  if (baseIsPosInf) {
49146
- if (exp2.isNegative === true) {
49178
+ if (exp3.isNegative === true) {
49147
49179
  return { value: ce.Zero, because: "+inf^negative -> 0" };
49148
49180
  }
49149
49181
  }
49150
49182
  if (baseIsNegInf) {
49151
- if (exp2.isNegative === true) {
49183
+ if (exp3.isNegative === true) {
49152
49184
  return { value: ce.Zero, because: "-inf^negative -> 0" };
49153
49185
  }
49154
- if (exp2.isInteger === true && exp2.isEven === true) {
49186
+ if (exp3.isInteger === true && exp3.isEven === true) {
49155
49187
  return {
49156
49188
  value: ce.PositiveInfinity,
49157
49189
  because: "(-inf)^(even integer) -> +inf"
49158
49190
  };
49159
49191
  }
49160
- if (exp2.isInteger === true && exp2.isOdd === true) {
49192
+ if (exp3.isInteger === true && exp3.isOdd === true) {
49161
49193
  return {
49162
49194
  value: ce.NegativeInfinity,
49163
49195
  because: "(-inf)^(odd integer) -> -inf"
49164
49196
  };
49165
49197
  }
49166
- if (exp2.isRational === true) {
49167
- const [numExpr, denomExpr] = exp2.numeratorDenominator;
49198
+ if (exp3.isRational === true) {
49199
+ const [numExpr, denomExpr] = exp3.numeratorDenominator;
49168
49200
  const num = numExpr.re;
49169
49201
  const denom = denomExpr.re;
49170
49202
  if (typeof num === "number" && typeof denom === "number" && Number.isInteger(num) && Number.isInteger(denom)) {
@@ -49206,17 +49238,17 @@ Error in definition of "${name}"`,
49206
49238
  }
49207
49239
  if (arg.operator === "Power") {
49208
49240
  const base = arg.op1;
49209
- const exp2 = arg.op2;
49210
- if (base && exp2) {
49211
- if (base.isNonNegative === true || exp2.isOdd === true || exp2.isRational === false) {
49241
+ const exp3 = arg.op2;
49242
+ if (base && exp3) {
49243
+ if (base.isNonNegative === true || exp3.isOdd === true || exp3.isRational === false) {
49212
49244
  return {
49213
- value: exp2.mul(ce._fn("Ln", [base])),
49245
+ value: exp3.mul(ce._fn("Ln", [base])),
49214
49246
  because: "ln(x^n) -> n*ln(x)"
49215
49247
  };
49216
49248
  }
49217
- if (exp2.isEven === true) {
49249
+ if (exp3.isEven === true) {
49218
49250
  return {
49219
- value: exp2.mul(ce._fn("Ln", [ce._fn("Abs", [base])])),
49251
+ value: exp3.mul(ce._fn("Ln", [ce._fn("Abs", [base])])),
49220
49252
  because: "ln(x^n) -> n*ln(|x|) when n even"
49221
49253
  };
49222
49254
  }
@@ -49229,11 +49261,11 @@ Error in definition of "${name}"`,
49229
49261
  for (let i = 0; i < arg.ops.length; i++) {
49230
49262
  const factor3 = arg.ops[i];
49231
49263
  if (factor3.operator === "Power" && factor3.op1?.symbol === "ExponentialE") {
49232
- const exp2 = factor3.op2;
49264
+ const exp3 = factor3.op2;
49233
49265
  const otherFactors = arg.ops.filter((_, idx) => idx !== i);
49234
49266
  const remaining = otherFactors.length === 1 ? otherFactors[0] : ce._fn("Multiply", otherFactors);
49235
49267
  return {
49236
- value: exp2.add(ce._fn("Ln", [remaining])),
49268
+ value: exp3.add(ce._fn("Ln", [remaining])),
49237
49269
  because: "ln(e^x * y) -> x + ln(y)"
49238
49270
  };
49239
49271
  }
@@ -49316,17 +49348,17 @@ Error in definition of "${name}"`,
49316
49348
  }
49317
49349
  if (arg.operator === "Power") {
49318
49350
  const powerBase = arg.op1;
49319
- const exp2 = arg.op2;
49320
- if (powerBase && exp2) {
49321
- if (powerBase.isNonNegative === true || exp2.isOdd === true || exp2.isRational === false) {
49351
+ const exp3 = arg.op2;
49352
+ if (powerBase && exp3) {
49353
+ if (powerBase.isNonNegative === true || exp3.isOdd === true || exp3.isRational === false) {
49322
49354
  return {
49323
- value: exp2.mul(ce._fn("Log", [powerBase, logBase])),
49355
+ value: exp3.mul(ce._fn("Log", [powerBase, logBase])),
49324
49356
  because: "log_c(x^n) -> n*log_c(x)"
49325
49357
  };
49326
49358
  }
49327
- if (exp2.isEven === true) {
49359
+ if (exp3.isEven === true) {
49328
49360
  return {
49329
- value: exp2.mul(
49361
+ value: exp3.mul(
49330
49362
  ce._fn("Log", [ce._fn("Abs", [powerBase]), logBase])
49331
49363
  ),
49332
49364
  because: "log_c(x^n) -> n*log_c(|x|) when n even"
@@ -49338,11 +49370,11 @@ Error in definition of "${name}"`,
49338
49370
  for (let i = 0; i < arg.ops.length; i++) {
49339
49371
  const factor3 = arg.ops[i];
49340
49372
  if (factor3.operator === "Power" && factor3.op1?.isSame(logBase)) {
49341
- const exp2 = factor3.op2;
49373
+ const exp3 = factor3.op2;
49342
49374
  const otherFactors = arg.ops.filter((_, idx) => idx !== i);
49343
49375
  const remaining = otherFactors.length === 1 ? otherFactors[0] : ce._fn("Multiply", otherFactors);
49344
49376
  return {
49345
- value: exp2.add(ce._fn("Log", [remaining, logBase])),
49377
+ value: exp3.add(ce._fn("Log", [remaining, logBase])),
49346
49378
  because: "log_c(c^x * y) -> x + log_c(y)"
49347
49379
  };
49348
49380
  }
@@ -49382,32 +49414,32 @@ Error in definition of "${name}"`,
49382
49414
  }
49383
49415
  if (op === "Power") {
49384
49416
  const base = x.op1;
49385
- const exp2 = x.op2;
49386
- if (!base || !exp2) return void 0;
49387
- if (base.symbol === "ExponentialE" && exp2.operator === "Ln") {
49388
- return { value: exp2.op1, because: "e^ln(x) -> x" };
49417
+ const exp3 = x.op2;
49418
+ if (!base || !exp3) return void 0;
49419
+ if (base.symbol === "ExponentialE" && exp3.operator === "Ln") {
49420
+ return { value: exp3.op1, because: "e^ln(x) -> x" };
49389
49421
  }
49390
- if (base.symbol === "ExponentialE" && exp2.operator === "Log" && exp2.op1) {
49391
- const logBase = exp2.op2;
49422
+ if (base.symbol === "ExponentialE" && exp3.operator === "Log" && exp3.op1) {
49423
+ const logBase = exp3.op2;
49392
49424
  const isDefaultOrBase10 = !logBase || logBase.symbol === "Nothing" || logBase.is(10);
49393
49425
  if (isDefaultOrBase10) {
49394
49426
  return {
49395
- value: exp2.op1.pow(ce.One.div(ce._fn("Ln", [ce.number(10)]))),
49427
+ value: exp3.op1.pow(ce.One.div(ce._fn("Ln", [ce.number(10)]))),
49396
49428
  because: "e^log(x) -> x^{1/ln(10)}"
49397
49429
  };
49398
49430
  }
49399
49431
  if (logBase && logBase.symbol !== "ExponentialE") {
49400
49432
  return {
49401
- value: exp2.op1.pow(ce.One.div(ce._fn("Ln", [logBase]))),
49433
+ value: exp3.op1.pow(ce.One.div(ce._fn("Ln", [logBase]))),
49402
49434
  because: "e^log_c(x) -> x^{1/ln(c)}"
49403
49435
  };
49404
49436
  }
49405
49437
  }
49406
- if (base.symbol === "ExponentialE" && exp2.operator === "Add" && exp2.ops) {
49407
- for (let i = 0; i < exp2.ops.length; i++) {
49408
- const term = exp2.ops[i];
49438
+ if (base.symbol === "ExponentialE" && exp3.operator === "Add" && exp3.ops) {
49439
+ for (let i = 0; i < exp3.ops.length; i++) {
49440
+ const term = exp3.ops[i];
49409
49441
  if (term.operator === "Ln") {
49410
- const otherTerms = exp2.ops.filter((_, idx) => idx !== i);
49442
+ const otherTerms = exp3.ops.filter((_, idx) => idx !== i);
49411
49443
  const remaining = otherTerms.length === 0 ? ce.Zero : otherTerms.length === 1 ? otherTerms[0] : ce._fn("Add", otherTerms);
49412
49444
  return {
49413
49445
  value: term.op1.mul(ce._fn("Exp", [remaining])),
@@ -49415,10 +49447,10 @@ Error in definition of "${name}"`,
49415
49447
  };
49416
49448
  }
49417
49449
  }
49418
- for (let i = 0; i < exp2.ops.length; i++) {
49419
- const term = exp2.ops[i];
49450
+ for (let i = 0; i < exp3.ops.length; i++) {
49451
+ const term = exp3.ops[i];
49420
49452
  if (term.operator !== "Log" || !term.op1) continue;
49421
- const otherTerms = exp2.ops.filter((_, idx) => idx !== i);
49453
+ const otherTerms = exp3.ops.filter((_, idx) => idx !== i);
49422
49454
  const remaining = otherTerms.length === 0 ? ce.Zero : otherTerms.length === 1 ? otherTerms[0] : ce._fn("Add", otherTerms);
49423
49455
  const logBase = term.op2;
49424
49456
  const isDefaultOrBase10 = !logBase || logBase.symbol === "Nothing" || logBase.is(10);
@@ -49429,11 +49461,11 @@ Error in definition of "${name}"`,
49429
49461
  };
49430
49462
  }
49431
49463
  }
49432
- if (base.symbol === "ExponentialE" && exp2.operator === "Multiply" && exp2.ops) {
49433
- for (let i = 0; i < exp2.ops.length; i++) {
49434
- const factor3 = exp2.ops[i];
49464
+ if (base.symbol === "ExponentialE" && exp3.operator === "Multiply" && exp3.ops) {
49465
+ for (let i = 0; i < exp3.ops.length; i++) {
49466
+ const factor3 = exp3.ops[i];
49435
49467
  if (factor3.operator === "Ln") {
49436
- const otherFactors = exp2.ops.filter((_, idx) => idx !== i);
49468
+ const otherFactors = exp3.ops.filter((_, idx) => idx !== i);
49437
49469
  const y = otherFactors.length === 1 ? otherFactors[0] : ce._fn("Multiply", otherFactors);
49438
49470
  return {
49439
49471
  value: factor3.op1.pow(y),
@@ -49442,20 +49474,20 @@ Error in definition of "${name}"`,
49442
49474
  }
49443
49475
  }
49444
49476
  }
49445
- if (base.symbol === "ExponentialE" && exp2.operator === "Divide" && exp2.op1?.operator === "Ln") {
49477
+ if (base.symbol === "ExponentialE" && exp3.operator === "Divide" && exp3.op1?.operator === "Ln") {
49446
49478
  return {
49447
- value: exp2.op1.op1.pow(ce.One.div(exp2.op2)),
49479
+ value: exp3.op1.op1.pow(ce.One.div(exp3.op2)),
49448
49480
  because: "e^(ln(x) / y) -> x^(1/y)"
49449
49481
  };
49450
49482
  }
49451
- if (exp2.operator === "Log" && exp2.op2?.isSame(base)) {
49452
- return { value: exp2.op1, because: "c^log_c(x) -> x" };
49483
+ if (exp3.operator === "Log" && exp3.op2?.isSame(base)) {
49484
+ return { value: exp3.op1, because: "c^log_c(x) -> x" };
49453
49485
  }
49454
- if (exp2.operator === "Add" && exp2.ops) {
49455
- for (let i = 0; i < exp2.ops.length; i++) {
49456
- const term = exp2.ops[i];
49486
+ if (exp3.operator === "Add" && exp3.ops) {
49487
+ for (let i = 0; i < exp3.ops.length; i++) {
49488
+ const term = exp3.ops[i];
49457
49489
  if (term.operator === "Log" && term.op2?.isSame(base)) {
49458
- const otherTerms = exp2.ops.filter((_, idx) => idx !== i);
49490
+ const otherTerms = exp3.ops.filter((_, idx) => idx !== i);
49459
49491
  const remaining = otherTerms.length === 0 ? ce.Zero : otherTerms.length === 1 ? otherTerms[0] : ce._fn("Add", otherTerms);
49460
49492
  return {
49461
49493
  value: term.op1.mul(base.pow(remaining)),
@@ -49464,11 +49496,11 @@ Error in definition of "${name}"`,
49464
49496
  }
49465
49497
  }
49466
49498
  }
49467
- if (exp2.operator === "Multiply" && exp2.ops) {
49468
- for (let i = 0; i < exp2.ops.length; i++) {
49469
- const factor3 = exp2.ops[i];
49499
+ if (exp3.operator === "Multiply" && exp3.ops) {
49500
+ for (let i = 0; i < exp3.ops.length; i++) {
49501
+ const factor3 = exp3.ops[i];
49470
49502
  if (factor3.operator === "Log" && factor3.op2?.isSame(base)) {
49471
- const otherFactors = exp2.ops.filter((_, idx) => idx !== i);
49503
+ const otherFactors = exp3.ops.filter((_, idx) => idx !== i);
49472
49504
  const y = otherFactors.length === 1 ? otherFactors[0] : ce._fn("Multiply", otherFactors);
49473
49505
  return {
49474
49506
  value: factor3.op1.pow(y),
@@ -49477,9 +49509,9 @@ Error in definition of "${name}"`,
49477
49509
  }
49478
49510
  }
49479
49511
  }
49480
- if (exp2.operator === "Divide" && exp2.op1?.operator === "Log" && exp2.op1.op2?.isSame(base)) {
49512
+ if (exp3.operator === "Divide" && exp3.op1?.operator === "Log" && exp3.op1.op2?.isSame(base)) {
49481
49513
  return {
49482
- value: exp2.op1.op1.pow(ce.One.div(exp2.op2)),
49514
+ value: exp3.op1.op1.pow(ce.One.div(exp3.op2)),
49483
49515
  because: "c^(log_c(x) / y) -> x^(1/y)"
49484
49516
  };
49485
49517
  }
@@ -49619,8 +49651,8 @@ Error in definition of "${name}"`,
49619
49651
  }
49620
49652
  if (arg.operator === "Power") {
49621
49653
  const base = arg.op1;
49622
- const exp2 = arg.op2;
49623
- if (base && exp2?.isSame(rootIndex)) {
49654
+ const exp3 = arg.op2;
49655
+ if (base && exp3?.isSame(rootIndex)) {
49624
49656
  if (rootIndex.isEven === true) {
49625
49657
  return {
49626
49658
  value: ce._fn("Abs", [base]),
@@ -49631,8 +49663,8 @@ Error in definition of "${name}"`,
49631
49663
  return { value: base, because: "root(x^n, n) -> x when n odd" };
49632
49664
  }
49633
49665
  }
49634
- if (base && exp2) {
49635
- const resultExp = exp2.div(rootIndex);
49666
+ if (base && exp3) {
49667
+ const resultExp = exp3.div(rootIndex);
49636
49668
  if (rootIndex.isEven === true) {
49637
49669
  if (resultExp.isInteger === true) {
49638
49670
  return {
@@ -49652,7 +49684,7 @@ Error in definition of "${name}"`,
49652
49684
  }
49653
49685
  }
49654
49686
  }
49655
- if (rootIndex.isOdd === true && exp2.isInteger === true) {
49687
+ if (rootIndex.isOdd === true && exp3.isInteger === true) {
49656
49688
  return {
49657
49689
  value: base.pow(resultExp),
49658
49690
  because: "root(x^m, n) -> x^{m/n} when n is odd"
@@ -49705,22 +49737,22 @@ Error in definition of "${name}"`,
49705
49737
  }
49706
49738
  if (arg.operator === "Power") {
49707
49739
  const base = arg.op1;
49708
- const exp2 = arg.op2;
49709
- if (base && exp2) {
49710
- if (exp2.is(2) && base.isNonNegative === true) {
49740
+ const exp3 = arg.op2;
49741
+ if (base && exp3) {
49742
+ if (exp3.is(2) && base.isNonNegative === true) {
49711
49743
  return { value: base, because: "sqrt(x^2) -> x when x >= 0" };
49712
49744
  }
49713
- if (exp2.is(2)) {
49745
+ if (exp3.is(2)) {
49714
49746
  return { value: ce._fn("Abs", [base]), because: "sqrt(x^2) -> |x|" };
49715
49747
  }
49716
- if (exp2.isEven === true && exp2.isPositive === true) {
49748
+ if (exp3.isEven === true && exp3.isPositive === true) {
49717
49749
  return {
49718
- value: ce._fn("Abs", [base]).pow(exp2.div(2)),
49750
+ value: ce._fn("Abs", [base]).pow(exp3.div(2)),
49719
49751
  because: "sqrt(x^{2n}) -> |x|^n"
49720
49752
  };
49721
49753
  }
49722
- if (exp2.isOdd === true && exp2.isInteger === true && exp2.isPositive === true) {
49723
- const n = exp2.sub(ce.One).div(2);
49754
+ if (exp3.isOdd === true && exp3.isInteger === true && exp3.isPositive === true) {
49755
+ const n = exp3.sub(ce.One).div(2);
49724
49756
  if (n.isPositive === true) {
49725
49757
  return {
49726
49758
  value: ce._fn("Abs", [base]).pow(n).mul(ce._fn("Sqrt", [base])),
@@ -49736,13 +49768,13 @@ Error in definition of "${name}"`,
49736
49768
  for (const factor3 of arg.ops) {
49737
49769
  if (factor3.operator === "Power" && factor3.op1 && factor3.op2) {
49738
49770
  const base = factor3.op1;
49739
- const exp2 = factor3.op2;
49740
- if (exp2.is(2)) {
49771
+ const exp3 = factor3.op2;
49772
+ if (exp3.is(2)) {
49741
49773
  perfectSquares.push(ce._fn("Abs", [base]));
49742
- } else if (exp2.isEven === true && exp2.isPositive === true) {
49743
- perfectSquares.push(ce._fn("Abs", [base]).pow(exp2.div(2)));
49744
- } else if (exp2.isInteger === true && exp2.isPositive === true && exp2.isOdd === true) {
49745
- const n = exp2.sub(ce.One).div(2);
49774
+ } else if (exp3.isEven === true && exp3.isPositive === true) {
49775
+ perfectSquares.push(ce._fn("Abs", [base]).pow(exp3.div(2)));
49776
+ } else if (exp3.isInteger === true && exp3.isPositive === true && exp3.isOdd === true) {
49777
+ const n = exp3.sub(ce.One).div(2);
49746
49778
  if (n.isPositive === true) {
49747
49779
  perfectSquares.push(ce._fn("Abs", [base]).pow(n));
49748
49780
  }
@@ -49772,13 +49804,13 @@ Error in definition of "${name}"`,
49772
49804
  }
49773
49805
  if (op === "Power") {
49774
49806
  const base = x.op1;
49775
- const exp2 = x.op2;
49776
- if (!base || !exp2) return void 0;
49777
- if (base.is(0) && exp2.isPositive === true) {
49807
+ const exp3 = x.op2;
49808
+ if (!base || !exp3) return void 0;
49809
+ if (base.is(0) && exp3.isPositive === true) {
49778
49810
  return { value: ce.Zero, because: "0^x -> 0 when x > 0" };
49779
49811
  }
49780
49812
  if (base.is(-1)) {
49781
- const rat = asRational(exp2);
49813
+ const rat = asRational(exp3);
49782
49814
  if (rat) {
49783
49815
  const [num, denom] = rat;
49784
49816
  const numN = Number(num);
@@ -49792,7 +49824,7 @@ Error in definition of "${name}"`,
49792
49824
  }
49793
49825
  }
49794
49826
  if (base.operator === "Multiply" && base.ops) {
49795
- const rat = asRational(exp2);
49827
+ const rat = asRational(exp3);
49796
49828
  if (rat) {
49797
49829
  const [num, denom] = rat;
49798
49830
  const numN = Number(num);
@@ -49816,15 +49848,15 @@ Error in definition of "${name}"`,
49816
49848
  );
49817
49849
  const posBase = newFactors.length === 1 ? newFactors[0] : ce._fn("Multiply", newFactors);
49818
49850
  return {
49819
- value: posBase.pow(exp2).neg(),
49851
+ value: posBase.pow(exp3).neg(),
49820
49852
  because: "(-a*b)^{p/q} -> -(a*b)^{p/q} when p,q odd"
49821
49853
  };
49822
49854
  }
49823
49855
  }
49824
49856
  }
49825
49857
  }
49826
- if (base.operator === "Multiply" && base.ops && exp2.isInteger === true) {
49827
- const newFactors = base.ops.map((factor3) => factor3.pow(exp2));
49858
+ if (base.operator === "Multiply" && base.ops && exp3.isInteger === true) {
49859
+ const newFactors = base.ops.map((factor3) => factor3.pow(exp3));
49828
49860
  return {
49829
49861
  value: ce._fn("Multiply", newFactors),
49830
49862
  because: "(a*b)^n -> a^n * b^n"
@@ -49832,19 +49864,19 @@ Error in definition of "${name}"`,
49832
49864
  }
49833
49865
  if (base.operator === "Negate" && base.op1) {
49834
49866
  const innerBase = base.op1;
49835
- if (exp2.isEven === true) {
49867
+ if (exp3.isEven === true) {
49836
49868
  return {
49837
- value: innerBase.pow(exp2),
49869
+ value: innerBase.pow(exp3),
49838
49870
  because: "(-x)^n -> x^n when n is even"
49839
49871
  };
49840
49872
  }
49841
- if (exp2.isOdd === true) {
49873
+ if (exp3.isOdd === true) {
49842
49874
  return {
49843
- value: innerBase.pow(exp2).neg(),
49875
+ value: innerBase.pow(exp3).neg(),
49844
49876
  because: "(-x)^n -> -x^n when n is odd"
49845
49877
  };
49846
49878
  }
49847
- const rat = asRational(exp2);
49879
+ const rat = asRational(exp3);
49848
49880
  if (rat) {
49849
49881
  const [num, denom] = rat;
49850
49882
  const numN = Number(num);
@@ -49854,13 +49886,13 @@ Error in definition of "${name}"`,
49854
49886
  const denomIsOdd = denomN % 2 !== 0;
49855
49887
  if (numIsEven && denomIsOdd) {
49856
49888
  return {
49857
- value: innerBase.pow(exp2),
49889
+ value: innerBase.pow(exp3),
49858
49890
  because: "(-x)^{n/m} -> x^{n/m} when n is even and m is odd"
49859
49891
  };
49860
49892
  }
49861
49893
  if (numIsOdd && denomIsOdd) {
49862
49894
  return {
49863
- value: innerBase.pow(exp2).neg(),
49895
+ value: innerBase.pow(exp3).neg(),
49864
49896
  because: "(-x)^{n/m} -> -x^{n/m} when n and m are odd"
49865
49897
  };
49866
49898
  }
@@ -49868,15 +49900,15 @@ Error in definition of "${name}"`,
49868
49900
  }
49869
49901
  if (base.operator === "Sqrt" && base.op1) {
49870
49902
  const innerBase = base.op1;
49871
- if (exp2.isEven === true) {
49903
+ if (exp3.isEven === true) {
49872
49904
  return {
49873
- value: innerBase.pow(exp2.div(2)),
49905
+ value: innerBase.pow(exp3.div(2)),
49874
49906
  because: "sqrt(x)^n -> x^{n/2} when n is even"
49875
49907
  };
49876
49908
  }
49877
49909
  if (innerBase.isNonNegative === true) {
49878
49910
  return {
49879
- value: innerBase.pow(exp2.div(2)),
49911
+ value: innerBase.pow(exp3.div(2)),
49880
49912
  because: "sqrt(x)^n -> x^{n/2} when x >= 0"
49881
49913
  };
49882
49914
  }
@@ -49884,7 +49916,7 @@ Error in definition of "${name}"`,
49884
49916
  if (base.operator === "Root" && base.op1 && base.op2) {
49885
49917
  const innerBase = base.op1;
49886
49918
  const rootIndex = base.op2;
49887
- const resultExp = exp2.div(rootIndex);
49919
+ const resultExp = exp3.div(rootIndex);
49888
49920
  if (resultExp.isInteger === true || innerBase.isNonNegative === true) {
49889
49921
  return {
49890
49922
  value: innerBase.pow(resultExp),
@@ -49896,13 +49928,13 @@ Error in definition of "${name}"`,
49896
49928
  const innerBase = base.op1;
49897
49929
  const innerExp = base.op2;
49898
49930
  if (innerBase && innerExp) {
49899
- const bothIntegers = innerExp.isInteger === true && exp2.isInteger === true;
49931
+ const bothIntegers = innerExp.isInteger === true && exp3.isInteger === true;
49900
49932
  const baseNonNeg = innerBase.isNonNegative === true;
49901
- const productIrrational = innerExp.mul(exp2).isRational === false;
49902
- const atLeastOnePositive = innerExp.isPositive === true || exp2.isPositive === true;
49933
+ const productIrrational = innerExp.mul(exp3).isRational === false;
49934
+ const atLeastOnePositive = innerExp.isPositive === true || exp3.isPositive === true;
49903
49935
  if ((bothIntegers || baseNonNeg || productIrrational) && atLeastOnePositive) {
49904
49936
  return {
49905
- value: innerBase.pow(innerExp.mul(exp2)),
49937
+ value: innerBase.pow(innerExp.mul(exp3)),
49906
49938
  because: "(x^n)^m -> x^{n*m}"
49907
49939
  };
49908
49940
  }
@@ -49911,18 +49943,18 @@ Error in definition of "${name}"`,
49911
49943
  if (base.operator === "Divide" && base.op2?.is(0) === false) {
49912
49944
  const num = base.op1;
49913
49945
  const denom = base.op2;
49914
- if (exp2.operator === "Negate") {
49946
+ if (exp3.operator === "Negate") {
49915
49947
  return {
49916
- value: denom.div(num).pow(exp2.op1),
49948
+ value: denom.div(num).pow(exp3.op1),
49917
49949
  because: "(a/b)^{-n} -> (b/a)^n"
49918
49950
  };
49919
49951
  }
49920
- if (exp2.is(-1)) {
49952
+ if (exp3.is(-1)) {
49921
49953
  return { value: denom.div(num), because: "(a/b)^{-1} -> b/a" };
49922
49954
  }
49923
- if (exp2.isNegative === true && exp2.isNumberLiteral) {
49955
+ if (exp3.isNegative === true && exp3.isNumberLiteral) {
49924
49956
  return {
49925
- value: denom.div(num).pow(exp2.neg()),
49957
+ value: denom.div(num).pow(exp3.neg()),
49926
49958
  because: "(a/b)^{-n} -> (b/a)^n"
49927
49959
  };
49928
49960
  }
@@ -49958,10 +49990,10 @@ Error in definition of "${name}"`,
49958
49990
  }
49959
49991
  if (denom.operator === "Power" && denom.op1?.is(0) === false) {
49960
49992
  const base = denom.op1;
49961
- const exp2 = denom.op2;
49962
- if (exp2?.operator === "Negate") {
49993
+ const exp3 = denom.op2;
49994
+ if (exp3?.operator === "Negate") {
49963
49995
  return {
49964
- value: num.mul(base.pow(exp2.op1)),
49996
+ value: num.mul(base.pow(exp3.op1)),
49965
49997
  because: "a / b^{-n} -> a * b^n"
49966
49998
  };
49967
49999
  }
@@ -49984,9 +50016,9 @@ Error in definition of "${name}"`,
49984
50016
  if (denom.operator === "Power" && denom.op1?.operator === "Divide" && denom.op1.op2?.is(0) === false) {
49985
50017
  const fracNum = denom.op1.op1;
49986
50018
  const fracDenom = denom.op1.op2;
49987
- const exp2 = denom.op2;
50019
+ const exp3 = denom.op2;
49988
50020
  return {
49989
- value: num.mul(fracDenom.div(fracNum).pow(exp2)),
50021
+ value: num.mul(fracDenom.div(fracNum).pow(exp3)),
49990
50022
  because: "a / (b/c)^d -> a * (c/b)^d"
49991
50023
  };
49992
50024
  }
@@ -50161,12 +50193,12 @@ Error in definition of "${name}"`,
50161
50193
  const left = arg.op1;
50162
50194
  const right = arg.op2;
50163
50195
  if (left?.symbol === "Pi" && right) {
50164
- const sign2 = PI_MINUS_SIGN[op];
50165
- if (sign2 !== void 0) {
50196
+ const sign3 = PI_MINUS_SIGN[op];
50197
+ if (sign3 !== void 0) {
50166
50198
  const result = ce._fn(op, [right]);
50167
50199
  return {
50168
- value: sign2 === 1 ? result : result.neg(),
50169
- because: `${op}(\u03C0 - x) -> ${sign2 === 1 ? "" : "-"}${op}(x)`
50200
+ value: sign3 === 1 ? result : result.neg(),
50201
+ because: `${op}(\u03C0 - x) -> ${sign3 === 1 ? "" : "-"}${op}(x)`
50170
50202
  };
50171
50203
  }
50172
50204
  }
@@ -50177,12 +50209,12 @@ Error in definition of "${name}"`,
50177
50209
  const otherTerms = arg.ops.filter((_, idx) => idx !== piIndex);
50178
50210
  if (otherTerms.length === arg.ops.length - 1) {
50179
50211
  const remaining = otherTerms.length === 1 ? otherTerms[0] : ce._fn("Add", otherTerms);
50180
- const sign2 = PI_PLUS_SIGN[op];
50181
- if (sign2 !== void 0) {
50212
+ const sign3 = PI_PLUS_SIGN[op];
50213
+ if (sign3 !== void 0) {
50182
50214
  const result = ce._fn(op, [remaining]);
50183
50215
  return {
50184
- value: sign2 === 1 ? result : result.neg(),
50185
- because: `${op}(\u03C0 + x) -> ${sign2 === 1 ? "" : "-"}${op}(x)`
50216
+ value: sign3 === 1 ? result : result.neg(),
50217
+ because: `${op}(\u03C0 + x) -> ${sign3 === 1 ? "" : "-"}${op}(x)`
50186
50218
  };
50187
50219
  }
50188
50220
  }
@@ -51127,13 +51159,13 @@ Error in definition of "${name}"`,
51127
51159
  const otherTerms = [];
51128
51160
  for (const term of x.ops) {
51129
51161
  let base;
51130
- let exp2;
51162
+ let exp3;
51131
51163
  if (term.operator === "Power") {
51132
51164
  base = term.op1;
51133
- exp2 = term.op2;
51165
+ exp3 = term.op2;
51134
51166
  } else if (term.symbol) {
51135
51167
  base = term;
51136
- exp2 = ce.One;
51168
+ exp3 = ce.One;
51137
51169
  } else {
51138
51170
  otherTerms.push(term);
51139
51171
  continue;
@@ -51144,7 +51176,7 @@ Error in definition of "${name}"`,
51144
51176
  group = { base, terms: [] };
51145
51177
  baseGroups.set(baseKey, group);
51146
51178
  }
51147
- group.terms.push({ term, exp: exp2 });
51179
+ group.terms.push({ term, exp: exp3 });
51148
51180
  }
51149
51181
  let hasCombinations = false;
51150
51182
  for (const group of baseGroups.values()) {
@@ -51487,12 +51519,12 @@ Error in definition of "${name}"`,
51487
51519
  Power: (args, compile) => {
51488
51520
  const arg = args[0];
51489
51521
  if (arg === null) throw new Error("Power: no argument");
51490
- const exp2 = args[1].re;
51491
- if (exp2 === 0.5) return `Math.sqrt(${compile(arg)})`;
51492
- if (exp2 === 1 / 3) return `Math.cbrt(${compile(arg)})`;
51493
- if (exp2 === 1) return compile(arg);
51494
- if (exp2 === -1) return `(1 / (${compile(arg)}))`;
51495
- if (exp2 === -0.5) return `(1 / Math.sqrt(${compile(arg)}))`;
51522
+ const exp3 = args[1].re;
51523
+ if (exp3 === 0.5) return `Math.sqrt(${compile(arg)})`;
51524
+ if (exp3 === 1 / 3) return `Math.cbrt(${compile(arg)})`;
51525
+ if (exp3 === 1) return compile(arg);
51526
+ if (exp3 === -1) return `(1 / (${compile(arg)}))`;
51527
+ if (exp3 === -0.5) return `(1 / Math.sqrt(${compile(arg)}))`;
51496
51528
  return `Math.pow(${compile(arg)}, ${compile(args[1])})`;
51497
51529
  },
51498
51530
  Range: (args, compile) => {
@@ -51526,13 +51558,13 @@ Error in definition of "${name}"`,
51526
51558
  }
51527
51559
  return `Array.from({length: Math.floor((${stop} - ${start}) / ${step}) + 1}, (_, i) => ${start} + i * ${step})`;
51528
51560
  },
51529
- Root: ([arg, exp2], compile) => {
51561
+ Root: ([arg, exp3], compile) => {
51530
51562
  if (arg === null) throw new Error("Root: no argument");
51531
- if (exp2 === null) return `Math.sqrt(${compile(arg)})`;
51532
- if (exp2?.re === 2) return `Math.sqrt(${compile(arg)})`;
51533
- if (exp2?.re === 3) return `Math.cbrt(${compile(arg)})`;
51534
- if (!isNaN(exp2?.re)) return `Math.pow(${compile(arg)}, ${1 / exp2.re})`;
51535
- return `Math.pow(${compile(arg)}, 1 / (${compile(exp2)}))`;
51563
+ if (exp3 === null) return `Math.sqrt(${compile(arg)})`;
51564
+ if (exp3?.re === 2) return `Math.sqrt(${compile(arg)})`;
51565
+ if (exp3?.re === 3) return `Math.cbrt(${compile(arg)})`;
51566
+ if (!isNaN(exp3?.re)) return `Math.pow(${compile(arg)}, ${1 / exp3.re})`;
51567
+ return `Math.pow(${compile(arg)}, 1 / (${compile(exp3)}))`;
51536
51568
  },
51537
51569
  Random: "Math.random",
51538
51570
  Round: "Math.round",
@@ -52018,6 +52050,1611 @@ Error in definition of "${name}"`,
52018
52050
  }
52019
52051
  };
52020
52052
 
52053
+ // src/compute-engine/compilation/interval-javascript-target.ts
52054
+ init_base_compiler();
52055
+
52056
+ // src/compute-engine/interval/util.ts
52057
+ function ok(value) {
52058
+ return { kind: "interval", value };
52059
+ }
52060
+ function point(n) {
52061
+ return { lo: n, hi: n };
52062
+ }
52063
+ function containsExtremum(x, extremum, period) {
52064
+ const n = Math.ceil((x.lo - extremum) / period);
52065
+ const candidate = extremum + n * period;
52066
+ const EPS = 1e-15;
52067
+ return candidate >= x.lo - EPS && candidate <= x.hi + EPS;
52068
+ }
52069
+ function unionResults(a, b) {
52070
+ if (a.kind === "empty") return b;
52071
+ if (b.kind === "empty") return a;
52072
+ if (a.kind === "singular" || b.kind === "singular") {
52073
+ return { kind: "singular" };
52074
+ }
52075
+ if (a.kind === "entire" || b.kind === "entire") {
52076
+ return { kind: "entire" };
52077
+ }
52078
+ const aVal = a.value;
52079
+ const bVal = b.value;
52080
+ const aDomainClip = a.kind === "partial" ? a.domainClipped : null;
52081
+ const bDomainClip = b.kind === "partial" ? b.domainClipped : null;
52082
+ const value = {
52083
+ lo: Math.min(aVal.lo, bVal.lo),
52084
+ hi: Math.max(aVal.hi, bVal.hi)
52085
+ };
52086
+ if (aDomainClip || bDomainClip) {
52087
+ const domainClipped = mergeDomainClip(aDomainClip, bDomainClip);
52088
+ return { kind: "partial", value, domainClipped };
52089
+ }
52090
+ return { kind: "interval", value };
52091
+ }
52092
+ function mergeDomainClip(a, b) {
52093
+ if (a === "both" || b === "both") return "both";
52094
+ if (a === null) return b;
52095
+ if (b === null) return a;
52096
+ if (a === b) return a;
52097
+ return "both";
52098
+ }
52099
+ function isPoint(x) {
52100
+ return x.lo === x.hi;
52101
+ }
52102
+ function containsZero(x) {
52103
+ return x.lo <= 0 && x.hi >= 0;
52104
+ }
52105
+ function isPositive2(x) {
52106
+ return x.lo > 0;
52107
+ }
52108
+ function isNegative(x) {
52109
+ return x.hi < 0;
52110
+ }
52111
+ function isNonNegative(x) {
52112
+ return x.lo >= 0;
52113
+ }
52114
+ function isNonPositive(x) {
52115
+ return x.hi <= 0;
52116
+ }
52117
+ function width(x) {
52118
+ return x.hi - x.lo;
52119
+ }
52120
+ function midpoint(x) {
52121
+ return (x.lo + x.hi) / 2;
52122
+ }
52123
+ function getValue(result) {
52124
+ if (result.kind === "interval" || result.kind === "partial") {
52125
+ return result.value;
52126
+ }
52127
+ return void 0;
52128
+ }
52129
+ function unwrap(input) {
52130
+ if ("kind" in input) {
52131
+ if (input.kind === "interval" || input.kind === "partial") {
52132
+ return input.value;
52133
+ }
52134
+ return void 0;
52135
+ }
52136
+ return input;
52137
+ }
52138
+ function unwrapOrPropagate(...inputs) {
52139
+ const result = [];
52140
+ for (const input of inputs) {
52141
+ if ("kind" in input) {
52142
+ if (input.kind === "empty") return { kind: "empty" };
52143
+ if (input.kind === "entire") return { kind: "entire" };
52144
+ if (input.kind === "singular") return input;
52145
+ result.push(input.value);
52146
+ } else {
52147
+ result.push(input);
52148
+ }
52149
+ }
52150
+ return result;
52151
+ }
52152
+
52153
+ // src/compute-engine/interval/arithmetic.ts
52154
+ function add4(a, b) {
52155
+ const unwrapped = unwrapOrPropagate(a, b);
52156
+ if (!Array.isArray(unwrapped)) return unwrapped;
52157
+ const [aVal, bVal] = unwrapped;
52158
+ return ok({ lo: aVal.lo + bVal.lo, hi: aVal.hi + bVal.hi });
52159
+ }
52160
+ function sub2(a, b) {
52161
+ const unwrapped = unwrapOrPropagate(a, b);
52162
+ if (!Array.isArray(unwrapped)) return unwrapped;
52163
+ const [aVal, bVal] = unwrapped;
52164
+ return ok({ lo: aVal.lo - bVal.hi, hi: aVal.hi - bVal.lo });
52165
+ }
52166
+ function negate2(x) {
52167
+ const unwrapped = unwrapOrPropagate(x);
52168
+ if (!Array.isArray(unwrapped)) return unwrapped;
52169
+ const [xVal] = unwrapped;
52170
+ return ok({ lo: -xVal.hi, hi: -xVal.lo });
52171
+ }
52172
+ function _mul(a, b) {
52173
+ const products = [a.lo * b.lo, a.lo * b.hi, a.hi * b.lo, a.hi * b.hi];
52174
+ return { lo: Math.min(...products), hi: Math.max(...products) };
52175
+ }
52176
+ function mul4(a, b) {
52177
+ const unwrapped = unwrapOrPropagate(a, b);
52178
+ if (!Array.isArray(unwrapped)) return unwrapped;
52179
+ const [aVal, bVal] = unwrapped;
52180
+ return ok(_mul(aVal, bVal));
52181
+ }
52182
+ function div3(a, b) {
52183
+ const unwrapped = unwrapOrPropagate(a, b);
52184
+ if (!Array.isArray(unwrapped)) return unwrapped;
52185
+ const [aVal, bVal] = unwrapped;
52186
+ return _div(aVal, bVal);
52187
+ }
52188
+ function _div(a, b) {
52189
+ if (b.lo > 0 || b.hi < 0) {
52190
+ return ok(_mul(a, { lo: 1 / b.hi, hi: 1 / b.lo }));
52191
+ }
52192
+ if (b.lo < 0 && b.hi > 0) {
52193
+ return { kind: "singular" };
52194
+ }
52195
+ if (b.lo === 0 && b.hi > 0) {
52196
+ if (a.lo >= 0) {
52197
+ return {
52198
+ kind: "partial",
52199
+ value: { lo: a.lo / b.hi, hi: Infinity },
52200
+ domainClipped: "hi"
52201
+ };
52202
+ } else if (a.hi <= 0) {
52203
+ return {
52204
+ kind: "partial",
52205
+ value: { lo: -Infinity, hi: a.hi / b.hi },
52206
+ domainClipped: "lo"
52207
+ };
52208
+ } else {
52209
+ return { kind: "entire" };
52210
+ }
52211
+ }
52212
+ if (b.hi === 0 && b.lo < 0) {
52213
+ if (a.lo >= 0) {
52214
+ return {
52215
+ kind: "partial",
52216
+ value: { lo: -Infinity, hi: a.lo / b.lo },
52217
+ domainClipped: "lo"
52218
+ };
52219
+ } else if (a.hi <= 0) {
52220
+ return {
52221
+ kind: "partial",
52222
+ value: { lo: a.hi / b.lo, hi: Infinity },
52223
+ domainClipped: "hi"
52224
+ };
52225
+ } else {
52226
+ return { kind: "entire" };
52227
+ }
52228
+ }
52229
+ return { kind: "empty" };
52230
+ }
52231
+
52232
+ // src/compute-engine/interval/elementary.ts
52233
+ function sqrt2(x) {
52234
+ const unwrapped = unwrapOrPropagate(x);
52235
+ if (!Array.isArray(unwrapped)) return unwrapped;
52236
+ const [xVal] = unwrapped;
52237
+ return _sqrt(xVal);
52238
+ }
52239
+ function _sqrt(x) {
52240
+ if (x.hi < 0) {
52241
+ return { kind: "empty" };
52242
+ }
52243
+ if (x.lo >= 0) {
52244
+ return ok({ lo: Math.sqrt(x.lo), hi: Math.sqrt(x.hi) });
52245
+ }
52246
+ return {
52247
+ kind: "partial",
52248
+ value: { lo: 0, hi: Math.sqrt(x.hi) },
52249
+ domainClipped: "lo"
52250
+ };
52251
+ }
52252
+ function square(x) {
52253
+ const unwrapped = unwrapOrPropagate(x);
52254
+ if (!Array.isArray(unwrapped)) return unwrapped;
52255
+ const [xVal] = unwrapped;
52256
+ if (xVal.lo >= 0) {
52257
+ return ok({ lo: xVal.lo * xVal.lo, hi: xVal.hi * xVal.hi });
52258
+ } else if (xVal.hi <= 0) {
52259
+ return ok({ lo: xVal.hi * xVal.hi, hi: xVal.lo * xVal.lo });
52260
+ } else {
52261
+ return ok({ lo: 0, hi: Math.max(xVal.lo * xVal.lo, xVal.hi * xVal.hi) });
52262
+ }
52263
+ }
52264
+ function intPow2(base, n) {
52265
+ if (n === 0) return { lo: 1, hi: 1 };
52266
+ if (n === 1) return base;
52267
+ if (n % 2 === 0) {
52268
+ if (base.lo >= 0) {
52269
+ return { lo: Math.pow(base.lo, n), hi: Math.pow(base.hi, n) };
52270
+ } else if (base.hi <= 0) {
52271
+ return { lo: Math.pow(base.hi, n), hi: Math.pow(base.lo, n) };
52272
+ } else {
52273
+ return {
52274
+ lo: 0,
52275
+ hi: Math.max(Math.pow(base.lo, n), Math.pow(base.hi, n))
52276
+ };
52277
+ }
52278
+ }
52279
+ return { lo: Math.pow(base.lo, n), hi: Math.pow(base.hi, n) };
52280
+ }
52281
+ function pow3(base, exp3) {
52282
+ if (Number.isInteger(exp3)) {
52283
+ if (exp3 >= 0) {
52284
+ return ok(intPow2(base, exp3));
52285
+ } else {
52286
+ if (containsZero(base)) {
52287
+ return { kind: "singular" };
52288
+ }
52289
+ const denom = intPow2(base, -exp3);
52290
+ return ok({ lo: 1 / denom.hi, hi: 1 / denom.lo });
52291
+ }
52292
+ } else {
52293
+ if (isNegative(base)) {
52294
+ return { kind: "empty" };
52295
+ }
52296
+ if (base.lo < 0) {
52297
+ const value = exp3 > 0 ? { lo: 0, hi: Math.pow(base.hi, exp3) } : { lo: Math.pow(base.hi, exp3), hi: Infinity };
52298
+ return { kind: "partial", value, domainClipped: "lo" };
52299
+ }
52300
+ if (exp3 > 0) {
52301
+ return ok({ lo: Math.pow(base.lo, exp3), hi: Math.pow(base.hi, exp3) });
52302
+ } else {
52303
+ if (base.lo === 0) {
52304
+ return {
52305
+ kind: "partial",
52306
+ value: { lo: Math.pow(base.hi, exp3), hi: Infinity },
52307
+ domainClipped: "hi"
52308
+ };
52309
+ }
52310
+ return ok({ lo: Math.pow(base.hi, exp3), hi: Math.pow(base.lo, exp3) });
52311
+ }
52312
+ }
52313
+ }
52314
+ function powInterval(base, exp3) {
52315
+ if (base.hi <= 0) {
52316
+ return { kind: "empty" };
52317
+ }
52318
+ if (base.lo <= 0) {
52319
+ const posBase = { lo: Math.max(base.lo, Number.EPSILON), hi: base.hi };
52320
+ const corners2 = [
52321
+ Math.pow(posBase.lo, exp3.lo),
52322
+ Math.pow(posBase.lo, exp3.hi),
52323
+ Math.pow(posBase.hi, exp3.lo),
52324
+ Math.pow(posBase.hi, exp3.hi)
52325
+ ];
52326
+ return {
52327
+ kind: "partial",
52328
+ value: { lo: Math.min(...corners2), hi: Math.max(...corners2) },
52329
+ domainClipped: "lo"
52330
+ };
52331
+ }
52332
+ const corners = [
52333
+ Math.pow(base.lo, exp3.lo),
52334
+ Math.pow(base.lo, exp3.hi),
52335
+ Math.pow(base.hi, exp3.lo),
52336
+ Math.pow(base.hi, exp3.hi)
52337
+ ];
52338
+ return ok({ lo: Math.min(...corners), hi: Math.max(...corners) });
52339
+ }
52340
+ function exp2(x) {
52341
+ const unwrapped = unwrapOrPropagate(x);
52342
+ if (!Array.isArray(unwrapped)) return unwrapped;
52343
+ const [xVal] = unwrapped;
52344
+ return ok({ lo: Math.exp(xVal.lo), hi: Math.exp(xVal.hi) });
52345
+ }
52346
+ function ln2(x) {
52347
+ if (x.hi <= 0) {
52348
+ return { kind: "empty" };
52349
+ }
52350
+ if (x.lo > 0) {
52351
+ return ok({ lo: Math.log(x.lo), hi: Math.log(x.hi) });
52352
+ }
52353
+ return {
52354
+ kind: "partial",
52355
+ value: { lo: -Infinity, hi: Math.log(x.hi) },
52356
+ domainClipped: "lo"
52357
+ };
52358
+ }
52359
+ function log102(x) {
52360
+ if (x.hi <= 0) {
52361
+ return { kind: "empty" };
52362
+ }
52363
+ if (x.lo > 0) {
52364
+ return ok({ lo: Math.log10(x.lo), hi: Math.log10(x.hi) });
52365
+ }
52366
+ return {
52367
+ kind: "partial",
52368
+ value: { lo: -Infinity, hi: Math.log10(x.hi) },
52369
+ domainClipped: "lo"
52370
+ };
52371
+ }
52372
+ function log22(x) {
52373
+ if (x.hi <= 0) {
52374
+ return { kind: "empty" };
52375
+ }
52376
+ if (x.lo > 0) {
52377
+ return ok({ lo: Math.log2(x.lo), hi: Math.log2(x.hi) });
52378
+ }
52379
+ return {
52380
+ kind: "partial",
52381
+ value: { lo: -Infinity, hi: Math.log2(x.hi) },
52382
+ domainClipped: "lo"
52383
+ };
52384
+ }
52385
+ function abs2(x) {
52386
+ if (x.lo >= 0) {
52387
+ return ok(x);
52388
+ }
52389
+ if (x.hi <= 0) {
52390
+ return ok({ lo: -x.hi, hi: -x.lo });
52391
+ }
52392
+ return ok({ lo: 0, hi: Math.max(-x.lo, x.hi) });
52393
+ }
52394
+ function floor2(x) {
52395
+ return ok({ lo: Math.floor(x.lo), hi: Math.floor(x.hi) });
52396
+ }
52397
+ function ceil2(x) {
52398
+ return ok({ lo: Math.ceil(x.lo), hi: Math.ceil(x.hi) });
52399
+ }
52400
+ function round2(x) {
52401
+ return ok({ lo: Math.round(x.lo), hi: Math.round(x.hi) });
52402
+ }
52403
+ function min2(a, b) {
52404
+ return ok({ lo: Math.min(a.lo, b.lo), hi: Math.min(a.hi, b.hi) });
52405
+ }
52406
+ function max2(a, b) {
52407
+ return ok({ lo: Math.max(a.lo, b.lo), hi: Math.max(a.hi, b.hi) });
52408
+ }
52409
+ function mod2(a, b) {
52410
+ if (containsZero(b)) {
52411
+ return { kind: "singular" };
52412
+ }
52413
+ const bAbs = Math.max(Math.abs(b.lo), Math.abs(b.hi));
52414
+ const aWidth = a.hi - a.lo;
52415
+ if (aWidth >= bAbs) {
52416
+ return ok({ lo: 0, hi: bAbs });
52417
+ }
52418
+ const modLo = (a.lo % bAbs + bAbs) % bAbs;
52419
+ const modHi = (a.hi % bAbs + bAbs) % bAbs;
52420
+ if (modLo <= modHi) {
52421
+ return ok({ lo: modLo, hi: modHi });
52422
+ } else {
52423
+ return ok({ lo: 0, hi: bAbs });
52424
+ }
52425
+ }
52426
+ function sign2(x) {
52427
+ if (x.lo > 0) return ok({ lo: 1, hi: 1 });
52428
+ if (x.hi < 0) return ok({ lo: -1, hi: -1 });
52429
+ if (x.lo === 0 && x.hi === 0) return ok({ lo: 0, hi: 0 });
52430
+ if (x.lo < 0 && x.hi > 0) return ok({ lo: -1, hi: 1 });
52431
+ if (x.lo === 0) return ok({ lo: 0, hi: 1 });
52432
+ return ok({ lo: -1, hi: 0 });
52433
+ }
52434
+
52435
+ // src/compute-engine/interval/trigonometric.ts
52436
+ var TWO_PI = 2 * Math.PI;
52437
+ var PI2 = Math.PI;
52438
+ var HALF_PI = Math.PI / 2;
52439
+ var THREE_HALF_PI = 3 * Math.PI / 2;
52440
+ function sin2(x) {
52441
+ if (x.hi - x.lo >= TWO_PI) {
52442
+ return ok({ lo: -1, hi: 1 });
52443
+ }
52444
+ const sinLo = Math.sin(x.lo);
52445
+ const sinHi = Math.sin(x.hi);
52446
+ let lo = Math.min(sinLo, sinHi);
52447
+ let hi = Math.max(sinLo, sinHi);
52448
+ if (containsExtremum(x, HALF_PI, TWO_PI)) {
52449
+ hi = 1;
52450
+ }
52451
+ if (containsExtremum(x, THREE_HALF_PI, TWO_PI)) {
52452
+ lo = -1;
52453
+ }
52454
+ return ok({ lo, hi });
52455
+ }
52456
+ function cos2(x) {
52457
+ if (x.hi - x.lo >= TWO_PI) {
52458
+ return ok({ lo: -1, hi: 1 });
52459
+ }
52460
+ const cosLo = Math.cos(x.lo);
52461
+ const cosHi = Math.cos(x.hi);
52462
+ let lo = Math.min(cosLo, cosHi);
52463
+ let hi = Math.max(cosLo, cosHi);
52464
+ if (containsExtremum(x, 0, TWO_PI)) {
52465
+ hi = 1;
52466
+ }
52467
+ if (containsExtremum(x, PI2, TWO_PI)) {
52468
+ lo = -1;
52469
+ }
52470
+ return ok({ lo, hi });
52471
+ }
52472
+ function tan2(x) {
52473
+ if (x.hi - x.lo >= PI2) {
52474
+ return { kind: "singular" };
52475
+ }
52476
+ if (containsExtremum(x, HALF_PI, PI2)) {
52477
+ const n = Math.ceil((x.lo - HALF_PI) / PI2);
52478
+ const poleAt = HALF_PI + n * PI2;
52479
+ return { kind: "singular", at: poleAt };
52480
+ }
52481
+ const tanLo = Math.tan(x.lo);
52482
+ const tanHi = Math.tan(x.hi);
52483
+ if (tanLo > 1e10 && tanHi < -1e10 || tanLo < -1e10 && tanHi > 1e10) {
52484
+ return { kind: "singular" };
52485
+ }
52486
+ return ok({ lo: tanLo, hi: tanHi });
52487
+ }
52488
+ function cot(x) {
52489
+ if (x.hi - x.lo >= PI2) {
52490
+ return { kind: "singular" };
52491
+ }
52492
+ if (containsExtremum(x, 0, PI2)) {
52493
+ const n = Math.ceil(x.lo / PI2);
52494
+ const poleAt = n * PI2;
52495
+ return { kind: "singular", at: poleAt };
52496
+ }
52497
+ const cotLo = 1 / Math.tan(x.lo);
52498
+ const cotHi = 1 / Math.tan(x.hi);
52499
+ return ok({ lo: Math.min(cotLo, cotHi), hi: Math.max(cotLo, cotHi) });
52500
+ }
52501
+ function sec(x) {
52502
+ if (x.hi - x.lo >= PI2) {
52503
+ return { kind: "singular" };
52504
+ }
52505
+ if (containsExtremum(x, HALF_PI, PI2)) {
52506
+ const n = Math.ceil((x.lo - HALF_PI) / PI2);
52507
+ const poleAt = HALF_PI + n * PI2;
52508
+ return { kind: "singular", at: poleAt };
52509
+ }
52510
+ const secLo = 1 / Math.cos(x.lo);
52511
+ const secHi = 1 / Math.cos(x.hi);
52512
+ let lo = Math.min(secLo, secHi);
52513
+ let hi = Math.max(secLo, secHi);
52514
+ if (containsExtremum(x, 0, TWO_PI)) {
52515
+ lo = Math.min(lo, 1);
52516
+ hi = Math.max(hi, 1);
52517
+ }
52518
+ if (containsExtremum(x, PI2, TWO_PI)) {
52519
+ lo = Math.min(lo, -1);
52520
+ hi = Math.max(hi, -1);
52521
+ }
52522
+ return ok({ lo, hi });
52523
+ }
52524
+ function csc(x) {
52525
+ if (x.hi - x.lo >= PI2) {
52526
+ return { kind: "singular" };
52527
+ }
52528
+ if (containsExtremum(x, 0, PI2)) {
52529
+ const n = Math.ceil(x.lo / PI2);
52530
+ const poleAt = n * PI2;
52531
+ return { kind: "singular", at: poleAt };
52532
+ }
52533
+ const cscLo = 1 / Math.sin(x.lo);
52534
+ const cscHi = 1 / Math.sin(x.hi);
52535
+ let lo = Math.min(cscLo, cscHi);
52536
+ let hi = Math.max(cscLo, cscHi);
52537
+ if (containsExtremum(x, HALF_PI, TWO_PI)) {
52538
+ lo = Math.min(lo, 1);
52539
+ hi = Math.max(hi, 1);
52540
+ }
52541
+ if (containsExtremum(x, THREE_HALF_PI, TWO_PI)) {
52542
+ lo = Math.min(lo, -1);
52543
+ hi = Math.max(hi, -1);
52544
+ }
52545
+ return ok({ lo, hi });
52546
+ }
52547
+ function asin2(x) {
52548
+ if (x.lo > 1 || x.hi < -1) {
52549
+ return { kind: "empty" };
52550
+ }
52551
+ if (x.lo < -1 || x.hi > 1) {
52552
+ const clippedLo = Math.max(x.lo, -1);
52553
+ const clippedHi = Math.min(x.hi, 1);
52554
+ return {
52555
+ kind: "partial",
52556
+ value: { lo: Math.asin(clippedLo), hi: Math.asin(clippedHi) },
52557
+ domainClipped: x.lo < -1 && x.hi > 1 ? "both" : x.lo < -1 ? "lo" : "hi"
52558
+ };
52559
+ }
52560
+ return ok({ lo: Math.asin(x.lo), hi: Math.asin(x.hi) });
52561
+ }
52562
+ function acos2(x) {
52563
+ if (x.lo > 1 || x.hi < -1) {
52564
+ return { kind: "empty" };
52565
+ }
52566
+ if (x.lo < -1 || x.hi > 1) {
52567
+ const clippedLo = Math.max(x.lo, -1);
52568
+ const clippedHi = Math.min(x.hi, 1);
52569
+ return {
52570
+ kind: "partial",
52571
+ value: { lo: Math.acos(clippedHi), hi: Math.acos(clippedLo) },
52572
+ domainClipped: x.lo < -1 && x.hi > 1 ? "both" : x.lo < -1 ? "lo" : "hi"
52573
+ };
52574
+ }
52575
+ return ok({ lo: Math.acos(x.hi), hi: Math.acos(x.lo) });
52576
+ }
52577
+ function atan3(x) {
52578
+ return ok({ lo: Math.atan(x.lo), hi: Math.atan(x.hi) });
52579
+ }
52580
+ function atan22(y, x) {
52581
+ if (y.lo === y.hi && x.lo === x.hi) {
52582
+ const result = Math.atan2(y.lo, x.lo);
52583
+ return ok({ lo: result, hi: result });
52584
+ }
52585
+ const angles = [];
52586
+ angles.push(Math.atan2(y.lo, x.lo));
52587
+ angles.push(Math.atan2(y.lo, x.hi));
52588
+ angles.push(Math.atan2(y.hi, x.lo));
52589
+ angles.push(Math.atan2(y.hi, x.hi));
52590
+ if (x.lo < 0 && y.lo < 0 && y.hi > 0) {
52591
+ return ok({ lo: -PI2, hi: PI2 });
52592
+ }
52593
+ return ok({ lo: Math.min(...angles), hi: Math.max(...angles) });
52594
+ }
52595
+ function sinh3(x) {
52596
+ return ok({ lo: Math.sinh(x.lo), hi: Math.sinh(x.hi) });
52597
+ }
52598
+ function cosh3(x) {
52599
+ if (x.lo >= 0) {
52600
+ return ok({ lo: Math.cosh(x.lo), hi: Math.cosh(x.hi) });
52601
+ } else if (x.hi <= 0) {
52602
+ return ok({ lo: Math.cosh(x.hi), hi: Math.cosh(x.lo) });
52603
+ } else {
52604
+ return ok({ lo: 1, hi: Math.max(Math.cosh(x.lo), Math.cosh(x.hi)) });
52605
+ }
52606
+ }
52607
+ function tanh2(x) {
52608
+ return ok({ lo: Math.tanh(x.lo), hi: Math.tanh(x.hi) });
52609
+ }
52610
+ function asinh2(x) {
52611
+ return ok({ lo: Math.asinh(x.lo), hi: Math.asinh(x.hi) });
52612
+ }
52613
+ function acosh2(x) {
52614
+ if (x.hi < 1) {
52615
+ return { kind: "empty" };
52616
+ }
52617
+ if (x.lo < 1) {
52618
+ return {
52619
+ kind: "partial",
52620
+ value: { lo: 0, hi: Math.acosh(x.hi) },
52621
+ domainClipped: "lo"
52622
+ };
52623
+ }
52624
+ return ok({ lo: Math.acosh(x.lo), hi: Math.acosh(x.hi) });
52625
+ }
52626
+ function atanh2(x) {
52627
+ if (x.lo >= 1 || x.hi <= -1) {
52628
+ return { kind: "empty" };
52629
+ }
52630
+ if (x.lo <= -1 || x.hi >= 1) {
52631
+ const clippedLo = Math.max(x.lo, -1 + Number.EPSILON);
52632
+ const clippedHi = Math.min(x.hi, 1 - Number.EPSILON);
52633
+ return {
52634
+ kind: "partial",
52635
+ value: { lo: Math.atanh(clippedLo), hi: Math.atanh(clippedHi) },
52636
+ domainClipped: x.lo <= -1 && x.hi >= 1 ? "both" : x.lo <= -1 ? "lo" : "hi"
52637
+ };
52638
+ }
52639
+ return ok({ lo: Math.atanh(x.lo), hi: Math.atanh(x.hi) });
52640
+ }
52641
+
52642
+ // src/compute-engine/interval/comparison.ts
52643
+ function less(a, b) {
52644
+ if (a.hi < b.lo) return "true";
52645
+ if (a.lo >= b.hi) return "false";
52646
+ return "maybe";
52647
+ }
52648
+ function lessEqual(a, b) {
52649
+ if (a.hi <= b.lo) return "true";
52650
+ if (a.lo > b.hi) return "false";
52651
+ return "maybe";
52652
+ }
52653
+ function greater(a, b) {
52654
+ if (a.lo > b.hi) return "true";
52655
+ if (a.hi <= b.lo) return "false";
52656
+ return "maybe";
52657
+ }
52658
+ function greaterEqual(a, b) {
52659
+ if (a.lo >= b.hi) return "true";
52660
+ if (a.hi < b.lo) return "false";
52661
+ return "maybe";
52662
+ }
52663
+ function equal(a, b) {
52664
+ if (a.lo === a.hi && b.lo === b.hi && a.lo === b.lo) return "true";
52665
+ if (a.hi < b.lo || b.hi < a.lo) return "false";
52666
+ return "maybe";
52667
+ }
52668
+ function notEqual(a, b) {
52669
+ const eq2 = equal(a, b);
52670
+ if (eq2 === "true") return "false";
52671
+ if (eq2 === "false") return "true";
52672
+ return "maybe";
52673
+ }
52674
+ function and(a, b) {
52675
+ if (a === "false" || b === "false") return "false";
52676
+ if (a === "true" && b === "true") return "true";
52677
+ return "maybe";
52678
+ }
52679
+ function or(a, b) {
52680
+ if (a === "true" || b === "true") return "true";
52681
+ if (a === "false" && b === "false") return "false";
52682
+ return "maybe";
52683
+ }
52684
+ function not(a) {
52685
+ if (a === "true") return "false";
52686
+ if (a === "false") return "true";
52687
+ return "maybe";
52688
+ }
52689
+ function piecewise(x, condition, trueBranch, falseBranch) {
52690
+ const cond = condition(x);
52691
+ switch (cond) {
52692
+ case "true":
52693
+ return trueBranch(x);
52694
+ case "false":
52695
+ return falseBranch(x);
52696
+ case "maybe":
52697
+ const t = trueBranch(x);
52698
+ const f = falseBranch(x);
52699
+ return unionResults(t, f);
52700
+ }
52701
+ }
52702
+ function clamp2(x, lo, hi) {
52703
+ const resultLo = Math.max(x.lo, lo.lo);
52704
+ const resultHi = Math.min(x.hi, hi.hi);
52705
+ if (resultLo > resultHi) {
52706
+ return { kind: "empty" };
52707
+ }
52708
+ return { kind: "interval", value: { lo: resultLo, hi: resultHi } };
52709
+ }
52710
+
52711
+ // src/compute-engine/interval/index.ts
52712
+ var IntervalArithmetic = {
52713
+ // Utilities
52714
+ ok,
52715
+ point,
52716
+ containsExtremum,
52717
+ unionResults,
52718
+ mergeDomainClip,
52719
+ isPoint,
52720
+ containsZero,
52721
+ isPositive: isPositive2,
52722
+ isNegative,
52723
+ isNonNegative,
52724
+ isNonPositive,
52725
+ width,
52726
+ midpoint,
52727
+ getValue,
52728
+ unwrap,
52729
+ unwrapOrPropagate,
52730
+ // Arithmetic
52731
+ add: add4,
52732
+ sub: sub2,
52733
+ mul: mul4,
52734
+ div: div3,
52735
+ negate: negate2,
52736
+ // Elementary
52737
+ sqrt: sqrt2,
52738
+ square,
52739
+ pow: pow3,
52740
+ powInterval,
52741
+ exp: exp2,
52742
+ ln: ln2,
52743
+ log10: log102,
52744
+ log2: log22,
52745
+ abs: abs2,
52746
+ floor: floor2,
52747
+ ceil: ceil2,
52748
+ round: round2,
52749
+ min: min2,
52750
+ max: max2,
52751
+ mod: mod2,
52752
+ sign: sign2,
52753
+ // Trigonometric
52754
+ sin: sin2,
52755
+ cos: cos2,
52756
+ tan: tan2,
52757
+ cot,
52758
+ sec,
52759
+ csc,
52760
+ asin: asin2,
52761
+ acos: acos2,
52762
+ atan: atan3,
52763
+ atan2: atan22,
52764
+ sinh: sinh3,
52765
+ cosh: cosh3,
52766
+ tanh: tanh2,
52767
+ asinh: asinh2,
52768
+ acosh: acosh2,
52769
+ atanh: atanh2,
52770
+ // Comparison
52771
+ less,
52772
+ lessEqual,
52773
+ greater,
52774
+ greaterEqual,
52775
+ equal,
52776
+ notEqual,
52777
+ and,
52778
+ or,
52779
+ not,
52780
+ piecewise,
52781
+ clamp: clamp2
52782
+ };
52783
+
52784
+ // src/compute-engine/compilation/interval-javascript-target.ts
52785
+ var INTERVAL_JAVASCRIPT_OPERATORS = {
52786
+ // We use high precedence since these become function calls
52787
+ Add: ["_IA.add", 20],
52788
+ Negate: ["_IA.negate", 20],
52789
+ Subtract: ["_IA.sub", 20],
52790
+ Multiply: ["_IA.mul", 20],
52791
+ Divide: ["_IA.div", 20],
52792
+ // Comparisons return BoolInterval
52793
+ Equal: ["_IA.equal", 20],
52794
+ NotEqual: ["_IA.notEqual", 20],
52795
+ LessEqual: ["_IA.lessEqual", 20],
52796
+ GreaterEqual: ["_IA.greaterEqual", 20],
52797
+ Less: ["_IA.less", 20],
52798
+ Greater: ["_IA.greater", 20],
52799
+ And: ["_IA.and", 20],
52800
+ Or: ["_IA.or", 20],
52801
+ Not: ["_IA.not", 20]
52802
+ };
52803
+ var INTERVAL_JAVASCRIPT_FUNCTIONS = {
52804
+ // Basic arithmetic - using function call syntax
52805
+ Add: (args, compile) => {
52806
+ if (args.length === 0) return "_IA.point(0)";
52807
+ if (args.length === 1) return compile(args[0]);
52808
+ let result = compile(args[0]);
52809
+ for (let i = 1; i < args.length; i++) {
52810
+ result = `_IA.add(${result}, ${compile(args[i])})`;
52811
+ }
52812
+ return result;
52813
+ },
52814
+ Subtract: (args, compile) => {
52815
+ if (args.length === 0) return "_IA.point(0)";
52816
+ if (args.length === 1) return `_IA.negate(${compile(args[0])})`;
52817
+ if (args.length === 2)
52818
+ return `_IA.sub(${compile(args[0])}, ${compile(args[1])})`;
52819
+ let result = compile(args[0]);
52820
+ for (let i = 1; i < args.length; i++) {
52821
+ result = `_IA.sub(${result}, ${compile(args[i])})`;
52822
+ }
52823
+ return result;
52824
+ },
52825
+ Multiply: (args, compile) => {
52826
+ if (args.length === 0) return "_IA.point(1)";
52827
+ if (args.length === 1) return compile(args[0]);
52828
+ let result = compile(args[0]);
52829
+ for (let i = 1; i < args.length; i++) {
52830
+ result = `_IA.mul(${result}, ${compile(args[i])})`;
52831
+ }
52832
+ return result;
52833
+ },
52834
+ Divide: (args, compile) => {
52835
+ if (args.length === 0) return "_IA.point(1)";
52836
+ if (args.length === 1) return compile(args[0]);
52837
+ if (args.length === 2)
52838
+ return `_IA.div(${compile(args[0])}, ${compile(args[1])})`;
52839
+ let result = compile(args[0]);
52840
+ for (let i = 1; i < args.length; i++) {
52841
+ result = `_IA.div(${result}, ${compile(args[i])})`;
52842
+ }
52843
+ return result;
52844
+ },
52845
+ Negate: (args, compile) => `_IA.negate(${compile(args[0])})`,
52846
+ // Elementary functions
52847
+ Abs: (args, compile) => `_IA.abs(${compile(args[0])})`,
52848
+ Ceiling: (args, compile) => `_IA.ceil(${compile(args[0])})`,
52849
+ Exp: (args, compile) => `_IA.exp(${compile(args[0])})`,
52850
+ Floor: (args, compile) => `_IA.floor(${compile(args[0])})`,
52851
+ Ln: (args, compile) => `_IA.ln(${compile(args[0])})`,
52852
+ Log: (args, compile) => {
52853
+ if (args.length === 1) return `_IA.log10(${compile(args[0])})`;
52854
+ return `_IA.div(_IA.ln(${compile(args[0])}), _IA.ln(${compile(args[1])}))`;
52855
+ },
52856
+ Lb: (args, compile) => `_IA.log2(${compile(args[0])})`,
52857
+ Max: (args, compile) => {
52858
+ if (args.length === 0) return "_IA.point(-Infinity)";
52859
+ if (args.length === 1) return compile(args[0]);
52860
+ let result = compile(args[0]);
52861
+ for (let i = 1; i < args.length; i++) {
52862
+ result = `_IA.max(${result}, ${compile(args[i])})`;
52863
+ }
52864
+ return result;
52865
+ },
52866
+ Min: (args, compile) => {
52867
+ if (args.length === 0) return "_IA.point(Infinity)";
52868
+ if (args.length === 1) return compile(args[0]);
52869
+ let result = compile(args[0]);
52870
+ for (let i = 1; i < args.length; i++) {
52871
+ result = `_IA.min(${result}, ${compile(args[i])})`;
52872
+ }
52873
+ return result;
52874
+ },
52875
+ Power: (args, compile) => {
52876
+ const base = args[0];
52877
+ const exp3 = args[1];
52878
+ if (base === null) throw new Error("Power: no argument");
52879
+ if (base.symbol === "ExponentialE") {
52880
+ return `_IA.exp(${compile(exp3)})`;
52881
+ }
52882
+ if (exp3?.isNumberLiteral && exp3.im === 0) {
52883
+ const expVal = exp3.re;
52884
+ if (expVal === 0.5) return `_IA.sqrt(${compile(base)})`;
52885
+ if (expVal === 2) return `_IA.square(${compile(base)})`;
52886
+ return `_IA.pow(${compile(base)}, ${expVal})`;
52887
+ }
52888
+ return `_IA.powInterval(${compile(base)}, ${compile(exp3)})`;
52889
+ },
52890
+ Root: (args, compile) => {
52891
+ const [arg, exp3] = args;
52892
+ if (arg === null) throw new Error("Root: no argument");
52893
+ if (exp3 === null) return `_IA.sqrt(${compile(arg)})`;
52894
+ if (exp3?.re === 2) return `_IA.sqrt(${compile(arg)})`;
52895
+ if (exp3?.isNumberLiteral && exp3.im === 0) {
52896
+ return `_IA.pow(${compile(arg)}, ${1 / exp3.re})`;
52897
+ }
52898
+ return `_IA.powInterval(${compile(arg)}, _IA.div(_IA.point(1), ${compile(exp3)}))`;
52899
+ },
52900
+ Round: (args, compile) => `_IA.round(${compile(args[0])})`,
52901
+ Sgn: (args, compile) => `_IA.sign(${compile(args[0])})`,
52902
+ Sqrt: (args, compile) => `_IA.sqrt(${compile(args[0])})`,
52903
+ Square: (args, compile) => `_IA.square(${compile(args[0])})`,
52904
+ // Trigonometric functions
52905
+ Sin: (args, compile) => `_IA.sin(${compile(args[0])})`,
52906
+ Cos: (args, compile) => `_IA.cos(${compile(args[0])})`,
52907
+ Tan: (args, compile) => `_IA.tan(${compile(args[0])})`,
52908
+ Cot: (args, compile) => `_IA.cot(${compile(args[0])})`,
52909
+ Sec: (args, compile) => `_IA.sec(${compile(args[0])})`,
52910
+ Csc: (args, compile) => `_IA.csc(${compile(args[0])})`,
52911
+ Arcsin: (args, compile) => `_IA.asin(${compile(args[0])})`,
52912
+ Arccos: (args, compile) => `_IA.acos(${compile(args[0])})`,
52913
+ Arctan: (args, compile) => `_IA.atan(${compile(args[0])})`,
52914
+ // Hyperbolic functions
52915
+ Sinh: (args, compile) => `_IA.sinh(${compile(args[0])})`,
52916
+ Cosh: (args, compile) => `_IA.cosh(${compile(args[0])})`,
52917
+ Tanh: (args, compile) => `_IA.tanh(${compile(args[0])})`,
52918
+ Arsinh: (args, compile) => `_IA.asinh(${compile(args[0])})`,
52919
+ Arcosh: (args, compile) => `_IA.acosh(${compile(args[0])})`,
52920
+ Artanh: (args, compile) => `_IA.atanh(${compile(args[0])})`,
52921
+ // Inverse trig (alternative names)
52922
+ Asin: (args, compile) => `_IA.asin(${compile(args[0])})`,
52923
+ Acos: (args, compile) => `_IA.acos(${compile(args[0])})`,
52924
+ Atan: (args, compile) => `_IA.atan(${compile(args[0])})`,
52925
+ // Mod
52926
+ Mod: (args, compile) => `_IA.mod(${compile(args[0])}, ${compile(args[1])})`,
52927
+ // Conditionals
52928
+ If: (args, compile) => {
52929
+ if (args.length !== 3) throw new Error("If: wrong number of arguments");
52930
+ return `_IA.piecewise(
52931
+ ${compile(args[0])},
52932
+ (_x) => ${compile(args[0])},
52933
+ (_x) => ${compile(args[1])},
52934
+ (_x) => ${compile(args[2])}
52935
+ )`;
52936
+ }
52937
+ };
52938
+ var ComputeEngineIntervalFunction = class extends Function {
52939
+ IA = IntervalArithmetic;
52940
+ constructor(body, preamble = "") {
52941
+ super(
52942
+ "_IA",
52943
+ "_",
52944
+ preamble ? `${preamble};return ${body}` : `return ${body}`
52945
+ );
52946
+ return new Proxy(this, {
52947
+ apply: (target, thisArg, argumentsList) => {
52948
+ const processedArgs = argumentsList.map(processInput);
52949
+ return super.apply(thisArg, [this.IA, ...processedArgs]);
52950
+ },
52951
+ get: (target, prop) => {
52952
+ if (prop === "toString") return () => body;
52953
+ if (prop === "isCompiled") return true;
52954
+ return target[prop];
52955
+ }
52956
+ });
52957
+ }
52958
+ };
52959
+ function processInput(input) {
52960
+ if (input === null || input === void 0) {
52961
+ return input;
52962
+ }
52963
+ if (typeof input === "object" && "lo" in input && "hi" in input) {
52964
+ return input;
52965
+ }
52966
+ if (typeof input === "object") {
52967
+ const result = {};
52968
+ for (const [key, value] of Object.entries(input)) {
52969
+ result[key] = processInput(value);
52970
+ }
52971
+ return result;
52972
+ }
52973
+ if (typeof input === "number") {
52974
+ return { lo: input, hi: input };
52975
+ }
52976
+ return input;
52977
+ }
52978
+ var IntervalJavaScriptTarget = class {
52979
+ getOperators() {
52980
+ return INTERVAL_JAVASCRIPT_OPERATORS;
52981
+ }
52982
+ getFunctions() {
52983
+ return INTERVAL_JAVASCRIPT_FUNCTIONS;
52984
+ }
52985
+ createTarget(options = {}) {
52986
+ return {
52987
+ language: "interval-javascript",
52988
+ // Don't use operators - all arithmetic goes through functions
52989
+ // because interval arithmetic returns IntervalResult, not numbers
52990
+ operators: () => void 0,
52991
+ functions: (id) => INTERVAL_JAVASCRIPT_FUNCTIONS[id],
52992
+ var: (id) => {
52993
+ const result = {
52994
+ Pi: "_IA.point(Math.PI)",
52995
+ ExponentialE: "_IA.point(Math.E)",
52996
+ NaN: "{ lo: NaN, hi: NaN }",
52997
+ ImaginaryUnit: "{ lo: NaN, hi: NaN }",
52998
+ Half: "_IA.point(0.5)",
52999
+ MachineEpsilon: "_IA.point(Number.EPSILON)",
53000
+ GoldenRatio: "_IA.point((1 + Math.sqrt(5)) / 2)",
53001
+ CatalanConstant: "_IA.point(0.91596559417721901)",
53002
+ EulerGamma: "_IA.point(0.57721566490153286)"
53003
+ };
53004
+ return result[id];
53005
+ },
53006
+ string: (str) => JSON.stringify(str),
53007
+ number: (n) => `_IA.point(${n})`,
53008
+ indent: 0,
53009
+ ws: (s) => s ?? "",
53010
+ preamble: "",
53011
+ ...options
53012
+ };
53013
+ }
53014
+ compileToExecutable(expr, options = {}) {
53015
+ const { functions, vars, preamble } = options;
53016
+ const unknowns = expr.unknowns;
53017
+ const namedFunctions = {};
53018
+ let preambleImports = "";
53019
+ if (functions) {
53020
+ for (const [k, v] of Object.entries(functions)) {
53021
+ if (typeof v === "function") {
53022
+ preambleImports += `const ${k} = ${v.toString()};
53023
+ `;
53024
+ namedFunctions[k] = k;
53025
+ } else if (typeof v === "string") {
53026
+ namedFunctions[k] = v;
53027
+ }
53028
+ }
53029
+ }
53030
+ const target = this.createTarget({
53031
+ functions: (id) => namedFunctions?.[id] ? namedFunctions[id] : INTERVAL_JAVASCRIPT_FUNCTIONS[id],
53032
+ var: (id) => {
53033
+ if (vars && id in vars) return vars[id];
53034
+ const constants = {
53035
+ Pi: "_IA.point(Math.PI)",
53036
+ ExponentialE: "_IA.point(Math.E)",
53037
+ NaN: "{ lo: NaN, hi: NaN }",
53038
+ ImaginaryUnit: "{ lo: NaN, hi: NaN }",
53039
+ Half: "_IA.point(0.5)",
53040
+ MachineEpsilon: "_IA.point(Number.EPSILON)",
53041
+ GoldenRatio: "_IA.point((1 + Math.sqrt(5)) / 2)",
53042
+ CatalanConstant: "_IA.point(0.91596559417721901)",
53043
+ EulerGamma: "_IA.point(0.57721566490153286)"
53044
+ };
53045
+ if (id in constants) return constants[id];
53046
+ if (unknowns.includes(id)) return `_.${id}`;
53047
+ return void 0;
53048
+ },
53049
+ preamble: (preamble ?? "") + preambleImports
53050
+ });
53051
+ return compileToIntervalTarget(expr, target);
53052
+ }
53053
+ };
53054
+ function compileToIntervalTarget(expr, target) {
53055
+ const js = BaseCompiler.compile(expr, target);
53056
+ return new ComputeEngineIntervalFunction(
53057
+ js,
53058
+ target.preamble
53059
+ );
53060
+ }
53061
+
53062
+ // src/compute-engine/compilation/interval-glsl-target.ts
53063
+ init_base_compiler();
53064
+ var GLSL_INTERVAL_LIBRARY = `
53065
+ // Interval Arithmetic Library for GLSL
53066
+ // Intervals are represented as vec2(lo, hi)
53067
+ // Results use IntervalResult struct with status flags
53068
+
53069
+ // Status constants
53070
+ const float IA_NORMAL = 0.0;
53071
+ const float IA_EMPTY = 1.0;
53072
+ const float IA_ENTIRE = 2.0;
53073
+ const float IA_SINGULAR = 3.0;
53074
+ const float IA_PARTIAL_LO = 4.0;
53075
+ const float IA_PARTIAL_HI = 5.0;
53076
+ const float IA_PARTIAL_BOTH = 6.0;
53077
+
53078
+ // Interval result struct
53079
+ struct IntervalResult {
53080
+ vec2 value; // (lo, hi)
53081
+ float status; // Status flag
53082
+ };
53083
+
53084
+ // Epsilon for conservative bounds
53085
+ const float IA_EPS = 1e-6;
53086
+ const float IA_HUGE = 1e38;
53087
+
53088
+ // Create a point interval
53089
+ vec2 ia_point(float x) {
53090
+ return vec2(x, x);
53091
+ }
53092
+
53093
+ // Create interval result
53094
+ IntervalResult ia_ok(vec2 v) {
53095
+ return IntervalResult(v, IA_NORMAL);
53096
+ }
53097
+
53098
+ IntervalResult ia_empty() {
53099
+ return IntervalResult(vec2(0.0), IA_EMPTY);
53100
+ }
53101
+
53102
+ IntervalResult ia_entire() {
53103
+ return IntervalResult(vec2(-IA_HUGE, IA_HUGE), IA_ENTIRE);
53104
+ }
53105
+
53106
+ IntervalResult ia_singular(float at) {
53107
+ return IntervalResult(vec2(at, at), IA_SINGULAR);
53108
+ }
53109
+
53110
+ IntervalResult ia_partial(vec2 v, float clip) {
53111
+ return IntervalResult(v, clip);
53112
+ }
53113
+
53114
+ // Addition
53115
+ IntervalResult ia_add(vec2 a, vec2 b) {
53116
+ return ia_ok(vec2(a.x + b.x - IA_EPS, a.y + b.y + IA_EPS));
53117
+ }
53118
+
53119
+ // Subtraction
53120
+ IntervalResult ia_sub(vec2 a, vec2 b) {
53121
+ return ia_ok(vec2(a.x - b.y - IA_EPS, a.y - b.x + IA_EPS));
53122
+ }
53123
+
53124
+ // Negation
53125
+ IntervalResult ia_negate(vec2 x) {
53126
+ return ia_ok(vec2(-x.y, -x.x));
53127
+ }
53128
+
53129
+ // Multiplication helper (returns vec2)
53130
+ vec2 ia_mul_raw(vec2 a, vec2 b) {
53131
+ float p1 = a.x * b.x;
53132
+ float p2 = a.x * b.y;
53133
+ float p3 = a.y * b.x;
53134
+ float p4 = a.y * b.y;
53135
+ return vec2(
53136
+ min(min(p1, p2), min(p3, p4)) - IA_EPS,
53137
+ max(max(p1, p2), max(p3, p4)) + IA_EPS
53138
+ );
53139
+ }
53140
+
53141
+ // Multiplication
53142
+ IntervalResult ia_mul(vec2 a, vec2 b) {
53143
+ return ia_ok(ia_mul_raw(a, b));
53144
+ }
53145
+
53146
+ // Division
53147
+ IntervalResult ia_div(vec2 a, vec2 b) {
53148
+ // Case 1: Divisor entirely positive or negative
53149
+ if (b.x > 0.0 || b.y < 0.0) {
53150
+ return ia_ok(ia_mul_raw(a, vec2(1.0 / b.y, 1.0 / b.x)));
53151
+ }
53152
+
53153
+ // Case 2: Divisor strictly contains zero
53154
+ if (b.x < 0.0 && b.y > 0.0) {
53155
+ return ia_singular(0.0);
53156
+ }
53157
+
53158
+ // Case 3: Divisor touches zero at lower bound [0, c]
53159
+ if (b.x == 0.0 && b.y > 0.0) {
53160
+ if (a.x >= 0.0) {
53161
+ return ia_partial(vec2(a.x / b.y, IA_HUGE), IA_PARTIAL_HI);
53162
+ } else if (a.y <= 0.0) {
53163
+ return ia_partial(vec2(-IA_HUGE, a.y / b.y), IA_PARTIAL_LO);
53164
+ } else {
53165
+ return ia_entire();
53166
+ }
53167
+ }
53168
+
53169
+ // Case 4: Divisor touches zero at upper bound [c, 0]
53170
+ if (b.y == 0.0 && b.x < 0.0) {
53171
+ if (a.x >= 0.0) {
53172
+ return ia_partial(vec2(-IA_HUGE, a.x / b.x), IA_PARTIAL_LO);
53173
+ } else if (a.y <= 0.0) {
53174
+ return ia_partial(vec2(a.y / b.x, IA_HUGE), IA_PARTIAL_HI);
53175
+ } else {
53176
+ return ia_entire();
53177
+ }
53178
+ }
53179
+
53180
+ // Case 5: Divisor is [0, 0]
53181
+ return ia_empty();
53182
+ }
53183
+
53184
+ // Square root
53185
+ IntervalResult ia_sqrt(vec2 x) {
53186
+ if (x.y < 0.0) {
53187
+ return ia_empty();
53188
+ }
53189
+ if (x.x >= 0.0) {
53190
+ return ia_ok(vec2(sqrt(x.x), sqrt(x.y) + IA_EPS));
53191
+ }
53192
+ return ia_partial(vec2(0.0, sqrt(x.y) + IA_EPS), IA_PARTIAL_LO);
53193
+ }
53194
+
53195
+ // Square
53196
+ IntervalResult ia_square(vec2 x) {
53197
+ if (x.x >= 0.0) {
53198
+ return ia_ok(vec2(x.x * x.x - IA_EPS, x.y * x.y + IA_EPS));
53199
+ } else if (x.y <= 0.0) {
53200
+ return ia_ok(vec2(x.y * x.y - IA_EPS, x.x * x.x + IA_EPS));
53201
+ } else {
53202
+ float m = max(-x.x, x.y);
53203
+ return ia_ok(vec2(0.0, m * m + IA_EPS));
53204
+ }
53205
+ }
53206
+
53207
+ // Exponential
53208
+ IntervalResult ia_exp(vec2 x) {
53209
+ return ia_ok(vec2(exp(x.x) - IA_EPS, exp(x.y) + IA_EPS));
53210
+ }
53211
+
53212
+ // Natural logarithm
53213
+ IntervalResult ia_ln(vec2 x) {
53214
+ if (x.y <= 0.0) {
53215
+ return ia_empty();
53216
+ }
53217
+ if (x.x > 0.0) {
53218
+ return ia_ok(vec2(log(x.x) - IA_EPS, log(x.y) + IA_EPS));
53219
+ }
53220
+ return ia_partial(vec2(-IA_HUGE, log(x.y) + IA_EPS), IA_PARTIAL_LO);
53221
+ }
53222
+
53223
+ // Absolute value
53224
+ IntervalResult ia_abs(vec2 x) {
53225
+ if (x.x >= 0.0) {
53226
+ return ia_ok(x);
53227
+ }
53228
+ if (x.y <= 0.0) {
53229
+ return ia_ok(vec2(-x.y, -x.x));
53230
+ }
53231
+ return ia_ok(vec2(0.0, max(-x.x, x.y)));
53232
+ }
53233
+
53234
+ // Sign function
53235
+ IntervalResult ia_sign(vec2 x) {
53236
+ if (x.x > 0.0) return ia_ok(vec2(1.0, 1.0));
53237
+ if (x.y < 0.0) return ia_ok(vec2(-1.0, -1.0));
53238
+ if (x.x == 0.0 && x.y == 0.0) return ia_ok(vec2(0.0, 0.0));
53239
+ if (x.x < 0.0 && x.y > 0.0) return ia_ok(vec2(-1.0, 1.0));
53240
+ if (x.x == 0.0) return ia_ok(vec2(0.0, 1.0));
53241
+ return ia_ok(vec2(-1.0, 0.0));
53242
+ }
53243
+
53244
+ // Floor
53245
+ IntervalResult ia_floor(vec2 x) {
53246
+ return ia_ok(vec2(floor(x.x), floor(x.y)));
53247
+ }
53248
+
53249
+ // Ceiling
53250
+ IntervalResult ia_ceil(vec2 x) {
53251
+ return ia_ok(vec2(ceil(x.x), ceil(x.y)));
53252
+ }
53253
+
53254
+ // Min of two intervals
53255
+ IntervalResult ia_min(vec2 a, vec2 b) {
53256
+ return ia_ok(vec2(min(a.x, b.x), min(a.y, b.y)));
53257
+ }
53258
+
53259
+ // Max of two intervals
53260
+ IntervalResult ia_max(vec2 a, vec2 b) {
53261
+ return ia_ok(vec2(max(a.x, b.x), max(a.y, b.y)));
53262
+ }
53263
+
53264
+ // Power with constant exponent
53265
+ IntervalResult ia_pow(vec2 base, float exp) {
53266
+ if (exp == 0.0) return ia_ok(vec2(1.0, 1.0));
53267
+ if (exp == 1.0) return ia_ok(base);
53268
+ if (exp == 2.0) return ia_square(base);
53269
+ if (exp == 0.5) return ia_sqrt(base);
53270
+
53271
+ // General case - requires positive base for non-integer exponents
53272
+ if (base.y < 0.0) {
53273
+ return ia_empty();
53274
+ }
53275
+ if (base.x < 0.0) {
53276
+ // Partial domain
53277
+ if (exp > 0.0) {
53278
+ return ia_partial(vec2(0.0, pow(base.y, exp) + IA_EPS), IA_PARTIAL_LO);
53279
+ } else {
53280
+ return ia_partial(vec2(pow(base.y, exp) - IA_EPS, IA_HUGE), IA_PARTIAL_LO);
53281
+ }
53282
+ }
53283
+
53284
+ // Entirely non-negative
53285
+ if (exp > 0.0) {
53286
+ return ia_ok(vec2(pow(base.x, exp) - IA_EPS, pow(base.y, exp) + IA_EPS));
53287
+ } else {
53288
+ if (base.x == 0.0) {
53289
+ return ia_partial(vec2(pow(base.y, exp) - IA_EPS, IA_HUGE), IA_PARTIAL_HI);
53290
+ }
53291
+ return ia_ok(vec2(pow(base.y, exp) - IA_EPS, pow(base.x, exp) + IA_EPS));
53292
+ }
53293
+ }
53294
+
53295
+ // Check if interval contains extremum at (extremum + n * period)
53296
+ bool ia_contains_extremum(vec2 x, float extremum, float period) {
53297
+ float n = ceil((x.x - extremum) / period);
53298
+ float candidate = extremum + n * period;
53299
+ return candidate >= x.x - 1e-7 && candidate <= x.y + 1e-7;
53300
+ }
53301
+
53302
+ // Sine
53303
+ IntervalResult ia_sin(vec2 x) {
53304
+ const float TWO_PI = 6.28318530718;
53305
+ const float HALF_PI = 1.57079632679;
53306
+ const float THREE_HALF_PI = 4.71238898038;
53307
+
53308
+ if (x.y - x.x >= TWO_PI) {
53309
+ return ia_ok(vec2(-1.0, 1.0));
53310
+ }
53311
+
53312
+ float sinLo = sin(x.x);
53313
+ float sinHi = sin(x.y);
53314
+ float lo = min(sinLo, sinHi);
53315
+ float hi = max(sinLo, sinHi);
53316
+
53317
+ if (ia_contains_extremum(x, HALF_PI, TWO_PI)) hi = 1.0;
53318
+ if (ia_contains_extremum(x, THREE_HALF_PI, TWO_PI)) lo = -1.0;
53319
+
53320
+ return ia_ok(vec2(lo - IA_EPS, hi + IA_EPS));
53321
+ }
53322
+
53323
+ // Cosine
53324
+ IntervalResult ia_cos(vec2 x) {
53325
+ const float TWO_PI = 6.28318530718;
53326
+ const float PI = 3.14159265359;
53327
+
53328
+ if (x.y - x.x >= TWO_PI) {
53329
+ return ia_ok(vec2(-1.0, 1.0));
53330
+ }
53331
+
53332
+ float cosLo = cos(x.x);
53333
+ float cosHi = cos(x.y);
53334
+ float lo = min(cosLo, cosHi);
53335
+ float hi = max(cosLo, cosHi);
53336
+
53337
+ if (ia_contains_extremum(x, 0.0, TWO_PI)) hi = 1.0;
53338
+ if (ia_contains_extremum(x, PI, TWO_PI)) lo = -1.0;
53339
+
53340
+ return ia_ok(vec2(lo - IA_EPS, hi + IA_EPS));
53341
+ }
53342
+
53343
+ // Tangent
53344
+ IntervalResult ia_tan(vec2 x) {
53345
+ const float PI = 3.14159265359;
53346
+ const float HALF_PI = 1.57079632679;
53347
+
53348
+ if (x.y - x.x >= PI) {
53349
+ return ia_singular(0.0);
53350
+ }
53351
+
53352
+ if (ia_contains_extremum(x, HALF_PI, PI)) {
53353
+ float n = ceil((x.x - HALF_PI) / PI);
53354
+ float poleAt = HALF_PI + n * PI;
53355
+ return ia_singular(poleAt);
53356
+ }
53357
+
53358
+ float tanLo = tan(x.x);
53359
+ float tanHi = tan(x.y);
53360
+
53361
+ if ((tanLo > 1e10 && tanHi < -1e10) || (tanLo < -1e10 && tanHi > 1e10)) {
53362
+ return ia_singular(0.0);
53363
+ }
53364
+
53365
+ return ia_ok(vec2(tanLo - IA_EPS, tanHi + IA_EPS));
53366
+ }
53367
+
53368
+ // Arc sine
53369
+ IntervalResult ia_asin(vec2 x) {
53370
+ if (x.x > 1.0 || x.y < -1.0) {
53371
+ return ia_empty();
53372
+ }
53373
+
53374
+ vec2 clipped = vec2(max(x.x, -1.0), min(x.y, 1.0));
53375
+
53376
+ if (x.x < -1.0 || x.y > 1.0) {
53377
+ float clip = (x.x < -1.0 && x.y > 1.0) ? IA_PARTIAL_BOTH :
53378
+ (x.x < -1.0) ? IA_PARTIAL_LO : IA_PARTIAL_HI;
53379
+ return ia_partial(vec2(asin(clipped.x) - IA_EPS, asin(clipped.y) + IA_EPS), clip);
53380
+ }
53381
+
53382
+ return ia_ok(vec2(asin(x.x) - IA_EPS, asin(x.y) + IA_EPS));
53383
+ }
53384
+
53385
+ // Arc cosine
53386
+ IntervalResult ia_acos(vec2 x) {
53387
+ if (x.x > 1.0 || x.y < -1.0) {
53388
+ return ia_empty();
53389
+ }
53390
+
53391
+ vec2 clipped = vec2(max(x.x, -1.0), min(x.y, 1.0));
53392
+
53393
+ if (x.x < -1.0 || x.y > 1.0) {
53394
+ float clip = (x.x < -1.0 && x.y > 1.0) ? IA_PARTIAL_BOTH :
53395
+ (x.x < -1.0) ? IA_PARTIAL_LO : IA_PARTIAL_HI;
53396
+ // acos is decreasing, so bounds swap
53397
+ return ia_partial(vec2(acos(clipped.y) - IA_EPS, acos(clipped.x) + IA_EPS), clip);
53398
+ }
53399
+
53400
+ // acos is decreasing
53401
+ return ia_ok(vec2(acos(x.y) - IA_EPS, acos(x.x) + IA_EPS));
53402
+ }
53403
+
53404
+ // Arc tangent
53405
+ IntervalResult ia_atan(vec2 x) {
53406
+ return ia_ok(vec2(atan(x.x) - IA_EPS, atan(x.y) + IA_EPS));
53407
+ }
53408
+
53409
+ // Hyperbolic sine
53410
+ IntervalResult ia_sinh(vec2 x) {
53411
+ return ia_ok(vec2(sinh(x.x) - IA_EPS, sinh(x.y) + IA_EPS));
53412
+ }
53413
+
53414
+ // Hyperbolic cosine
53415
+ IntervalResult ia_cosh(vec2 x) {
53416
+ if (x.x >= 0.0) {
53417
+ return ia_ok(vec2(cosh(x.x) - IA_EPS, cosh(x.y) + IA_EPS));
53418
+ } else if (x.y <= 0.0) {
53419
+ return ia_ok(vec2(cosh(x.y) - IA_EPS, cosh(x.x) + IA_EPS));
53420
+ } else {
53421
+ return ia_ok(vec2(1.0 - IA_EPS, max(cosh(x.x), cosh(x.y)) + IA_EPS));
53422
+ }
53423
+ }
53424
+
53425
+ // Hyperbolic tangent
53426
+ IntervalResult ia_tanh(vec2 x) {
53427
+ return ia_ok(vec2(tanh(x.x) - IA_EPS, tanh(x.y) + IA_EPS));
53428
+ }
53429
+ `;
53430
+ var INTERVAL_GLSL_OPERATORS = {
53431
+ Add: ["ia_add", 20],
53432
+ Negate: ["ia_negate", 20],
53433
+ Subtract: ["ia_sub", 20],
53434
+ Multiply: ["ia_mul", 20],
53435
+ Divide: ["ia_div", 20]
53436
+ };
53437
+ var INTERVAL_GLSL_FUNCTIONS = {
53438
+ Add: (args, compile) => {
53439
+ if (args.length === 0) return "ia_point(0.0)";
53440
+ if (args.length === 1) return compile(args[0]);
53441
+ let result = compile(args[0]);
53442
+ for (let i = 1; i < args.length; i++) {
53443
+ result = `ia_add(${result}, ${compile(args[i])})`;
53444
+ }
53445
+ return result;
53446
+ },
53447
+ Subtract: (args, compile) => {
53448
+ if (args.length === 0) return "ia_point(0.0)";
53449
+ if (args.length === 1) return `ia_negate(${compile(args[0])})`;
53450
+ let result = compile(args[0]);
53451
+ for (let i = 1; i < args.length; i++) {
53452
+ result = `ia_sub(${result}, ${compile(args[i])})`;
53453
+ }
53454
+ return result;
53455
+ },
53456
+ Multiply: (args, compile) => {
53457
+ if (args.length === 0) return "ia_point(1.0)";
53458
+ if (args.length === 1) return compile(args[0]);
53459
+ let result = compile(args[0]);
53460
+ for (let i = 1; i < args.length; i++) {
53461
+ result = `ia_mul(${result}, ${compile(args[i])})`;
53462
+ }
53463
+ return result;
53464
+ },
53465
+ Divide: (args, compile) => {
53466
+ if (args.length === 0) return "ia_point(1.0)";
53467
+ if (args.length === 1) return compile(args[0]);
53468
+ let result = compile(args[0]);
53469
+ for (let i = 1; i < args.length; i++) {
53470
+ result = `ia_div(${result}, ${compile(args[i])})`;
53471
+ }
53472
+ return result;
53473
+ },
53474
+ Negate: (args, compile) => `ia_negate(${compile(args[0])})`,
53475
+ // Elementary functions
53476
+ Abs: (args, compile) => `ia_abs(${compile(args[0])})`,
53477
+ Ceiling: (args, compile) => `ia_ceil(${compile(args[0])})`,
53478
+ Exp: (args, compile) => `ia_exp(${compile(args[0])})`,
53479
+ Floor: (args, compile) => `ia_floor(${compile(args[0])})`,
53480
+ Ln: (args, compile) => `ia_ln(${compile(args[0])})`,
53481
+ Max: (args, compile) => {
53482
+ if (args.length === 0) return "ia_point(-1e38)";
53483
+ if (args.length === 1) return compile(args[0]);
53484
+ let result = compile(args[0]);
53485
+ for (let i = 1; i < args.length; i++) {
53486
+ result = `ia_max(${result}, ${compile(args[i])})`;
53487
+ }
53488
+ return result;
53489
+ },
53490
+ Min: (args, compile) => {
53491
+ if (args.length === 0) return "ia_point(1e38)";
53492
+ if (args.length === 1) return compile(args[0]);
53493
+ let result = compile(args[0]);
53494
+ for (let i = 1; i < args.length; i++) {
53495
+ result = `ia_min(${result}, ${compile(args[i])})`;
53496
+ }
53497
+ return result;
53498
+ },
53499
+ Power: (args, compile) => {
53500
+ const base = args[0];
53501
+ const exp3 = args[1];
53502
+ if (base === null) throw new Error("Power: no argument");
53503
+ if (base.symbol === "ExponentialE") {
53504
+ return `ia_exp(${compile(exp3)})`;
53505
+ }
53506
+ if (exp3?.isNumberLiteral && exp3.im === 0) {
53507
+ const expVal = exp3.re;
53508
+ if (expVal === 2) return `ia_square(${compile(base)})`;
53509
+ return `ia_pow(${compile(base)}, ${expVal})`;
53510
+ }
53511
+ throw new Error("Interval GLSL does not support variable exponents");
53512
+ },
53513
+ Sgn: (args, compile) => `ia_sign(${compile(args[0])})`,
53514
+ Sqrt: (args, compile) => `ia_sqrt(${compile(args[0])})`,
53515
+ Square: (args, compile) => `ia_square(${compile(args[0])})`,
53516
+ // Trigonometric functions
53517
+ Sin: (args, compile) => `ia_sin(${compile(args[0])})`,
53518
+ Cos: (args, compile) => `ia_cos(${compile(args[0])})`,
53519
+ Tan: (args, compile) => `ia_tan(${compile(args[0])})`,
53520
+ Arcsin: (args, compile) => `ia_asin(${compile(args[0])})`,
53521
+ Arccos: (args, compile) => `ia_acos(${compile(args[0])})`,
53522
+ Arctan: (args, compile) => `ia_atan(${compile(args[0])})`,
53523
+ // Hyperbolic functions
53524
+ Sinh: (args, compile) => `ia_sinh(${compile(args[0])})`,
53525
+ Cosh: (args, compile) => `ia_cosh(${compile(args[0])})`,
53526
+ Tanh: (args, compile) => `ia_tanh(${compile(args[0])})`
53527
+ };
53528
+ var IntervalGLSLTarget = class {
53529
+ getOperators() {
53530
+ return INTERVAL_GLSL_OPERATORS;
53531
+ }
53532
+ getFunctions() {
53533
+ return INTERVAL_GLSL_FUNCTIONS;
53534
+ }
53535
+ /**
53536
+ * Get the GLSL interval library code.
53537
+ *
53538
+ * This should be included in shaders that use interval arithmetic.
53539
+ */
53540
+ getLibrary() {
53541
+ return GLSL_INTERVAL_LIBRARY;
53542
+ }
53543
+ createTarget(options = {}) {
53544
+ return {
53545
+ language: "interval-glsl",
53546
+ // Don't use operators - all arithmetic goes through functions
53547
+ // because interval arithmetic returns IntervalResult, not numbers
53548
+ operators: () => void 0,
53549
+ functions: (id) => INTERVAL_GLSL_FUNCTIONS[id],
53550
+ var: (id) => {
53551
+ const constants = {
53552
+ Pi: "ia_point(3.14159265359)",
53553
+ ExponentialE: "ia_point(2.71828182846)",
53554
+ GoldenRatio: "ia_point(1.61803398875)",
53555
+ CatalanConstant: "ia_point(0.91596559417)",
53556
+ EulerGamma: "ia_point(0.57721566490)"
53557
+ };
53558
+ if (id in constants) return constants[id];
53559
+ return id;
53560
+ },
53561
+ string: (str) => JSON.stringify(str),
53562
+ number: (n) => {
53563
+ const str = n.toString();
53564
+ const numStr = !str.includes(".") && !str.includes("e") && !str.includes("E") ? `${str}.0` : str;
53565
+ return `ia_point(${numStr})`;
53566
+ },
53567
+ indent: 0,
53568
+ ws: (s) => s ?? "",
53569
+ preamble: "",
53570
+ ...options
53571
+ };
53572
+ }
53573
+ compileToExecutable(expr, options = {}) {
53574
+ const { functions, vars } = options;
53575
+ const target = this.createTarget({
53576
+ functions: (id) => {
53577
+ if (functions && id in functions) {
53578
+ const fn = functions[id];
53579
+ if (typeof fn === "string") return fn;
53580
+ if (typeof fn === "function") return fn.name || id;
53581
+ }
53582
+ return INTERVAL_GLSL_FUNCTIONS[id];
53583
+ },
53584
+ var: (id) => {
53585
+ if (vars && id in vars) return vars[id];
53586
+ const constants = {
53587
+ Pi: "ia_point(3.14159265359)",
53588
+ ExponentialE: "ia_point(2.71828182846)",
53589
+ GoldenRatio: "ia_point(1.61803398875)",
53590
+ CatalanConstant: "ia_point(0.91596559417)",
53591
+ EulerGamma: "ia_point(0.57721566490)"
53592
+ };
53593
+ if (id in constants) return constants[id];
53594
+ return id;
53595
+ }
53596
+ });
53597
+ const glslCode = BaseCompiler.compile(expr, target);
53598
+ const result = function() {
53599
+ return glslCode;
53600
+ };
53601
+ Object.defineProperty(result, "toString", {
53602
+ value: () => glslCode
53603
+ });
53604
+ Object.defineProperty(result, "isCompiled", {
53605
+ value: true
53606
+ });
53607
+ return result;
53608
+ }
53609
+ /**
53610
+ * Compile an expression to GLSL interval code.
53611
+ */
53612
+ compile(expr, options = {}) {
53613
+ const target = this.createTarget();
53614
+ return BaseCompiler.compile(expr, target);
53615
+ }
53616
+ /**
53617
+ * Create a complete GLSL interval function from an expression.
53618
+ *
53619
+ * @param expr - The expression to compile
53620
+ * @param functionName - Name of the GLSL function
53621
+ * @param parameters - Parameter names (each becomes a vec2 interval input)
53622
+ */
53623
+ compileFunction(expr, functionName, parameters) {
53624
+ const target = this.createTarget();
53625
+ const body = BaseCompiler.compile(expr, target);
53626
+ const params = parameters.map((name) => `vec2 ${name}`).join(", ");
53627
+ return `IntervalResult ${functionName}(${params}) {
53628
+ return ${body};
53629
+ }`;
53630
+ }
53631
+ /**
53632
+ * Create a complete GLSL fragment shader for interval function plotting.
53633
+ *
53634
+ * @param expr - The expression to compile
53635
+ * @param options - Shader options
53636
+ */
53637
+ compileShaderFunction(expr, options = {}) {
53638
+ const {
53639
+ functionName = "evaluateInterval",
53640
+ version: version2 = "300 es",
53641
+ parameters = ["x"]
53642
+ } = options;
53643
+ const target = this.createTarget();
53644
+ const body = BaseCompiler.compile(expr, target);
53645
+ const params = parameters.map((name) => `vec2 ${name}`).join(", ");
53646
+ return `#version ${version2}
53647
+ precision highp float;
53648
+
53649
+ ${GLSL_INTERVAL_LIBRARY}
53650
+
53651
+ IntervalResult ${functionName}(${params}) {
53652
+ return ${body};
53653
+ }
53654
+ `;
53655
+ }
53656
+ };
53657
+
52021
53658
  // src/compute-engine/index.ts
52022
53659
  init_base_compiler();
52023
53660
  var ComputeEngine = class _ComputeEngine {
@@ -52323,6 +53960,11 @@ Error in definition of "${name}"`,
52323
53960
  this.pushScope(void 0, "global");
52324
53961
  this._compilationTargets.set("javascript", new JavaScriptTarget());
52325
53962
  this._compilationTargets.set("glsl", new GLSLTarget());
53963
+ this._compilationTargets.set(
53964
+ "interval-js",
53965
+ new IntervalJavaScriptTarget()
53966
+ );
53967
+ this._compilationTargets.set("interval-glsl", new IntervalGLSLTarget());
52326
53968
  hidePrivateProperties(this);
52327
53969
  }
52328
53970
  toJSON() {
@@ -53780,10 +55422,10 @@ Error in definition of "${name}"`,
53780
55422
  // src/compute-engine.ts
53781
55423
  init_types6();
53782
55424
  init_base_compiler();
53783
- var version = "0.34.0";
55425
+ var version = "0.35.0";
53784
55426
  globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
53785
55427
  ComputeEngine: ComputeEngine.prototype.constructor,
53786
- version: "0.34.0"
55428
+ version: "0.35.0"
53787
55429
  };
53788
55430
  return __toCommonJS(compute_engine_exports);
53789
55431
  })();