@cortex-js/compute-engine 0.18.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/compute-engine.esm.js +21 -10
  2. package/dist/compute-engine.js +21 -10
  3. package/dist/compute-engine.min.esm.js +7 -7
  4. package/dist/compute-engine.min.js +7 -7
  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/compile.d.ts +1 -1
  31. package/dist/types/compute-engine/compute-engine.d.ts +1 -1
  32. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  33. package/dist/types/compute-engine/domain-utils.d.ts +1 -1
  34. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  35. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  36. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  37. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  38. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  39. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  40. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  41. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  42. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  43. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  51. package/dist/types/compute-engine/latex-syntax/public.d.ts +1 -1
  52. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  53. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  54. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  55. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  56. package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
  57. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
  58. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
  59. package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
  60. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  61. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  62. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  63. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  64. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  65. package/dist/types/compute-engine/library/core.d.ts +1 -1
  66. package/dist/types/compute-engine/library/domains.d.ts +1 -1
  67. package/dist/types/compute-engine/library/library.d.ts +1 -1
  68. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  69. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  70. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  71. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  72. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  73. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  74. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  75. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  76. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  77. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  78. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  79. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  80. package/dist/types/compute-engine/numerics/numeric.d.ts +4 -2
  81. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  82. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  83. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  84. package/dist/types/compute-engine/public.d.ts +1 -1
  85. package/dist/types/compute-engine/rules.d.ts +1 -1
  86. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  87. package/dist/types/compute-engine/solve.d.ts +1 -1
  88. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  89. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  90. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  91. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  92. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  93. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  94. package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
  95. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  96. package/dist/types/compute-engine.d.ts +2 -2
  97. package/dist/types/math-json/math-json-format.d.ts +1 -1
  98. package/dist/types/math-json/utils.d.ts +1 -1
  99. package/dist/types/math-json.d.ts +2 -2
  100. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /** CortexJS Compute Engine 0.18.0 */
1
+ /** CortexJS Compute Engine 0.18.1 */
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -9433,6 +9433,11 @@ var _Parser = class {
9433
9433
  const exponent = this.parseExponent();
9434
9434
  if (!hasRepeatingPart && this.options.parseNumbers === "rational") {
9435
9435
  const whole = parseInt(wholePart, 10);
9436
+ if (!fractionalPart) {
9437
+ if (exponent)
9438
+ return ["Multiply", whole, ["Power", 10, exponent]];
9439
+ return whole;
9440
+ }
9436
9441
  const fraction = parseInt(fractionalPart, 10);
9437
9442
  const n = fractionalPart.length;
9438
9443
  const numerator = whole * Math.pow(10, n) + fraction;
@@ -12509,10 +12514,10 @@ function erfInv(x) {
12509
12514
  const x7 = x5 * x2;
12510
12515
  return Math.sqrt(pi) / 2 * (x + pi / 12 * x3 + 7 * pi2 / 480 * x5 + 127 * pi3 / 40320 * x7 + 4369 * pi2 * pi2 / 5806080 * x7 * x2 + 34807 * pi3 * pi2 / 182476800 * x7 * x2 * x2);
12511
12516
  }
12512
- function centeredDiff8thOrder(f, x, h = 1e-4) {
12513
- return (-f(x - 4 * h) + 9 * f(x - 3 * h) - 45 * f(x - 2 * h) + 186 * f(x - h) - 186 * f(x + h) + 45 * f(x + 2 * h) - 9 * f(x + 3 * h) + f(x + 4 * h)) / (60 * h);
12517
+ function centeredDiff8thOrder(f, x, h = 0.1) {
12518
+ return (f(x - 4 * h) / 280 - 4 * f(x - 3 * h) / 105 + f(x - 2 * h) / 5 - 4 * f(x - h) / 5 + 4 * f(x + h) / 5 - f(x + 2 * h) / 5 + 4 * f(x + 3 * h) / 105 - f(x + 4 * h) / 280) / h;
12514
12519
  }
12515
- function monteCarloEstimate(f, a, b, n = 1e4) {
12520
+ function monteCarloEstimate(f, a, b, n = 1e5) {
12516
12521
  let sum2 = 0;
12517
12522
  if (a === -Infinity && b === Infinity) {
12518
12523
  for (let i = 0; i < n; i++) {
@@ -20981,7 +20986,7 @@ var CALCULUS_LIBRARY = [
20981
20986
  if (typeof x !== "number")
20982
20987
  return void 0;
20983
20988
  const f = applicableN1(ce.box(ops2[0]));
20984
- return ce.number(centeredDiff8thOrder(f, x, 1e-6));
20989
+ return ce.number(centeredDiff8thOrder(f, x));
20985
20990
  }
20986
20991
  }
20987
20992
  },
@@ -21037,11 +21042,17 @@ var CALCULUS_LIBRARY = [
21037
21042
  signature: {
21038
21043
  domain: ["FunctionOf", "Functions", "Numbers", "Numbers", "Numbers"],
21039
21044
  evaluate: (ce, ops2) => {
21045
+ const numericMode = ce.numericMode;
21046
+ const precision = ce.precision;
21047
+ ce.numericMode = "machine";
21040
21048
  const f = applicableN1(ops2[0]);
21041
21049
  const [a, b] = ops2.slice(1).map((op3) => op3.valueOf());
21042
- if (typeof a !== "number" || typeof b !== "number")
21043
- return void 0;
21044
- return ce.number(monteCarloEstimate(f, a, b));
21050
+ let result = void 0;
21051
+ if (typeof a === "number" && typeof b === "number")
21052
+ result = ce.number(monteCarloEstimate(f, a, b));
21053
+ ce.numericMode = numericMode;
21054
+ ce.precision = precision;
21055
+ return result;
21045
21056
  }
21046
21057
  }
21047
21058
  }
@@ -27628,10 +27639,10 @@ var ComputeEngine = class _ComputeEngine {
27628
27639
  };
27629
27640
 
27630
27641
  // src/compute-engine.ts
27631
- var version = "0.18.0";
27642
+ var version = "0.18.1";
27632
27643
  globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
27633
27644
  ComputeEngine: ComputeEngine.prototype.constructor,
27634
- version: "0.18.0"
27645
+ version: "0.18.1"
27635
27646
  };
27636
27647
  export {
27637
27648
  ADDITION_PRECEDENCE,
@@ -1,4 +1,4 @@
1
- /** CortexJS Compute Engine 0.18.0 */
1
+ /** CortexJS Compute Engine 0.18.1 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComputeEngine = {}));})(this, (function (exports) { 'use strict';
3
3
  var ComputeEngine = (() => {
4
4
  var __create = Object.create;
@@ -9463,6 +9463,11 @@ var ComputeEngine = (() => {
9463
9463
  const exponent = this.parseExponent();
9464
9464
  if (!hasRepeatingPart && this.options.parseNumbers === "rational") {
9465
9465
  const whole = parseInt(wholePart, 10);
9466
+ if (!fractionalPart) {
9467
+ if (exponent)
9468
+ return ["Multiply", whole, ["Power", 10, exponent]];
9469
+ return whole;
9470
+ }
9466
9471
  const fraction = parseInt(fractionalPart, 10);
9467
9472
  const n = fractionalPart.length;
9468
9473
  const numerator = whole * Math.pow(10, n) + fraction;
@@ -12539,10 +12544,10 @@ var ComputeEngine = (() => {
12539
12544
  const x7 = x5 * x2;
12540
12545
  return Math.sqrt(pi) / 2 * (x + pi / 12 * x3 + 7 * pi2 / 480 * x5 + 127 * pi3 / 40320 * x7 + 4369 * pi2 * pi2 / 5806080 * x7 * x2 + 34807 * pi3 * pi2 / 182476800 * x7 * x2 * x2);
12541
12546
  }
12542
- function centeredDiff8thOrder(f, x, h = 1e-4) {
12543
- return (-f(x - 4 * h) + 9 * f(x - 3 * h) - 45 * f(x - 2 * h) + 186 * f(x - h) - 186 * f(x + h) + 45 * f(x + 2 * h) - 9 * f(x + 3 * h) + f(x + 4 * h)) / (60 * h);
12547
+ function centeredDiff8thOrder(f, x, h = 0.1) {
12548
+ return (f(x - 4 * h) / 280 - 4 * f(x - 3 * h) / 105 + f(x - 2 * h) / 5 - 4 * f(x - h) / 5 + 4 * f(x + h) / 5 - f(x + 2 * h) / 5 + 4 * f(x + 3 * h) / 105 - f(x + 4 * h) / 280) / h;
12544
12549
  }
12545
- function monteCarloEstimate(f, a, b, n = 1e4) {
12550
+ function monteCarloEstimate(f, a, b, n = 1e5) {
12546
12551
  let sum2 = 0;
12547
12552
  if (a === -Infinity && b === Infinity) {
12548
12553
  for (let i = 0; i < n; i++) {
@@ -21011,7 +21016,7 @@ ${js}`);
21011
21016
  if (typeof x !== "number")
21012
21017
  return void 0;
21013
21018
  const f = applicableN1(ce.box(ops2[0]));
21014
- return ce.number(centeredDiff8thOrder(f, x, 1e-6));
21019
+ return ce.number(centeredDiff8thOrder(f, x));
21015
21020
  }
21016
21021
  }
21017
21022
  },
@@ -21067,11 +21072,17 @@ ${js}`);
21067
21072
  signature: {
21068
21073
  domain: ["FunctionOf", "Functions", "Numbers", "Numbers", "Numbers"],
21069
21074
  evaluate: (ce, ops2) => {
21075
+ const numericMode = ce.numericMode;
21076
+ const precision = ce.precision;
21077
+ ce.numericMode = "machine";
21070
21078
  const f = applicableN1(ops2[0]);
21071
21079
  const [a, b] = ops2.slice(1).map((op3) => op3.valueOf());
21072
- if (typeof a !== "number" || typeof b !== "number")
21073
- return void 0;
21074
- return ce.number(monteCarloEstimate(f, a, b));
21080
+ let result = void 0;
21081
+ if (typeof a === "number" && typeof b === "number")
21082
+ result = ce.number(monteCarloEstimate(f, a, b));
21083
+ ce.numericMode = numericMode;
21084
+ ce.precision = precision;
21085
+ return result;
21075
21086
  }
21076
21087
  }
21077
21088
  }
@@ -27658,10 +27669,10 @@ ${JSON.stringify(entry)}`
27658
27669
  };
27659
27670
 
27660
27671
  // src/compute-engine.ts
27661
- var version = "0.18.0";
27672
+ var version = "0.18.1";
27662
27673
  globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
27663
27674
  ComputeEngine: ComputeEngine.prototype.constructor,
27664
- version: "0.18.0"
27675
+ version: "0.18.1"
27665
27676
  };
27666
27677
  return __toCommonJS(compute_engine_exports);
27667
27678
  })();