@cortex-js/compute-engine 0.15.0 → 0.16.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 (99) hide show
  1. package/dist/compute-engine.esm.js +3246 -1703
  2. package/dist/compute-engine.js +3246 -1703
  3. package/dist/compute-engine.min.esm.js +3246 -1705
  4. package/dist/compute-engine.min.js +3246 -1705
  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 +15 -0
  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 +2 -2
  14. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +9 -12
  15. package/dist/types/compute-engine/boxed-expression/box.d.ts +8 -3
  16. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +3 -3
  17. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +6 -6
  18. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +27 -1
  19. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +7 -19
  20. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +3 -3
  21. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +3 -3
  22. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -3
  23. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +11 -10
  24. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +17 -11
  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 +30 -9
  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 +55 -23
  32. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  33. package/dist/types/compute-engine/domain-utils.d.ts +4 -19
  34. package/dist/types/compute-engine/function-utils.d.ts +84 -0
  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 +2 -2
  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 +19 -5
  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 +3 -2
  61. package/dist/types/compute-engine/library/calculus.d.ts +2 -2
  62. package/dist/types/compute-engine/library/collections.d.ts +2 -2
  63. package/dist/types/compute-engine/library/complex.d.ts +2 -2
  64. package/dist/types/compute-engine/library/control-structures.d.ts +2 -0
  65. package/dist/types/compute-engine/library/core.d.ts +2 -2
  66. package/dist/types/compute-engine/library/domains.d.ts +7 -8
  67. package/dist/types/compute-engine/library/library.d.ts +5 -5
  68. package/dist/types/compute-engine/library/linear-algebra.d.ts +2 -0
  69. package/dist/types/compute-engine/library/logic.d.ts +2 -2
  70. package/dist/types/compute-engine/library/polynomials.d.ts +2 -2
  71. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  72. package/dist/types/compute-engine/library/relational-operator.d.ts +2 -2
  73. package/dist/types/compute-engine/library/sets.d.ts +2 -2
  74. package/dist/types/compute-engine/library/statistics.d.ts +2 -2
  75. package/dist/types/compute-engine/library/trigonometry.d.ts +2 -2
  76. package/dist/types/compute-engine/library/utils.d.ts +3 -3
  77. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  78. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +3 -2
  79. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +2 -2
  80. package/dist/types/compute-engine/numerics/numeric.d.ts +60 -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/public.d.ts +205 -91
  84. package/dist/types/compute-engine/rules.d.ts +1 -1
  85. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  86. package/dist/types/compute-engine/solve.d.ts +1 -1
  87. package/dist/types/compute-engine/symbolic/derivative.d.ts +6 -0
  88. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  89. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  90. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  91. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  92. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  93. package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
  94. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  95. package/dist/types/compute-engine.d.ts +2 -2
  96. package/dist/types/math-json/math-json-format.d.ts +1 -1
  97. package/dist/types/math-json/utils.d.ts +1 -1
  98. package/dist/types/math-json.d.ts +2 -2
  99. package/package.json +23 -21
@@ -1,4 +1,4 @@
1
- /* 0.15.0 */
1
+ /* 0.16.0 */
2
2
  export declare function bigint(a: Decimal | number | bigint | string): bigint;
3
3
  export declare function gcd(a: bigint, b: bigint): bigint;
4
4
  export declare function lcm(a: bigint, b: bigint): bigint;
@@ -1,9 +1,10 @@
1
- /* 0.15.0 */
1
+ /* 0.16.0 */
2
2
  import { IComputeEngine } from '../public';
3
3
  export declare function gcd(a: Decimal, b: Decimal): Decimal;
4
4
  export declare function lcm(a: Decimal, b: Decimal): Decimal;
5
5
  export declare function factorial(ce: IComputeEngine, n: Decimal): Decimal;
6
- export declare function lngamma(ce: IComputeEngine, z: Decimal): Decimal;
6
+ export declare function factorial2(ce: IComputeEngine, n: Decimal): Decimal;
7
+ export declare function gammaln(ce: IComputeEngine, z: Decimal): Decimal;
7
8
  export declare function gamma(ce: IComputeEngine, z: Decimal): Decimal;
8
9
  /**
9
10
  * If the exponent of the bignum is in the range of the exponents
@@ -1,3 +1,3 @@
1
- /* 0.15.0 */
1
+ /* 0.16.0 */
2
2
  export declare function gamma(c: Complex): Complex;
3
- export declare function lngamma(c: Complex): Complex;
3
+ export declare function gammaln(c: Complex): Complex;
@@ -1,4 +1,4 @@
1
- /* 0.15.0 */
1
+ /* 0.16.0 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { BoxedExpression } from '../public';
4
4
  export declare const MACHINE_PRECISION_BITS = 53;
@@ -30,7 +30,8 @@ export declare function factorPower(n: number, exponent: number): [factor: numbe
30
30
  export declare function gcd(a: number, b: number): number;
31
31
  export declare function lcm(a: number, b: number): number;
32
32
  export declare function factorial(n: number): number;
33
- export declare function lngamma(z: number): number;
33
+ export declare function factorial2(n: number): number;
34
+ export declare function gammaln(z: number): number;
34
35
  export declare function gamma(z: number): number;
35
36
  export declare function fromDigits(s: string, base?: number): [value: number, rest: string];
36
37
  export declare function asFloat(expr: BoxedExpression): number | null;
@@ -39,4 +40,61 @@ export declare function asSmallInteger(expr: BoxedExpression): number | null;
39
40
  export declare function chop(n: number, tolerance: number): number;
40
41
  export declare function chop(n: Decimal, tolerance: number): 0 | Decimal;
41
42
  export declare function chop(n: Complex, tolerance: number): 0 | Complex;
43
+ /**
44
+ * An approximation of the gaussian error function, Erf(), using
45
+ * Abramowitz and Stegun approximation.
46
+ *
47
+ * Thoughts for future improvements:
48
+ * - https://math.stackexchange.com/questions/321569/approximating-the-error-function-erf-by-analytical-functions
49
+ * - https://en.wikipedia.org/wiki/Error_function#Approximation_with_elementary_functions
50
+
51
+ *
52
+ * References:
53
+ * - NIST: https://dlmf.nist.gov/7.24#i
54
+ */
42
55
  export declare function erf(x: number): number;
56
+ /**
57
+ * Trivial function, used when compiling.
58
+ */
59
+ export declare function erfc(x: number): number;
60
+ /**
61
+ * Inverse Error Function.
62
+ *
63
+ */
64
+ export declare function erfInv(x: number): number;
65
+ /**
66
+ * An 8th-order centered difference approximation can be used to get a highly
67
+ * accurate approximation of the first derivative of a function.
68
+ * The formula for the 8th-order centered difference approximation for the
69
+ * first derivative is given by:
70
+ *
71
+ * \[
72
+ * f'(x) \approx \frac{-f(x-4h) + 9f(x-3h) - 45f(x-2h) + 186f(x-h) - 186f(x+h) + 45f(x+2h) - 9f(x+3h) + f(x+4h)}{60h}
73
+ * \]
74
+ *
75
+ * Note: Mathematica uses an 8th order approximation for the first derivative
76
+ *
77
+ * f: the function
78
+ * x: the point at which to approximate the derivative
79
+ * h: the step size
80
+ */
81
+ export declare function centeredDiff8thOrder(f: (number: any) => number, x: number, h?: number): number;
82
+ /**
83
+ * Return a numerical approximation of the integral
84
+ * of the function `f` from `a` to `b` using Monte Carlo integration.
85
+ *
86
+ * Thoughts for future improvements:
87
+ * - use a MISER algorithm to improve the accuracy
88
+ * - use a stratified sampling to improve the accuracy
89
+ * - use a quasi-Monte Carlo method to improve the accuracy
90
+ * - use a Markov Chain Monte Carlo method to improve the accuracy
91
+ * - use a Metropolis-Hastings algorithm to improve the accuracy
92
+ * - use a Hamiltonian Monte Carlo algorithm to improve the accuracy
93
+ * - use a Gibbs sampling algorithm to improve the accuracy
94
+ *
95
+ *
96
+ * See:
97
+ * - https://64.github.io/monte-carlo/
98
+ *
99
+ */
100
+ export declare function monteCarloEstimate(f: (x: number) => number, a: number, b: number, n?: number): number;
@@ -1,2 +1,2 @@
1
- /* 0.15.0 */
1
+ /* 0.16.0 */
2
2
  export declare function isPrime(n: number): boolean | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.15.0 */
1
+ /* 0.16.0 */
2
2
  export declare function isRational(x: any | null): x is Rational;
3
3
  export declare function isMachineRational(x: any | null): x is [number, number];
4
4
  export declare function isBigRational(x: any | null): x is [bigint, bigint];