@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
  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
  console.assert(this.index !== index, "No token consumed");
@@ -15371,7 +15399,7 @@ function expandMultinomial(expr) {
15371
15399
  const ce = expr.engine;
15372
15400
  if (expr.op1.head === "Negate") {
15373
15401
  const sign2 = exp2 % 2 === 0 ? 1 : -1;
15374
- const result2 = expandMultinomial(ce.box(["Power", expr.op1.op1, expr.op2]));
15402
+ const result2 = expandMultinomial(ce.pow(expr.op1.op1, expr.op2));
15375
15403
  if (result2 === null)
15376
15404
  return null;
15377
15405
  if (sign2 > 0)
@@ -15596,15 +15624,14 @@ function assumeEquality(proposition) {
15596
15624
  const sols = findUnivariateRoots(proposition, lhs2);
15597
15625
  if (sols.length === 0) {
15598
15626
  ce.assumptions.set(
15599
- ce.box([
15600
- "Equal",
15627
+ ce.fn("Equal", [
15601
15628
  ce.add([proposition.op1.canonical, ce.neg(proposition.op2.canonical)]).simplify(),
15602
15629
  0
15603
15630
  ]),
15604
15631
  true
15605
15632
  );
15606
15633
  }
15607
- const val = sols.length === 1 ? sols[0] : ce.box(["List", ...sols]);
15634
+ const val = sols.length === 1 ? sols[0] : ce.fn("List", sols);
15608
15635
  const def = ce.lookupSymbol(lhs2);
15609
15636
  if (!def) {
15610
15637
  ce.defineSymbol(lhs2, { value: val });
@@ -16586,7 +16613,6 @@ var BoxedFunction = class _BoxedFunction extends AbstractBoxedExpression {
16586
16613
  return result;
16587
16614
  }
16588
16615
  solve(vars) {
16589
- console.log("solve this:", this.toString());
16590
16616
  if (vars.length !== 1)
16591
16617
  return null;
16592
16618
  const roots = findUnivariateRoots(this.simplify(), vars[0]);
@@ -16665,6 +16691,8 @@ function makeCanonicalFunction(ce, head2, ops2, metadata) {
16665
16691
  xs.push(y);
16666
16692
  }
16667
16693
  }
16694
+ if (!xs.every((x) => x.isValid))
16695
+ return new BoxedFunction(ce, head2, xs, { metadata, canonical: false });
16668
16696
  const sig = def.signature;
16669
16697
  if (sig.canonical) {
16670
16698
  try {
@@ -16695,21 +16723,22 @@ function makeCanonicalFunction(ce, head2, ops2, metadata) {
16695
16723
  return new BoxedFunction(ce, head2, xs, { metadata, def, canonical: true });
16696
16724
  }
16697
16725
  function apply(fn, args) {
16726
+ const ce = fn.engine;
16698
16727
  if (fn.head !== "Lambda")
16699
- return fn.engine._fn(fn.evaluate(), args);
16728
+ return ce._fn(fn.evaluate(), args);
16700
16729
  const subs2 = {
16701
- "__": fn.engine.tuple(args),
16702
- "_#": fn.engine.number(args.length)
16730
+ "__": ce.tuple(args),
16731
+ "_#": ce.number(args.length)
16703
16732
  };
16704
16733
  let n = 1;
16705
16734
  for (const op3 of args)
16706
16735
  subs2[`_${n++}`] = op3;
16707
16736
  subs2["_"] = subs2["_1"];
16708
- const savedContext = this.context;
16709
- this.context = fn.scope ?? null;
16710
- const result = fn.subs(subs2).evaluate();
16711
- this.context = savedContext;
16712
- return result;
16737
+ const savedContext = ce.context;
16738
+ ce.context = fn.scope ?? null;
16739
+ const result = fn.subs(subs2);
16740
+ ce.context = savedContext;
16741
+ return result.op1.evaluate();
16713
16742
  }
16714
16743
  function holdMap(xs, skip, associativeHead, f) {
16715
16744
  if (xs.length === 0)
@@ -18824,7 +18853,7 @@ var ARITHMETIC_LIBRARY = [
18824
18853
  return ce._NEGATIVE_INFINITY;
18825
18854
  if (ops2.length === 1)
18826
18855
  return ops2[0];
18827
- return ce.box(["Max", ...ops2]);
18856
+ return ce.fn("Max", ops2);
18828
18857
  },
18829
18858
  evaluate: (ce, ops2) => {
18830
18859
  if (ops2.length === 0)
@@ -18853,7 +18882,7 @@ var ARITHMETIC_LIBRARY = [
18853
18882
  return ce._NEGATIVE_INFINITY;
18854
18883
  if (ops2.length === 1)
18855
18884
  return ops2[0];
18856
- return ce.box(["Min", ...ops2]);
18885
+ return ce.fn("Min", ops2);
18857
18886
  },
18858
18887
  evaluate: (ce, ops2) => {
18859
18888
  if (ops2.length === 0)
@@ -19194,7 +19223,7 @@ var ARITHMETIC_LIBRARY = [
19194
19223
  e: {
19195
19224
  domain: "TranscendentalNumber",
19196
19225
  constant: true,
19197
- holdUntil: "never",
19226
+ holdUntil: "N",
19198
19227
  value: "ExponentialE"
19199
19228
  },
19200
19229
  i: {
@@ -19220,14 +19249,13 @@ var ARITHMETIC_LIBRARY = [
19220
19249
  },
19221
19250
  Half: {
19222
19251
  constant: true,
19223
- holdUntil: "never",
19252
+ holdUntil: "evaluate",
19224
19253
  value: ["Rational", 1, 2]
19225
19254
  },
19226
19255
  ImaginaryUnit: {
19227
19256
  domain: "ImaginaryNumber",
19228
19257
  constant: true,
19229
- holdUntil: "evaluate",
19230
- // @todo maybe?
19258
+ holdUntil: "never",
19231
19259
  wikidata: "Q193796",
19232
19260
  flags: { imaginary: true },
19233
19261
  value: ["Complex", 0, 1]
@@ -20055,8 +20083,7 @@ var CORE_LIBRARY = [
20055
20083
  signature: {
20056
20084
  domain: ["Function", ["Maybe", ["Sequence", "Anything"]], "String"],
20057
20085
  evaluate: (ce, ops2) => {
20058
- return ce.box([
20059
- "Latex",
20086
+ return ce.fn("Latex", [
20060
20087
  ce.string(tokensToString(ops2.map((x) => x.string ?? x.latex)))
20061
20088
  ]);
20062
20089
  }
@@ -20079,7 +20106,7 @@ var CORE_LIBRARY = [
20079
20106
  hold: "all",
20080
20107
  signature: {
20081
20108
  domain: ["Function", ["Maybe", ["Sequence", "Anything"]], "String"],
20082
- evaluate: (ce, ops2) => ce.box(["Latex", ce.string(joinLatex(ops2.map((x) => x.latex)))])
20109
+ evaluate: (ce, ops2) => ce.fn("Latex", [ce.string(joinLatex(ops2.map((x) => x.latex)))])
20083
20110
  }
20084
20111
  },
20085
20112
  SplitAsLatexTokens: {
@@ -20916,13 +20943,13 @@ var TRIGONOMETRY_LIBRARY = [
20916
20943
  "Number"
20917
20944
  ]);
20918
20945
  if (ops2.length !== 1)
20919
- return ce.box(["Degrees", ops2]);
20946
+ return ce.fn("Degrees", ops2, { canonical: false });
20920
20947
  const arg = ops2[0];
20921
20948
  if (arg.numericValue === null || !arg.isValid)
20922
- return ce.box(["Degrees", arg]);
20949
+ return ce.fn("Degrees", ops2, { canonical: false });
20923
20950
  return ce.div(ce.mul([arg, ce.symbol("Pi")]), ce.number(180));
20924
20951
  },
20925
- evaluate: (ce, ops2) => ce.mul([ops2[0], ce.box(["Divide", "Pi", 180])])
20952
+ evaluate: (ce, ops2) => ce.mul([ops2[0], ce.div(ce.symbol("Pi"), ce.number(180))])
20926
20953
  }
20927
20954
  },
20928
20955
  Hypot: {
@@ -21442,6 +21469,8 @@ var TRIG_IDENTITIES = {
21442
21469
  ]
21443
21470
  };
21444
21471
  function constructibleValues(ce, head2, x) {
21472
+ if (!x)
21473
+ return void 0;
21445
21474
  const specialValues = ce.cache(
21446
21475
  "constructible-trigonometric-values",
21447
21476
  () => {
@@ -21518,6 +21547,8 @@ function processInverseFunction(ce, xs) {
21518
21547
  return newHead ? ce.symbol(newHead) : void 0;
21519
21548
  }
21520
21549
  function evalTrig(ce, mode, head2, op3) {
21550
+ if (!op3)
21551
+ return void 0;
21521
21552
  if (mode === "evaluate") {
21522
21553
  const result = constructibleValues(ce, head2, op3)?.evaluate();
21523
21554
  if (result)
@@ -21715,7 +21746,7 @@ var BoxedSymbolDefinitionImpl = class {
21715
21746
  this._flags = def.flags ? normalizeFlags(def.flags) : void 0;
21716
21747
  this._domain = def.domain ? ce.domain(def.domain) : void 0;
21717
21748
  this.constant = def.constant ?? false;
21718
- this.holdUntil = def.holdUntil ?? "simplify";
21749
+ this.holdUntil = def.holdUntil ?? "evaluate";
21719
21750
  if (this.constant) {
21720
21751
  this._defValue = def.value;
21721
21752
  this._value = null;
@@ -23371,17 +23402,20 @@ var BoxedSymbol = class _BoxedSymbol extends AbstractBoxedExpression {
23371
23402
  }
23372
23403
  simplify(options) {
23373
23404
  const def = this.symbolDefinition;
23374
- if ((def?.holdUntil === "never" || def?.holdUntil === "simplify") && def.value)
23405
+ if (def?.holdUntil === "simplify" && def.value)
23375
23406
  return def.value.simplify(options);
23376
23407
  return options?.rules ? this.replace(options.rules) ?? this : this;
23377
23408
  }
23378
23409
  evaluate(options) {
23379
23410
  const def = this.symbolDefinition;
23380
- if (def?.holdUntil !== "N")
23381
- return def?.value?.evaluate(options) ?? this;
23411
+ if (def && (def.holdUntil === "simplify" || def.holdUntil === "evaluate"))
23412
+ return def.value?.evaluate(options) ?? this;
23382
23413
  return this;
23383
23414
  }
23384
23415
  N(options) {
23416
+ const def = this.symbolDefinition;
23417
+ if (def && def.holdUntil === "never")
23418
+ return this;
23385
23419
  return this.symbolDefinition?.value?.N(options) ?? this;
23386
23420
  }
23387
23421
  replace(rules, options) {
@@ -23794,7 +23828,7 @@ var ComputeEngine = class _ComputeEngine {
23794
23828
  precision: this.precision,
23795
23829
  avoidExponentsInRange: [-6, this.precision],
23796
23830
  onError: (err) => {
23797
- throw new Error(err[0].message.toString());
23831
+ throw new Error(JSON.stringify(err[0].message));
23798
23832
  }
23799
23833
  });
23800
23834
  return this._latexSyntax;
@@ -24058,8 +24092,8 @@ var ComputeEngine = class _ComputeEngine {
24058
24092
  const bxs = xs;
24059
24093
  return bxs.every((x) => x.isCanonical) ? bxs : bxs.map((x) => x.canonical);
24060
24094
  }
24061
- fn(head2, ops2, metadata) {
24062
- return boxFunction(this, head2, ops2, { metadata, canonical: true });
24095
+ fn(head2, ops2, options) {
24096
+ return boxFunction(this, head2, ops2, options ?? { canonical: true });
24063
24097
  }
24064
24098
  /** @internal */
24065
24099
  _fn(head2, ops2, metadata) {
@@ -24473,10 +24507,10 @@ var ComputeEngine = class _ComputeEngine {
24473
24507
  };
24474
24508
 
24475
24509
  // src/compute-engine.ts
24476
- var version = "0.12.4";
24510
+ var version = "0.12.5";
24477
24511
  globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
24478
24512
  ComputeEngine: ComputeEngine.prototype.constructor,
24479
- version: "0.12.4"
24513
+ version: "0.12.5"
24480
24514
  };
24481
24515
  export {
24482
24516
  ComputeEngine,