@cortex-js/compute-engine 0.20.0 → 0.20.2

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 (102) hide show
  1. package/dist/compute-engine.esm.js +274 -209
  2. package/dist/compute-engine.js +274 -209
  3. package/dist/compute-engine.min.esm.js +10 -10
  4. package/dist/compute-engine.min.js +10 -10
  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/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  11. package/dist/types/common/signals.d.ts +1 -1
  12. package/dist/types/common/utils.d.ts +1 -1
  13. package/dist/types/compute-engine/assume.d.ts +1 -1
  14. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  15. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  16. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  17. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
  18. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
  19. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  20. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  21. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  22. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  23. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  25. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  26. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  27. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  28. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  29. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  30. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  31. package/dist/types/compute-engine/compile.d.ts +1 -1
  32. package/dist/types/compute-engine/compute-engine.d.ts +1 -1
  33. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  34. package/dist/types/compute-engine/domain-utils.d.ts +1 -1
  35. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  36. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  37. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  38. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  39. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  40. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +2 -2
  41. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  42. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +2 -0
  43. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  51. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  52. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  53. package/dist/types/compute-engine/latex-syntax/public.d.ts +1 -1
  54. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  55. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  56. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  57. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  58. package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
  59. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
  60. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
  61. package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
  62. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  63. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  64. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  65. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  66. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  67. package/dist/types/compute-engine/library/core.d.ts +1 -1
  68. package/dist/types/compute-engine/library/domains.d.ts +1 -1
  69. package/dist/types/compute-engine/library/library.d.ts +1 -1
  70. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  71. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  72. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  73. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  74. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  75. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  76. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  77. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  78. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  79. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  80. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  81. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  82. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  83. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  84. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  85. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  86. package/dist/types/compute-engine/public.d.ts +1 -1
  87. package/dist/types/compute-engine/rules.d.ts +1 -1
  88. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  89. package/dist/types/compute-engine/solve.d.ts +1 -1
  90. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  91. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  92. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  93. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  94. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  95. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  96. package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
  97. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  98. package/dist/types/compute-engine.d.ts +2 -2
  99. package/dist/types/math-json/math-json-format.d.ts +1 -1
  100. package/dist/types/math-json/utils.d.ts +2 -1
  101. package/dist/types/math-json.d.ts +2 -2
  102. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /** CortexJS Compute Engine 0.20.0 */
1
+ /** CortexJS Compute Engine 0.20.2 */
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 __create = Object.create;
@@ -3980,6 +3980,13 @@ var ComputeEngine = (() => {
3980
3980
  return Math.max(0, expr.fn.length - 1);
3981
3981
  return 0;
3982
3982
  }
3983
+ function unhold(expr) {
3984
+ if (expr === null || expr === void 0)
3985
+ return null;
3986
+ if (head(expr) === "Hold")
3987
+ return op(expr, 1);
3988
+ return expr;
3989
+ }
3983
3990
  function symbol(expr) {
3984
3991
  if (expr === null || expr === void 0)
3985
3992
  return null;
@@ -5396,16 +5403,14 @@ var ComputeEngine = (() => {
5396
5403
  lhs = op(lhs, 1) ?? "Nothing";
5397
5404
  if (head(lhs) === "Sequence") {
5398
5405
  for (const x of ops(lhs) ?? []) {
5399
- if (symbol(x))
5400
- params.push(symbol(x));
5401
- else
5406
+ if (!symbol(x))
5402
5407
  return null;
5408
+ params.push(symbol(x));
5403
5409
  }
5404
5410
  } else {
5405
- if (symbol(lhs))
5406
- params = [symbol(lhs)];
5407
- else
5411
+ if (!symbol(lhs))
5408
5412
  return null;
5413
+ params = [symbol(lhs)];
5409
5414
  }
5410
5415
  let rhs = parser.parseExpression({ minPrec: ARROW_PRECEDENCE }) ?? "Nothing";
5411
5416
  if (head(rhs) === "Delimiter")
@@ -5478,8 +5483,23 @@ var ComputeEngine = (() => {
5478
5483
  // return ['Assign', lhs, rhs];
5479
5484
  // },
5480
5485
  serialize: (serializer, expr) => {
5486
+ const id = unhold(op(expr, 1));
5487
+ if (head(op(expr, 2)) === "Function") {
5488
+ const op_2 = op(expr, 2);
5489
+ const body = unhold(op(op_2, 1));
5490
+ const args = ops(op_2)?.slice(1) ?? [];
5491
+ return joinLatex([
5492
+ serializer.serialize(id),
5493
+ serializer.wrapString(
5494
+ args.map((x) => serializer.serialize(x)).join(", "),
5495
+ serializer.options.applyFunctionStyle(expr, serializer.level)
5496
+ ),
5497
+ "\\coloneq",
5498
+ serializer.serialize(body)
5499
+ ]);
5500
+ }
5481
5501
  return joinLatex([
5482
- serializer.serialize(op(expr, 1)),
5502
+ serializer.serialize(id),
5483
5503
  "\\coloneq",
5484
5504
  serializer.serialize(op(expr, 2))
5485
5505
  ]);
@@ -5585,107 +5605,6 @@ var ComputeEngine = (() => {
5585
5605
  return serializer.wrapString(body, style, open + close);
5586
5606
  }
5587
5607
  },
5588
- // The first argument is the matrix data.
5589
- // The second, optional, argument are the delimiters.
5590
- // The third, optional, argument is the column specification.
5591
- {
5592
- name: "Matrix",
5593
- // https://ctan.math.illinois.edu/macros/latex/required/tools/array.pdf
5594
- serialize: (serializer, expr) => {
5595
- const body = op(expr, 1);
5596
- const delims = op(expr, 2) ?? "()";
5597
- let columns = "";
5598
- if (op(expr, 3) !== null) {
5599
- const colsSpec = stringValue(op(expr, 3)) ?? "";
5600
- for (const c of colsSpec) {
5601
- if (c === "<")
5602
- columns += "l";
5603
- else if (c === ">")
5604
- columns += "r";
5605
- else if (c === "=")
5606
- columns += "c";
5607
- else if (c === "|")
5608
- columns += "|";
5609
- else if (c === ":")
5610
- columns += ":";
5611
- }
5612
- }
5613
- let [open, close] = ["", ""];
5614
- if (typeof delims === "string" && delims.length === 2)
5615
- [open, close] = delims;
5616
- const rows = [];
5617
- for (const row of ops(body) ?? []) {
5618
- const cells = [];
5619
- for (const cell of ops(row) ?? [])
5620
- cells.push(serializer.serialize(cell));
5621
- rows.push(cells.join(" & "));
5622
- }
5623
- const tabular = rows.join("\\\\\n");
5624
- const optColumns = columns.length > 0 ? `[${columns}]` : "";
5625
- if (open === "(" && close === ")")
5626
- return joinLatex([
5627
- "\\begin{pmatrix}",
5628
- optColumns,
5629
- tabular,
5630
- "\\end{pmatrix}"
5631
- ]);
5632
- if (open === "[" && close === "]")
5633
- return joinLatex([
5634
- "\\begin{bmatrix}",
5635
- optColumns,
5636
- tabular,
5637
- "\\end{bmatrix}"
5638
- ]);
5639
- if (open === "{" && close === "}")
5640
- return joinLatex([
5641
- "\\begin{Bmatrix}",
5642
- optColumns,
5643
- tabular,
5644
- "\\end{Bmatrix}"
5645
- ]);
5646
- if (open === "|" && close === "|")
5647
- return joinLatex([
5648
- "\\begin{vmatrix}",
5649
- optColumns,
5650
- tabular,
5651
- "\\end{vmatrix}"
5652
- ]);
5653
- if (open === "\u2016" && close === "\u2016")
5654
- return joinLatex([
5655
- "\\begin{Vmatrix}",
5656
- optColumns,
5657
- tabular,
5658
- "\\end{Vmatrix}"
5659
- ]);
5660
- if (open === "{" && close === ".")
5661
- return joinLatex([
5662
- "\\begin{dcases}",
5663
- optColumns,
5664
- tabular,
5665
- "\\end{dcases}"
5666
- ]);
5667
- if (open === "." && close === "}")
5668
- return joinLatex([
5669
- "\\begin{rcases}",
5670
- optColumns,
5671
- tabular,
5672
- "\\end{rcases}"
5673
- ]);
5674
- if (columns || open !== "." || close !== ".") {
5675
- return joinLatex([
5676
- "\\left",
5677
- DELIMITERS_SHORTHAND[open] ?? open,
5678
- "\\begin{array}",
5679
- `{${columns}}`,
5680
- tabular,
5681
- "\\end{array}",
5682
- "\\right",
5683
- DELIMITERS_SHORTHAND[close] ?? close
5684
- ]);
5685
- }
5686
- return joinLatex(["\\begin{matrix}", tabular, "\\end{matrix}"]);
5687
- }
5688
- },
5689
5608
  {
5690
5609
  name: "Domain",
5691
5610
  serialize: (serializer, expr) => {
@@ -6326,11 +6245,11 @@ var ComputeEngine = (() => {
6326
6245
  "(": "(",
6327
6246
  ")": ")",
6328
6247
  "[": "\\lbrack",
6248
+ "]": "\\rbrack",
6329
6249
  "\u27E6": "\\llbrack",
6330
6250
  // U+27E6 MATHEMATICAL LEFT WHITE SQUARE BRACKET
6331
6251
  "\u27E7": "\\rrbrack",
6332
6252
  // U+27E7 MATHEMATICAL RIGHT WHITE SQUARE BRACKET
6333
- "]": "\\rbrack",
6334
6253
  "{": "\\lbrace",
6335
6254
  "}": "\\rbrace",
6336
6255
  "<": "\\langle",
@@ -6377,6 +6296,16 @@ var ComputeEngine = (() => {
6377
6296
  }
6378
6297
  return ["Assign", fn, ["Function", rhs2, ...args ?? []]];
6379
6298
  }
6299
+ if (typeof head(lhs) === "string") {
6300
+ const fn = head(lhs);
6301
+ const args = ops(lhs) ?? [];
6302
+ const rhs2 = parser.parseExpression({ minPrec: 0 });
6303
+ if (rhs2 === null) {
6304
+ parser.index = index;
6305
+ return null;
6306
+ }
6307
+ return ["Assign", fn, ["Function", rhs2, ...args]];
6308
+ }
6380
6309
  if (!symbol(lhs))
6381
6310
  return null;
6382
6311
  const rhs = parser.parseExpression({ minPrec: 0 });
@@ -6787,6 +6716,111 @@ var ComputeEngine = (() => {
6787
6716
  }
6788
6717
  ];
6789
6718
 
6719
+ // src/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.ts
6720
+ var DEFINITIONS_LINEAR_ALGEBRA = [
6721
+ // The first argument is the matrix data.
6722
+ // The second, optional, argument are the delimiters.
6723
+ // The third, optional, argument is the column specification.
6724
+ {
6725
+ name: "Matrix",
6726
+ // https://ctan.math.illinois.edu/macros/latex/required/tools/array.pdf
6727
+ serialize: (serializer, expr) => {
6728
+ const body = op(expr, 1);
6729
+ const delims = op(expr, 2) ?? "()";
6730
+ let columns = "";
6731
+ if (op(expr, 3) !== null) {
6732
+ const colsSpec = stringValue(op(expr, 3)) ?? "";
6733
+ for (const c of colsSpec) {
6734
+ if (c === "<")
6735
+ columns += "l";
6736
+ else if (c === ">")
6737
+ columns += "r";
6738
+ else if (c === "=")
6739
+ columns += "c";
6740
+ else if (c === "|")
6741
+ columns += "|";
6742
+ else if (c === ":")
6743
+ columns += ":";
6744
+ }
6745
+ }
6746
+ let [open, close] = ["", ""];
6747
+ if (typeof delims === "string" && delims.length === 2)
6748
+ [open, close] = delims;
6749
+ const rows = [];
6750
+ for (const row of ops(body) ?? []) {
6751
+ const cells = [];
6752
+ for (const cell of ops(row) ?? [])
6753
+ cells.push(serializer.serialize(cell));
6754
+ rows.push(cells.join(" & "));
6755
+ }
6756
+ const tabular = rows.join("\\\\\n");
6757
+ const optColumns = columns.length > 0 ? `[${columns}]` : "";
6758
+ if (open === "(" && close === ")")
6759
+ return joinLatex([
6760
+ "\\begin{pmatrix}",
6761
+ optColumns,
6762
+ tabular,
6763
+ "\\end{pmatrix}"
6764
+ ]);
6765
+ if (open === "[" && close === "]")
6766
+ return joinLatex([
6767
+ "\\begin{bmatrix}",
6768
+ optColumns,
6769
+ tabular,
6770
+ "\\end{bmatrix}"
6771
+ ]);
6772
+ if (open === "{" && close === "}")
6773
+ return joinLatex([
6774
+ "\\begin{Bmatrix}",
6775
+ optColumns,
6776
+ tabular,
6777
+ "\\end{Bmatrix}"
6778
+ ]);
6779
+ if (open === "|" && close === "|")
6780
+ return joinLatex([
6781
+ "\\begin{vmatrix}",
6782
+ optColumns,
6783
+ tabular,
6784
+ "\\end{vmatrix}"
6785
+ ]);
6786
+ if (open === "\u2016" && close === "\u2016")
6787
+ return joinLatex([
6788
+ "\\begin{Vmatrix}",
6789
+ optColumns,
6790
+ tabular,
6791
+ "\\end{Vmatrix}"
6792
+ ]);
6793
+ if (open === "{" && close === ".")
6794
+ return joinLatex([
6795
+ "\\begin{dcases}",
6796
+ optColumns,
6797
+ tabular,
6798
+ "\\end{dcases}"
6799
+ ]);
6800
+ if (open === "." && close === "}")
6801
+ return joinLatex([
6802
+ "\\begin{rcases}",
6803
+ optColumns,
6804
+ tabular,
6805
+ "\\end{rcases}"
6806
+ ]);
6807
+ if (columns || open !== "." || close !== ".") {
6808
+ return joinLatex([
6809
+ "\\left",
6810
+ DELIMITERS_SHORTHAND[open] ?? open,
6811
+ "\\begin{array}",
6812
+ `{${columns}}`,
6813
+ tabular,
6814
+ "\\end{array}",
6815
+ "\\right",
6816
+ DELIMITERS_SHORTHAND[close] ?? close
6817
+ ]);
6818
+ }
6819
+ return joinLatex(["\\begin{matrix}", tabular, "\\end{matrix}"]);
6820
+ }
6821
+ }
6822
+ ];
6823
+
6790
6824
  // src/compute-engine/latex-syntax/dictionary/definitions-logic.ts
6791
6825
  var DEFINITIONS_LOGIC = [
6792
6826
  // Constants
@@ -8828,25 +8862,26 @@ var ComputeEngine = (() => {
8828
8862
  return true;
8829
8863
  }
8830
8864
  var DEFAULT_LATEX_DICTIONARY = {
8831
- algebra: DEFINITIONS_ALGEBRA,
8832
- arithmetic: DEFINITIONS_ARITHMETIC,
8833
- calculus: DEFINITIONS_CALCULUS,
8834
- complex: DEFINITIONS_COMPLEX,
8835
- core: DEFINITIONS_CORE,
8836
- logic: DEFINITIONS_LOGIC,
8837
- relop: DEFINITIONS_INEQUALITIES,
8838
- other: DEFINITIONS_OTHERS,
8839
- physics: [
8865
+ "algebra": DEFINITIONS_ALGEBRA,
8866
+ "arithmetic": DEFINITIONS_ARITHMETIC,
8867
+ "calculus": DEFINITIONS_CALCULUS,
8868
+ "complex": DEFINITIONS_COMPLEX,
8869
+ "core": DEFINITIONS_CORE,
8870
+ "linear-algebra": DEFINITIONS_LINEAR_ALGEBRA,
8871
+ "logic": DEFINITIONS_LOGIC,
8872
+ "relop": DEFINITIONS_INEQUALITIES,
8873
+ "other": DEFINITIONS_OTHERS,
8874
+ "physics": [
8840
8875
  {
8841
8876
  name: "mu0",
8842
8877
  kind: "symbol",
8843
8878
  latexTrigger: "\\mu_0"
8844
8879
  }
8845
8880
  ],
8846
- sets: DEFINITIONS_SETS,
8847
- statistics: DEFINITIONS_STATISTICS,
8848
- symbols: DEFINITIONS_SYMBOLS,
8849
- trigonometry: DEFINITIONS_TRIGONOMETRY
8881
+ "sets": DEFINITIONS_SETS,
8882
+ "statistics": DEFINITIONS_STATISTICS,
8883
+ "symbols": DEFINITIONS_SYMBOLS,
8884
+ "trigonometry": DEFINITIONS_TRIGONOMETRY
8850
8885
  };
8851
8886
 
8852
8887
  // src/compute-engine/latex-syntax/parse-identifier.ts
@@ -15168,7 +15203,7 @@ var ComputeEngine = (() => {
15168
15203
  }
15169
15204
  if (h === "Function") {
15170
15205
  const params = args.slice(1).map((x) => x.symbol);
15171
- return `((${params.join(", ")}) => ${compile(args[0], {
15206
+ return `((${params.join(", ")}) => ${compile(args[0].canonical, {
15172
15207
  ...target,
15173
15208
  var: (id) => params.includes(id) ? id : target.var(id)
15174
15209
  })})`;
@@ -17779,7 +17814,7 @@ var ComputeEngine = (() => {
17779
17814
  // src/compute-engine/function-utils.ts
17780
17815
  function canonicalFunctionExpression(expr) {
17781
17816
  if (expr.head === "N" && typeof expr.op1.head === "string") {
17782
- const newHead = { D: "ND", Integrate: "NIntegrate" }[expr.op1.head];
17817
+ const newHead = { Integrate: "NIntegrate", Limit: "NLimit" }[expr.op1.head];
17783
17818
  if (newHead)
17784
17819
  expr = expr.engine._fn(newHead, expr.op1.ops);
17785
17820
  }
@@ -18250,6 +18285,11 @@ var ComputeEngine = (() => {
18250
18285
  evaluate(options) {
18251
18286
  if (!this.isValid)
18252
18287
  return this;
18288
+ if (options?.numericMode) {
18289
+ const h = this.head;
18290
+ if (h === "Integrate" || h === "Limit")
18291
+ return this.engine.box(["N", this], { canonical: true }).evaluate(options);
18292
+ }
18253
18293
  if (!this.isCanonical) {
18254
18294
  this.engine.pushScope();
18255
18295
  const canonical2 = this.canonical;
@@ -21080,71 +21120,6 @@ var ComputeEngine = (() => {
21080
21120
  evaluate: (ce, ops2) => evalSummation(ce, ops2[0], ops2[1], "evaluate"),
21081
21121
  N: (ce, ops2) => evalSummation(ce, ops2[0], ops2[1], "N")
21082
21122
  }
21083
- },
21084
- // Limits
21085
- Limit: {
21086
- description: "Limit of a function",
21087
- complexity: 5e3,
21088
- hold: "all",
21089
- threadable: false,
21090
- signature: {
21091
- domain: [
21092
- "FunctionOf",
21093
- "Anything",
21094
- "Numbers",
21095
- ["OptArg", "Numbers"],
21096
- "Numbers"
21097
- ],
21098
- N: (ce, ops2) => {
21099
- const [f, x, dir] = ops2;
21100
- const target = asFloat(x.N());
21101
- if (target === null)
21102
- return void 0;
21103
- const fn = applicable(f);
21104
- return ce.number(
21105
- limit(
21106
- (x2) => {
21107
- const y = fn([ce.number(x2)])?.value;
21108
- return typeof y === "number" ? y : Number.NaN;
21109
- },
21110
- target,
21111
- dir ? asFloat(dir) ?? 1 : 1
21112
- )
21113
- );
21114
- }
21115
- }
21116
- },
21117
- NLimit: {
21118
- description: "Numerical approximation of the limit of a function",
21119
- complexity: 5e3,
21120
- hold: "all",
21121
- threadable: false,
21122
- signature: {
21123
- domain: [
21124
- "FunctionOf",
21125
- "Anything",
21126
- "Numbers",
21127
- ["OptArg", "Numbers"],
21128
- "Numbers"
21129
- ],
21130
- evaluate: (ce, ops2) => {
21131
- const [f, x, dir] = ops2;
21132
- const target = asFloat(x.N());
21133
- if (target === null)
21134
- return void 0;
21135
- const fn = applicable(f);
21136
- return ce.number(
21137
- limit(
21138
- (x2) => {
21139
- const y = fn([ce.number(x2)])?.value;
21140
- return typeof y === "number" ? y : Number.NaN;
21141
- },
21142
- target,
21143
- dir ? asFloat(dir) ?? 1 : 1
21144
- )
21145
- );
21146
- }
21147
- }
21148
21123
  }
21149
21124
  },
21150
21125
  //
@@ -21815,6 +21790,73 @@ var ComputeEngine = (() => {
21815
21790
  }
21816
21791
  }
21817
21792
  }
21793
+ },
21794
+ {
21795
+ // Limits
21796
+ Limit: {
21797
+ description: "Limit of a function",
21798
+ complexity: 5e3,
21799
+ hold: "all",
21800
+ threadable: false,
21801
+ signature: {
21802
+ domain: [
21803
+ "FunctionOf",
21804
+ "Anything",
21805
+ "Numbers",
21806
+ ["OptArg", "Numbers"],
21807
+ "Numbers"
21808
+ ],
21809
+ N: (ce, ops2) => {
21810
+ const [f, x, dir] = ops2;
21811
+ const target = asFloat(x.N());
21812
+ if (target === null)
21813
+ return void 0;
21814
+ const fn = applicable(f);
21815
+ return ce.number(
21816
+ limit(
21817
+ (x2) => {
21818
+ const y = fn([ce.number(x2)])?.value;
21819
+ return typeof y === "number" ? y : Number.NaN;
21820
+ },
21821
+ target,
21822
+ dir ? asFloat(dir) ?? 1 : 1
21823
+ )
21824
+ );
21825
+ }
21826
+ }
21827
+ },
21828
+ NLimit: {
21829
+ description: "Numerical approximation of the limit of a function",
21830
+ complexity: 5e3,
21831
+ hold: "all",
21832
+ threadable: false,
21833
+ signature: {
21834
+ domain: [
21835
+ "FunctionOf",
21836
+ "Anything",
21837
+ "Numbers",
21838
+ ["OptArg", "Numbers"],
21839
+ "Numbers"
21840
+ ],
21841
+ evaluate: (ce, ops2) => {
21842
+ const [f, x, dir] = ops2;
21843
+ const target = asFloat(x.N());
21844
+ if (target === null)
21845
+ return void 0;
21846
+ const fn = applicable(f);
21847
+ return ce.number(
21848
+ limit(
21849
+ (x2) => {
21850
+ const y = fn([ce.number(x2)])?.value;
21851
+ return typeof y === "number" ? y : Number.NaN;
21852
+ },
21853
+ target,
21854
+ dir ? asFloat(dir) ?? 1 : 1
21855
+ )
21856
+ );
21857
+ }
21858
+ }
21859
+ }
21818
21860
  }
21819
21861
  ];
21820
21862
 
@@ -23172,18 +23214,6 @@ var ComputeEngine = (() => {
23172
23214
  }
23173
23215
  }
23174
23216
  },
23175
- Matrix: {
23176
- complexity: 9e3,
23177
- hold: "all",
23178
- signature: {
23179
- params: ["Lists"],
23180
- optParams: ["Strings", "Strings"],
23181
- result: "Lists",
23182
- canonical: canonicalMatrix,
23183
- evaluate: (_ce, ops2) => ops2[0].evaluate(),
23184
- N: (_ce, ops2) => ops2[0].N()
23185
- }
23186
- },
23187
23217
  Error: {
23188
23218
  /**
23189
23219
  * - The first argument is either a string or an `["ErrorCode"]`
@@ -23335,7 +23365,7 @@ var ComputeEngine = (() => {
23335
23365
  if (!op12.symbol)
23336
23366
  return null;
23337
23367
  const op22 = args[1];
23338
- return ce._fn("Assign", [ce.hold(op12), ce.hold(op22)]);
23368
+ return ce._fn("Assign", [op12, op22]);
23339
23369
  },
23340
23370
  evaluate: (ce, ops2) => {
23341
23371
  const op12 = ops2[0];
@@ -23431,7 +23461,27 @@ var ComputeEngine = (() => {
23431
23461
  signature: {
23432
23462
  domain: ["FunctionOf", "Anything", "Anything"],
23433
23463
  result: (_ce, ops2) => ops2[0].domain,
23434
- canonical: (ce, ops2) => ce._fn("N", checkArity(ce, ops2, 1)),
23464
+ canonical: (ce, ops2) => {
23465
+ if (ops2.length !== 1)
23466
+ return ce._fn("N", checkArity(ce, ops2, 1));
23467
+ const h = ops2[0].head;
23468
+ if (h === "N")
23469
+ return ops2[0].canonical;
23470
+ if (h === "Integrate") {
23471
+ const [index, lower, upper] = normalizeLimits(ops2[0].op2);
23472
+ if (!index || lower === void 0 || upper === void 0)
23473
+ return null;
23474
+ const fn = ops2[0].op1;
23475
+ return ce._fn("NIntegrate", [
23476
+ ce.box(["Function", fn, index]),
23477
+ ce.number(lower),
23478
+ ce.number(upper)
23479
+ ]);
23480
+ }
23481
+ if (h === "Limit")
23482
+ return ce._fn("NLimit", ops2[0].ops);
23483
+ return ce._fn("N", ops2);
23484
+ },
23435
23485
  evaluate: (_ce, ops2) => ops2[0].N()
23436
23486
  }
23437
23487
  },
@@ -23674,6 +23724,24 @@ var ComputeEngine = (() => {
23674
23724
  return ce._fn("Multiply", flattenOps(ops2, "Multiply"));
23675
23725
  return ce._fn("Tuple", ops2);
23676
23726
  }
23727
+
23728
+ // src/compute-engine/library/linear-algebra.ts
23729
+ var LINEAR_ALGEBRA_LIBRARY = [
23730
+ {
23731
+ Matrix: {
23732
+ complexity: 9e3,
23733
+ hold: "all",
23734
+ signature: {
23735
+ params: ["Lists"],
23736
+ optParams: ["Strings", "Strings"],
23737
+ result: "Lists",
23738
+ canonical: canonicalMatrix,
23739
+ evaluate: (_ce, ops2) => ops2[0].evaluate(),
23740
+ N: (_ce, ops2) => ops2[0].N()
23741
+ }
23742
+ }
23743
+ }
23744
+ ];
23677
23745
  function canonicalMatrix(ce, ops2) {
23678
23746
  if (ops2.length === 0)
23679
23747
  return ce._fn("Matrix", []);
@@ -23689,9 +23757,6 @@ var ComputeEngine = (() => {
23689
23757
  return ce._fn("Matrix", [body]);
23690
23758
  }
23691
23759
 
23692
- // src/compute-engine/library/linear-algebra.ts
23693
- var LINEAR_ALGEBRA_LIBRARY = [];
23694
-
23695
23760
  // src/compute-engine/library/logic.ts
23696
23761
  var LOGIC_LIBRARY = {
23697
23762
  True: { wikidata: "Q16751793", domain: "Booleans", constant: true },
@@ -28813,10 +28878,10 @@ ${JSON.stringify(entry)}`
28813
28878
  }
28814
28879
 
28815
28880
  // src/compute-engine.ts
28816
- var version = "0.20.0";
28881
+ var version = "0.20.2";
28817
28882
  globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
28818
28883
  ComputeEngine: ComputeEngine.prototype.constructor,
28819
- version: "0.20.0"
28884
+ version: "0.20.2"
28820
28885
  };
28821
28886
  return __toCommonJS(compute_engine_exports);
28822
28887
  })();