@cortex-js/compute-engine 0.12.4 → 0.12.5

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 (89) hide show
  1. package/dist/compute-engine.esm.js +94 -60
  2. package/dist/compute-engine.js +94 -60
  3. package/dist/compute-engine.min.esm.js +94 -60
  4. package/dist/compute-engine.min.js +94 -60
  5. package/dist/math-json.esm.js +2 -2
  6. package/dist/math-json.js +2 -2
  7. package/dist/math-json.min.esm.js +2 -2
  8. package/dist/math-json.min.js +2 -2
  9. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  10. package/dist/types/common/signals.d.ts +1 -1
  11. package/dist/types/common/utils.d.ts +1 -1
  12. package/dist/types/compute-engine/assume.d.ts +1 -1
  13. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  14. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  15. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  16. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
  17. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
  18. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +2 -2
  19. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  20. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  21. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  22. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
  23. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  25. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  26. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  27. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  28. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  29. package/dist/types/compute-engine/compute-engine.d.ts +4 -2
  30. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  31. package/dist/types/compute-engine/domain-utils.d.ts +1 -1
  32. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  33. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  34. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  35. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  36. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  37. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  38. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  39. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  40. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  41. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  42. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  43. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/parse.d.ts +4 -2
  46. package/dist/types/compute-engine/latex-syntax/public.d.ts +2 -2
  47. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  51. package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
  52. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
  53. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
  54. package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
  55. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  56. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  57. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  58. package/dist/types/compute-engine/library/core.d.ts +1 -1
  59. package/dist/types/compute-engine/library/domains.d.ts +1 -1
  60. package/dist/types/compute-engine/library/library.d.ts +1 -1
  61. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  62. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  63. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  64. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  65. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  66. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  67. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  68. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  69. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  70. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  71. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  72. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  73. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  74. package/dist/types/compute-engine/public.d.ts +5 -3
  75. package/dist/types/compute-engine/rules.d.ts +1 -1
  76. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  77. package/dist/types/compute-engine/solve.d.ts +1 -1
  78. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  79. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  80. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  81. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  82. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  83. package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
  84. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  85. package/dist/types/compute-engine.d.ts +2 -2
  86. package/dist/types/math-json/math-json-format.d.ts +1 -1
  87. package/dist/types/math-json/utils.d.ts +1 -1
  88. package/dist/types/math-json.d.ts +2 -2
  89. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /** CortexJS Compute Engine 0.12.4 */
1
+ /** CortexJS Compute Engine 0.12.5 */
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -4587,6 +4587,15 @@ var DEFINITIONS_ARITHMETIC = [
4587
4587
  parse: "ExponentialE",
4588
4588
  serialize: "\\exponentialE"
4589
4589
  },
4590
+ {
4591
+ kind: "function",
4592
+ trigger: "exp",
4593
+ parse: (parser) => ["Exp", ...parser.matchArguments("enclosure") ?? []]
4594
+ },
4595
+ {
4596
+ trigger: "\\exp",
4597
+ parse: (parser) => ["Exp", ...parser.matchArguments("enclosure") ?? []]
4598
+ },
4590
4599
  {
4591
4600
  name: "ImaginaryUnit",
4592
4601
  trigger: ["\\imaginaryI"]
@@ -4710,11 +4719,12 @@ var DEFINITIONS_ARITHMETIC = [
4710
4719
  },
4711
4720
  {
4712
4721
  name: "Exp",
4713
- serialize: (serializer, expr) => joinLatex([
4714
- "\\exponentialE^{",
4715
- serializer.serialize(missingIfEmpty(op(expr, 1))),
4716
- "}"
4717
- ])
4722
+ serialize: (serializer, expr) => {
4723
+ const op12 = op(expr, 1);
4724
+ if (symbol(op12) || machineValue(op12) !== null)
4725
+ return joinLatex(["\\exponentialE^{", serializer.serialize(op12)]);
4726
+ return joinLatex(["\\exp", serializer.wrap(missingIfEmpty(op12))]);
4727
+ }
4718
4728
  },
4719
4729
  {
4720
4730
  name: "Factorial",
@@ -4891,7 +4901,31 @@ var DEFINITIONS_ARITHMETIC = [
4891
4901
  trigger: ["\\pm"],
4892
4902
  kind: "infix",
4893
4903
  associativity: "both",
4894
- precedence: 270
4904
+ precedence: 270,
4905
+ serialize: (serializer, expr) => {
4906
+ const op12 = op(expr, 1);
4907
+ if (op12 === null)
4908
+ return "\\pm";
4909
+ if (nops(expr) === 1)
4910
+ return joinLatex(["\\pm", serializer.serialize(op12)]);
4911
+ const op22 = op(expr, 2);
4912
+ return joinLatex([
4913
+ serializer.serialize(op12),
4914
+ "\\pm",
4915
+ serializer.serialize(op22)
4916
+ ]);
4917
+ }
4918
+ },
4919
+ {
4920
+ trigger: ["\\pm"],
4921
+ kind: "prefix",
4922
+ precedence: 270,
4923
+ parse: (parser, terminator) => {
4924
+ if (270 < terminator.minPrec)
4925
+ return null;
4926
+ const rhs = parser.matchExpression({ ...terminator, minPrec: 400 });
4927
+ return ["PlusMinus", missingIfEmpty(rhs)];
4928
+ }
4895
4929
  },
4896
4930
  {
4897
4931
  name: "Power",
@@ -5620,7 +5654,7 @@ var DEFINITIONS_INEQUALITIES = [
5620
5654
  kind: "infix",
5621
5655
  associativity: "right",
5622
5656
  precedence: 241,
5623
- parse: "Equal"
5657
+ parse: "LessEqual"
5624
5658
  },
5625
5659
  {
5626
5660
  trigger: ["\\leqslant"],
@@ -7404,7 +7438,7 @@ function indexLatexDictionary(dic, onError) {
7404
7438
  message: [
7405
7439
  "invalid-dictionary-entry",
7406
7440
  indexedEntry.name,
7407
- "Duplicate definition"
7441
+ "Duplicate definition. The name must be unique, but a trigger can be used by multiple definitions."
7408
7442
  ]
7409
7443
  });
7410
7444
  }
@@ -8701,6 +8735,8 @@ var _Parser = class {
8701
8735
  * - 'enclosure' : will look for an argument inside an enclosure (open/close fence)
8702
8736
  * - 'implicit': either an expression inside a pair of `()`, or just a product
8703
8737
  * (i.e. we interpret `\cos 2x + 1` as `\cos(2x) + 1`)
8738
+ *
8739
+ * This returns an array of arguments, or null if there is no match.
8704
8740
  */
8705
8741
  matchArguments(kind, until) {
8706
8742
  if (!kind)
@@ -8709,23 +8745,15 @@ var _Parser = class {
8709
8745
  return null;
8710
8746
  const savedIndex = this.index;
8711
8747
  const group = this.matchEnclosure();
8712
- if (kind === "enclosure" && head(group) === "Delimiter") {
8713
- if (op(group, 1) === "Sequence")
8714
- return ops(op(group, 1)) ?? [];
8715
- return [op(group, 1) ?? ["Sequence"]];
8716
- }
8748
+ if (kind === "enclosure")
8749
+ return getSequence(group) ?? [];
8717
8750
  if (kind === "implicit") {
8718
- if (head(group) === "Delimiter") {
8719
- if (head(op(group, 1)) === "Sequence")
8720
- return getSequence(group) ?? [];
8721
- return [op(group, 1) ?? ["Sequence"]];
8722
- }
8751
+ if (head(group) === "Delimiter")
8752
+ return getSequence(group) ?? [];
8723
8753
  if (group !== null)
8724
8754
  return [group];
8725
8755
  const primary = this.matchExpression({ ...until, minPrec: 390 });
8726
- if (primary !== null)
8727
- return [primary];
8728
- return null;
8756
+ return primary === null ? null : [primary];
8729
8757
  }
8730
8758
  this.index = savedIndex;
8731
8759
  return null;
@@ -8745,7 +8773,7 @@ var _Parser = class {
8745
8773
  fn = pf;
8746
8774
  } while (true);
8747
8775
  const seq = this.matchArguments("enclosure");
8748
- return seq ? [fn, ...seq] : id;
8776
+ return seq ? [fn, ...seq] : fn;
8749
8777
  }
8750
8778
  /** A prime suffix is a sequence of `'`, `\prime` or `\doubleprime`
8751
8779
  * after a function or in a superscript.
@@ -9154,7 +9182,7 @@ var _Parser = class {
9154
9182
  this.index = index;
9155
9183
  return result;
9156
9184
  }
9157
- matchPostfix(lhs) {
9185
+ matchPostfix(lhs, until) {
9158
9186
  /* @__PURE__ */ console.assert(lhs !== null);
9159
9187
  if (lhs === null)
9160
9188
  return null;
@@ -9164,7 +9192,7 @@ var _Parser = class {
9164
9192
  const start = this.index;
9165
9193
  for (const [def, n] of defs) {
9166
9194
  this.index = start + n;
9167
- const result = def.parse(this, lhs);
9195
+ const result = def.parse(this, lhs, until);
9168
9196
  if (result !== null)
9169
9197
  return result;
9170
9198
  }
@@ -9510,7 +9538,7 @@ var _Parser = class {
9510
9538
  let postfix = null;
9511
9539
  let index = this.index;
9512
9540
  do {
9513
- postfix = this.matchPostfix(result);
9541
+ postfix = this.matchPostfix(result, until);
9514
9542
  result = postfix ?? result;
9515
9543
  if (this.index === index && postfix !== null) {
9516
9544
  /* @__PURE__ */ console.assert(this.index !== index, "No token consumed");
@@ -15370,7 +15398,7 @@ function expandMultinomial(expr) {
15370
15398
  const ce = expr.engine;
15371
15399
  if (expr.op1.head === "Negate") {
15372
15400
  const sign2 = exp2 % 2 === 0 ? 1 : -1;
15373
- const result2 = expandMultinomial(ce.box(["Power", expr.op1.op1, expr.op2]));
15401
+ const result2 = expandMultinomial(ce.pow(expr.op1.op1, expr.op2));
15374
15402
  if (result2 === null)
15375
15403
  return null;
15376
15404
  if (sign2 > 0)
@@ -15595,15 +15623,14 @@ function assumeEquality(proposition) {
15595
15623
  const sols = findUnivariateRoots(proposition, lhs2);
15596
15624
  if (sols.length === 0) {
15597
15625
  ce.assumptions.set(
15598
- ce.box([
15599
- "Equal",
15626
+ ce.fn("Equal", [
15600
15627
  ce.add([proposition.op1.canonical, ce.neg(proposition.op2.canonical)]).simplify(),
15601
15628
  0
15602
15629
  ]),
15603
15630
  true
15604
15631
  );
15605
15632
  }
15606
- const val = sols.length === 1 ? sols[0] : ce.box(["List", ...sols]);
15633
+ const val = sols.length === 1 ? sols[0] : ce.fn("List", sols);
15607
15634
  const def = ce.lookupSymbol(lhs2);
15608
15635
  if (!def) {
15609
15636
  ce.defineSymbol(lhs2, { value: val });
@@ -16584,7 +16611,6 @@ var BoxedFunction = class _BoxedFunction extends AbstractBoxedExpression {
16584
16611
  return result;
16585
16612
  }
16586
16613
  solve(vars) {
16587
- /* @__PURE__ */ console.log("solve this:", this.toString());
16588
16614
  if (vars.length !== 1)
16589
16615
  return null;
16590
16616
  const roots = findUnivariateRoots(this.simplify(), vars[0]);
@@ -16663,6 +16689,8 @@ function makeCanonicalFunction(ce, head2, ops2, metadata) {
16663
16689
  xs.push(y);
16664
16690
  }
16665
16691
  }
16692
+ if (!xs.every((x) => x.isValid))
16693
+ return new BoxedFunction(ce, head2, xs, { metadata, canonical: false });
16666
16694
  const sig = def.signature;
16667
16695
  if (sig.canonical) {
16668
16696
  try {
@@ -16693,21 +16721,22 @@ function makeCanonicalFunction(ce, head2, ops2, metadata) {
16693
16721
  return new BoxedFunction(ce, head2, xs, { metadata, def, canonical: true });
16694
16722
  }
16695
16723
  function apply(fn, args) {
16724
+ const ce = fn.engine;
16696
16725
  if (fn.head !== "Lambda")
16697
- return fn.engine._fn(fn.evaluate(), args);
16726
+ return ce._fn(fn.evaluate(), args);
16698
16727
  const subs2 = {
16699
- "__": fn.engine.tuple(args),
16700
- "_#": fn.engine.number(args.length)
16728
+ "__": ce.tuple(args),
16729
+ "_#": ce.number(args.length)
16701
16730
  };
16702
16731
  let n = 1;
16703
16732
  for (const op3 of args)
16704
16733
  subs2[`_${n++}`] = op3;
16705
16734
  subs2["_"] = subs2["_1"];
16706
- const savedContext = this.context;
16707
- this.context = fn.scope ?? null;
16708
- const result = fn.subs(subs2).evaluate();
16709
- this.context = savedContext;
16710
- return result;
16735
+ const savedContext = ce.context;
16736
+ ce.context = fn.scope ?? null;
16737
+ const result = fn.subs(subs2);
16738
+ ce.context = savedContext;
16739
+ return result.op1.evaluate();
16711
16740
  }
16712
16741
  function holdMap(xs, skip, associativeHead, f) {
16713
16742
  if (xs.length === 0)
@@ -18820,7 +18849,7 @@ var ARITHMETIC_LIBRARY = [
18820
18849
  return ce._NEGATIVE_INFINITY;
18821
18850
  if (ops2.length === 1)
18822
18851
  return ops2[0];
18823
- return ce.box(["Max", ...ops2]);
18852
+ return ce.fn("Max", ops2);
18824
18853
  },
18825
18854
  evaluate: (ce, ops2) => {
18826
18855
  if (ops2.length === 0)
@@ -18849,7 +18878,7 @@ var ARITHMETIC_LIBRARY = [
18849
18878
  return ce._NEGATIVE_INFINITY;
18850
18879
  if (ops2.length === 1)
18851
18880
  return ops2[0];
18852
- return ce.box(["Min", ...ops2]);
18881
+ return ce.fn("Min", ops2);
18853
18882
  },
18854
18883
  evaluate: (ce, ops2) => {
18855
18884
  if (ops2.length === 0)
@@ -19190,7 +19219,7 @@ var ARITHMETIC_LIBRARY = [
19190
19219
  e: {
19191
19220
  domain: "TranscendentalNumber",
19192
19221
  constant: true,
19193
- holdUntil: "never",
19222
+ holdUntil: "N",
19194
19223
  value: "ExponentialE"
19195
19224
  },
19196
19225
  i: {
@@ -19216,14 +19245,13 @@ var ARITHMETIC_LIBRARY = [
19216
19245
  },
19217
19246
  Half: {
19218
19247
  constant: true,
19219
- holdUntil: "never",
19248
+ holdUntil: "evaluate",
19220
19249
  value: ["Rational", 1, 2]
19221
19250
  },
19222
19251
  ImaginaryUnit: {
19223
19252
  domain: "ImaginaryNumber",
19224
19253
  constant: true,
19225
- holdUntil: "evaluate",
19226
- // @todo maybe?
19254
+ holdUntil: "never",
19227
19255
  wikidata: "Q193796",
19228
19256
  flags: { imaginary: true },
19229
19257
  value: ["Complex", 0, 1]
@@ -20051,8 +20079,7 @@ var CORE_LIBRARY = [
20051
20079
  signature: {
20052
20080
  domain: ["Function", ["Maybe", ["Sequence", "Anything"]], "String"],
20053
20081
  evaluate: (ce, ops2) => {
20054
- return ce.box([
20055
- "Latex",
20082
+ return ce.fn("Latex", [
20056
20083
  ce.string(tokensToString(ops2.map((x) => x.string ?? x.latex)))
20057
20084
  ]);
20058
20085
  }
@@ -20075,7 +20102,7 @@ var CORE_LIBRARY = [
20075
20102
  hold: "all",
20076
20103
  signature: {
20077
20104
  domain: ["Function", ["Maybe", ["Sequence", "Anything"]], "String"],
20078
- evaluate: (ce, ops2) => ce.box(["Latex", ce.string(joinLatex(ops2.map((x) => x.latex)))])
20105
+ evaluate: (ce, ops2) => ce.fn("Latex", [ce.string(joinLatex(ops2.map((x) => x.latex)))])
20079
20106
  }
20080
20107
  },
20081
20108
  SplitAsLatexTokens: {
@@ -20912,13 +20939,13 @@ var TRIGONOMETRY_LIBRARY = [
20912
20939
  "Number"
20913
20940
  ]);
20914
20941
  if (ops2.length !== 1)
20915
- return ce.box(["Degrees", ops2]);
20942
+ return ce.fn("Degrees", ops2, { canonical: false });
20916
20943
  const arg = ops2[0];
20917
20944
  if (arg.numericValue === null || !arg.isValid)
20918
- return ce.box(["Degrees", arg]);
20945
+ return ce.fn("Degrees", ops2, { canonical: false });
20919
20946
  return ce.div(ce.mul([arg, ce.symbol("Pi")]), ce.number(180));
20920
20947
  },
20921
- evaluate: (ce, ops2) => ce.mul([ops2[0], ce.box(["Divide", "Pi", 180])])
20948
+ evaluate: (ce, ops2) => ce.mul([ops2[0], ce.div(ce.symbol("Pi"), ce.number(180))])
20922
20949
  }
20923
20950
  },
20924
20951
  Hypot: {
@@ -21438,6 +21465,8 @@ var TRIG_IDENTITIES = {
21438
21465
  ]
21439
21466
  };
21440
21467
  function constructibleValues(ce, head2, x) {
21468
+ if (!x)
21469
+ return void 0;
21441
21470
  const specialValues = ce.cache(
21442
21471
  "constructible-trigonometric-values",
21443
21472
  () => {
@@ -21514,6 +21543,8 @@ function processInverseFunction(ce, xs) {
21514
21543
  return newHead ? ce.symbol(newHead) : void 0;
21515
21544
  }
21516
21545
  function evalTrig(ce, mode, head2, op3) {
21546
+ if (!op3)
21547
+ return void 0;
21517
21548
  if (mode === "evaluate") {
21518
21549
  const result = constructibleValues(ce, head2, op3)?.evaluate();
21519
21550
  if (result)
@@ -21711,7 +21742,7 @@ var BoxedSymbolDefinitionImpl = class {
21711
21742
  this._flags = def.flags ? normalizeFlags(def.flags) : void 0;
21712
21743
  this._domain = def.domain ? ce.domain(def.domain) : void 0;
21713
21744
  this.constant = def.constant ?? false;
21714
- this.holdUntil = def.holdUntil ?? "simplify";
21745
+ this.holdUntil = def.holdUntil ?? "evaluate";
21715
21746
  if (this.constant) {
21716
21747
  this._defValue = def.value;
21717
21748
  this._value = null;
@@ -23367,17 +23398,20 @@ var BoxedSymbol = class _BoxedSymbol extends AbstractBoxedExpression {
23367
23398
  }
23368
23399
  simplify(options) {
23369
23400
  const def = this.symbolDefinition;
23370
- if ((def?.holdUntil === "never" || def?.holdUntil === "simplify") && def.value)
23401
+ if (def?.holdUntil === "simplify" && def.value)
23371
23402
  return def.value.simplify(options);
23372
23403
  return options?.rules ? this.replace(options.rules) ?? this : this;
23373
23404
  }
23374
23405
  evaluate(options) {
23375
23406
  const def = this.symbolDefinition;
23376
- if (def?.holdUntil !== "N")
23377
- return def?.value?.evaluate(options) ?? this;
23407
+ if (def && (def.holdUntil === "simplify" || def.holdUntil === "evaluate"))
23408
+ return def.value?.evaluate(options) ?? this;
23378
23409
  return this;
23379
23410
  }
23380
23411
  N(options) {
23412
+ const def = this.symbolDefinition;
23413
+ if (def && def.holdUntil === "never")
23414
+ return this;
23381
23415
  return this.symbolDefinition?.value?.N(options) ?? this;
23382
23416
  }
23383
23417
  replace(rules, options) {
@@ -23790,7 +23824,7 @@ var ComputeEngine = class _ComputeEngine {
23790
23824
  precision: this.precision,
23791
23825
  avoidExponentsInRange: [-6, this.precision],
23792
23826
  onError: (err) => {
23793
- throw new Error(err[0].message.toString());
23827
+ throw new Error(JSON.stringify(err[0].message));
23794
23828
  }
23795
23829
  });
23796
23830
  return this._latexSyntax;
@@ -24054,8 +24088,8 @@ var ComputeEngine = class _ComputeEngine {
24054
24088
  const bxs = xs;
24055
24089
  return bxs.every((x) => x.isCanonical) ? bxs : bxs.map((x) => x.canonical);
24056
24090
  }
24057
- fn(head2, ops2, metadata) {
24058
- return boxFunction(this, head2, ops2, { metadata, canonical: true });
24091
+ fn(head2, ops2, options) {
24092
+ return boxFunction(this, head2, ops2, options ?? { canonical: true });
24059
24093
  }
24060
24094
  /** @internal */
24061
24095
  _fn(head2, ops2, metadata) {
@@ -24469,10 +24503,10 @@ var ComputeEngine = class _ComputeEngine {
24469
24503
  };
24470
24504
 
24471
24505
  // src/compute-engine.ts
24472
- var version = "0.12.4";
24506
+ var version = "0.12.5";
24473
24507
  globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
24474
24508
  ComputeEngine: ComputeEngine.prototype.constructor,
24475
- version: "0.12.4"
24509
+ version: "0.12.5"
24476
24510
  };
24477
24511
  export {
24478
24512
  ComputeEngine,