@cortex-js/compute-engine 0.34.0 → 0.35.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 (177) hide show
  1. package/dist/compute-engine.esm.js +2337 -695
  2. package/dist/compute-engine.min.esm.js +419 -38
  3. package/dist/compute-engine.min.umd.js +419 -38
  4. package/dist/compute-engine.umd.js +2337 -695
  5. package/dist/math-json.esm.js +2 -2
  6. package/dist/math-json.min.esm.js +2 -2
  7. package/dist/math-json.min.umd.js +2 -2
  8. package/dist/math-json.umd.js +2 -2
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/configuration-change.d.ts +1 -1
  11. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  12. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  13. package/dist/types/common/interruptible.d.ts +1 -1
  14. package/dist/types/common/one-of.d.ts +1 -1
  15. package/dist/types/common/signals.d.ts +1 -1
  16. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  17. package/dist/types/common/type/boxed-type.d.ts +1 -1
  18. package/dist/types/common/type/lexer.d.ts +1 -1
  19. package/dist/types/common/type/parse.d.ts +1 -1
  20. package/dist/types/common/type/parser.d.ts +1 -1
  21. package/dist/types/common/type/primitive.d.ts +1 -1
  22. package/dist/types/common/type/reduce.d.ts +1 -1
  23. package/dist/types/common/type/serialize.d.ts +1 -1
  24. package/dist/types/common/type/subtype.d.ts +1 -1
  25. package/dist/types/common/type/type-builder.d.ts +1 -1
  26. package/dist/types/common/type/types.d.ts +1 -1
  27. package/dist/types/common/type/utils.d.ts +1 -1
  28. package/dist/types/common/utils.d.ts +1 -1
  29. package/dist/types/compute-engine/assume.d.ts +1 -1
  30. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  33. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  34. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  35. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  36. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  37. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  38. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  39. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  40. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  41. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  42. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  43. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  44. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  46. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  47. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  50. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  51. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  53. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  54. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  71. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  72. package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
  73. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  74. package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +51 -0
  75. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +93 -0
  76. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  77. package/dist/types/compute-engine/compilation/types.d.ts +1 -1
  78. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  79. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  80. package/dist/types/compute-engine/global-types.d.ts +2 -2
  81. package/dist/types/compute-engine/index.d.ts +3 -1
  82. package/dist/types/compute-engine/interval/arithmetic.d.ts +56 -0
  83. package/dist/types/compute-engine/interval/comparison.d.ts +70 -0
  84. package/dist/types/compute-engine/interval/elementary.d.ts +100 -0
  85. package/dist/types/compute-engine/interval/index.d.ts +93 -0
  86. package/dist/types/compute-engine/interval/trigonometric.d.ts +105 -0
  87. package/dist/types/compute-engine/interval/types.d.ts +50 -0
  88. package/dist/types/compute-engine/interval/util.d.ts +99 -0
  89. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  90. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  91. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  92. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  93. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  94. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  95. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  96. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  97. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  98. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  99. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  100. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  101. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  102. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  103. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  104. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  105. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  106. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  107. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  108. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  109. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  110. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  111. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  112. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  113. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  114. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  115. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  116. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  117. package/dist/types/compute-engine/library/core.d.ts +1 -1
  118. package/dist/types/compute-engine/library/invisible-operator.d.ts +1 -1
  119. package/dist/types/compute-engine/library/library.d.ts +1 -1
  120. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  121. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  122. package/dist/types/compute-engine/library/logic-utils.d.ts +1 -1
  123. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  124. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  125. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  126. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  127. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  128. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  129. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  130. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  131. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  132. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  133. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  134. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  135. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  136. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  137. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  138. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  139. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  140. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  141. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  142. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  143. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  144. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  145. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  146. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  147. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  148. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  149. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  150. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  151. package/dist/types/compute-engine/oeis.d.ts +1 -1
  152. package/dist/types/compute-engine/sequence.d.ts +1 -1
  153. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  154. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  155. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  156. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  157. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  158. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  159. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  160. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  161. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  162. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  163. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  164. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  165. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  166. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  167. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  168. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  169. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  170. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  171. package/dist/types/compute-engine/types.d.ts +1 -1
  172. package/dist/types/compute-engine.d.ts +1 -1
  173. package/dist/types/math-json/symbols.d.ts +1 -1
  174. package/dist/types/math-json/types.d.ts +1 -1
  175. package/dist/types/math-json/utils.d.ts +1 -1
  176. package/dist/types/math-json.d.ts +2 -2
  177. package/package.json +1 -1
@@ -0,0 +1,93 @@
1
+ /* 0.35.0 */
2
+ * JavaScript interval arithmetic compilation target
3
+ *
4
+ * Compiles mathematical expressions to JavaScript code using interval arithmetic
5
+ * for reliable function evaluation with singularity detection.
6
+ *
7
+ * @module compilation/interval-javascript-target
8
+ */
9
+ import type { BoxedExpression } from '../global-types';
10
+ import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompiledExecutable } from './types';
11
+ /**
12
+ * JavaScript function that wraps compiled interval arithmetic code.
13
+ *
14
+ * Injects the _IA library and provides input conversion from various formats.
15
+ */
16
+ export declare class ComputeEngineIntervalFunction extends Function {
17
+ IA: {
18
+ ok: typeof import("../interval").ok;
19
+ point: typeof import("../interval").point;
20
+ containsExtremum: typeof import("../interval").containsExtremum;
21
+ unionResults: typeof import("../interval").unionResults;
22
+ mergeDomainClip: typeof import("../interval").mergeDomainClip;
23
+ isPoint: typeof import("../interval").isPoint;
24
+ containsZero: typeof import("../interval").containsZero;
25
+ isPositive: typeof import("../interval").isPositive;
26
+ isNegative: typeof import("../interval").isNegative;
27
+ isNonNegative: typeof import("../interval").isNonNegative;
28
+ isNonPositive: typeof import("../interval").isNonPositive;
29
+ width: typeof import("../interval").width;
30
+ midpoint: typeof import("../interval").midpoint;
31
+ getValue: typeof import("../interval").getValue;
32
+ unwrap: typeof import("../interval").unwrap;
33
+ unwrapOrPropagate: typeof import("../interval").unwrapOrPropagate;
34
+ add: typeof import("../interval").add;
35
+ sub: typeof import("../interval").sub;
36
+ mul: typeof import("../interval").mul;
37
+ div: typeof import("../interval").div;
38
+ negate: typeof import("../interval").negate;
39
+ sqrt: typeof import("../interval").sqrt;
40
+ square: typeof import("../interval").square;
41
+ pow: typeof import("../interval").pow;
42
+ powInterval: typeof import("../interval").powInterval;
43
+ exp: typeof import("../interval").exp;
44
+ ln: typeof import("../interval").ln;
45
+ log10: typeof import("../interval").log10;
46
+ log2: typeof import("../interval").log2;
47
+ abs: typeof import("../interval").abs;
48
+ floor: typeof import("../interval").floor;
49
+ ceil: typeof import("../interval").ceil;
50
+ round: typeof import("../interval").round;
51
+ min: typeof import("../interval").min;
52
+ max: typeof import("../interval").max;
53
+ mod: typeof import("../interval").mod;
54
+ sign: typeof import("../interval").sign;
55
+ sin: typeof import("../interval").sin;
56
+ cos: typeof import("../interval").cos;
57
+ tan: typeof import("../interval").tan;
58
+ cot: typeof import("../interval").cot;
59
+ sec: typeof import("../interval").sec;
60
+ csc: typeof import("../interval").csc;
61
+ asin: typeof import("../interval").asin;
62
+ acos: typeof import("../interval").acos;
63
+ atan: typeof import("../interval").atan;
64
+ atan2: typeof import("../interval").atan2;
65
+ sinh: typeof import("../interval").sinh;
66
+ cosh: typeof import("../interval").cosh;
67
+ tanh: typeof import("../interval").tanh;
68
+ asinh: typeof import("../interval").asinh;
69
+ acosh: typeof import("../interval").acosh;
70
+ atanh: typeof import("../interval").atanh;
71
+ less: typeof import("../interval").less;
72
+ lessEqual: typeof import("../interval").lessEqual;
73
+ greater: typeof import("../interval").greater;
74
+ greaterEqual: typeof import("../interval").greaterEqual;
75
+ equal: typeof import("../interval").equal;
76
+ notEqual: typeof import("../interval").notEqual;
77
+ and: typeof import("../interval").and;
78
+ or: typeof import("../interval").or;
79
+ not: typeof import("../interval").not;
80
+ piecewise: typeof import("../interval").piecewise;
81
+ clamp: typeof import("../interval").clamp;
82
+ };
83
+ constructor(body: string, preamble?: string);
84
+ }
85
+ /**
86
+ * Interval arithmetic JavaScript target implementation.
87
+ */
88
+ export declare class IntervalJavaScriptTarget implements LanguageTarget {
89
+ getOperators(): CompiledOperators;
90
+ getFunctions(): CompiledFunctions;
91
+ createTarget(options?: Partial<CompileTarget>): CompileTarget;
92
+ compileToExecutable(expr: BoxedExpression, options?: CompilationOptions): CompiledExecutable;
93
+ }
@@ -1,4 +1,4 @@
1
- /* 0.34.0 */
1
+ /* 0.35.0 */
2
2
  import { chop, factorial, gcd, lcm, limit } from '../numerics/numeric';
3
3
  import { gamma, gammaln } from '../numerics/special-functions';
4
4
  import { interquartileRange, kurtosis, mean, median, mode, populationStandardDeviation, populationVariance, quartiles, skewness, standardDeviation, variance } from '../numerics/statistics';
@@ -1,4 +1,4 @@
1
- /* 0.34.0 */
1
+ /* 0.35.0 */
2
2
  import type { BoxedExpression } from '../global-types';
3
3
  /**
4
4
  * Source code in the target language
@@ -1,4 +1,4 @@
1
- /* 0.34.0 */
1
+ /* 0.35.0 */
2
2
  /**
3
3
  * The default cost function, used to determine if a new expression is simpler
4
4
  * than the old one.
@@ -1,4 +1,4 @@
1
- /* 0.34.0 */
1
+ /* 0.35.0 */
2
2
  import type { BoxedDefinition, BoxedExpression, ComputeEngine, Scope } from './global-types';
3
3
  /***
4
4
  * ### THEORY OF OPERATIONS
@@ -1,4 +1,4 @@
1
- /* 0.34.0 */
1
+ /* 0.35.0 */
2
2
  import type { OneOf } from '../common/one-of';
3
3
  import type { Expression, MathJsonNumberObject, MathJsonStringObject, MathJsonFunctionObject, MathJsonSymbolObject, MathJsonSymbol, MathJsonDictionaryObject } from '../math-json';
4
4
  import type { Type, TypeReference, TypeResolver, TypeString } from '../common/type/types';
@@ -1899,7 +1899,7 @@ export interface SequenceDefinition {
1899
1899
  variable?: string;
1900
1900
  /**
1901
1901
  * Index variable names for multi-index sequences.
1902
- * Example: `['n', 'k']` for Pascal's triangle P_{n,k}
1902
+ * Example: `['n', 'k']` for Pascal's triangle `P\_{n,k}`
1903
1903
  *
1904
1904
  * If provided, this takes precedence over `variable`.
1905
1905
  */
@@ -1,4 +1,4 @@
1
- /* 0.34.0 */
1
+ /* 0.35.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { Type, TypeResolver, TypeString } from '../common/type/types';
4
4
  import { BoxedType } from '../common/type/boxed-type';
@@ -19,6 +19,8 @@ export { factor, factorPerfectSquare, factorDifferenceOfSquares, factorQuadratic
19
19
  export type { CompileTarget, CompiledOperators, CompiledFunctions, CompilationOptions, CompiledExecutable, LanguageTarget, TargetSource, CompiledFunction, } from './compilation/types';
20
20
  export { JavaScriptTarget } from './compilation/javascript-target';
21
21
  export { GLSLTarget } from './compilation/glsl-target';
22
+ export { IntervalJavaScriptTarget } from './compilation/interval-javascript-target';
23
+ export { IntervalGLSLTarget } from './compilation/interval-glsl-target';
22
24
  export { BaseCompiler } from './compilation/base-compiler';
23
25
  import type { LanguageTarget } from './compilation/types';
24
26
  /**
@@ -0,0 +1,56 @@
1
+ /* 0.35.0 */
2
+ * Basic interval arithmetic operations
3
+ *
4
+ * @module interval/arithmetic
5
+ */
6
+ import type { Interval, IntervalResult } from './types';
7
+ /**
8
+ * Add two intervals (or IntervalResults).
9
+ *
10
+ * [a, b] + [c, d] = [a + c, b + d]
11
+ *
12
+ * Addition is always defined and produces a valid interval.
13
+ * If inputs are IntervalResults, propagates errors (empty, entire, singular).
14
+ */
15
+ export declare function add(a: Interval | IntervalResult, b: Interval | IntervalResult): IntervalResult;
16
+ /**
17
+ * Subtract two intervals (or IntervalResults).
18
+ *
19
+ * [a, b] - [c, d] = [a - d, b - c]
20
+ *
21
+ * Subtraction is always defined and produces a valid interval.
22
+ * If inputs are IntervalResults, propagates errors (empty, entire, singular).
23
+ */
24
+ export declare function sub(a: Interval | IntervalResult, b: Interval | IntervalResult): IntervalResult;
25
+ /**
26
+ * Negate an interval (or IntervalResult).
27
+ *
28
+ * -[a, b] = [-b, -a]
29
+ */
30
+ export declare function negate(x: Interval | IntervalResult): IntervalResult;
31
+ /**
32
+ * Internal multiplication helper that returns plain Interval.
33
+ *
34
+ * Used by div() and other operations that need plain interval results.
35
+ */
36
+ export declare function _mul(a: Interval, b: Interval): Interval;
37
+ /**
38
+ * Multiply two intervals (or IntervalResults).
39
+ *
40
+ * All four endpoint products are computed and the result
41
+ * spans from minimum to maximum.
42
+ * If inputs are IntervalResults, propagates errors (empty, entire, singular).
43
+ */
44
+ export declare function mul(a: Interval | IntervalResult, b: Interval | IntervalResult): IntervalResult;
45
+ /**
46
+ * Divide two intervals (or IntervalResults).
47
+ *
48
+ * Division by an interval containing zero produces special results:
49
+ * - If divisor strictly contains 0 (not just touching): singular
50
+ * - If divisor is exactly [0, 0]: empty
51
+ * - If divisor touches 0 at one bound: partial result
52
+ *
53
+ * This is the key operation for singularity detection in plotting.
54
+ * If inputs are IntervalResults, propagates errors (empty, entire, singular).
55
+ */
56
+ export declare function div(a: Interval | IntervalResult, b: Interval | IntervalResult): IntervalResult;
@@ -0,0 +1,70 @@
1
+ /* 0.35.0 */
2
+ * Comparison and conditional interval operations
3
+ *
4
+ * @module interval/comparison
5
+ */
6
+ import type { Interval, IntervalResult, BoolInterval } from './types';
7
+ /**
8
+ * Less than comparison for intervals.
9
+ *
10
+ * Returns:
11
+ * - 'true' if a is entirely less than b (a.hi < b.lo)
12
+ * - 'false' if a is entirely greater than or equal to b (a.lo >= b.hi)
13
+ * - 'maybe' if intervals overlap
14
+ */
15
+ export declare function less(a: Interval, b: Interval): BoolInterval;
16
+ /**
17
+ * Less than or equal comparison for intervals.
18
+ */
19
+ export declare function lessEqual(a: Interval, b: Interval): BoolInterval;
20
+ /**
21
+ * Greater than comparison for intervals.
22
+ */
23
+ export declare function greater(a: Interval, b: Interval): BoolInterval;
24
+ /**
25
+ * Greater than or equal comparison for intervals.
26
+ */
27
+ export declare function greaterEqual(a: Interval, b: Interval): BoolInterval;
28
+ /**
29
+ * Equality comparison for intervals.
30
+ *
31
+ * Returns:
32
+ * - 'true' only if both are point intervals with same value
33
+ * - 'false' if intervals don't overlap
34
+ * - 'maybe' if intervals overlap
35
+ */
36
+ export declare function equal(a: Interval, b: Interval): BoolInterval;
37
+ /**
38
+ * Not equal comparison for intervals.
39
+ */
40
+ export declare function notEqual(a: Interval, b: Interval): BoolInterval;
41
+ /**
42
+ * Logical AND for boolean intervals.
43
+ */
44
+ export declare function and(a: BoolInterval, b: BoolInterval): BoolInterval;
45
+ /**
46
+ * Logical OR for boolean intervals.
47
+ */
48
+ export declare function or(a: BoolInterval, b: BoolInterval): BoolInterval;
49
+ /**
50
+ * Logical NOT for boolean intervals.
51
+ */
52
+ export declare function not(a: BoolInterval): BoolInterval;
53
+ /**
54
+ * Piecewise (conditional) evaluation for intervals.
55
+ *
56
+ * When the condition is indeterminate ('maybe'), both branches
57
+ * are evaluated and the union (hull) is returned.
58
+ *
59
+ * @param x - Input interval
60
+ * @param condition - Function that evaluates the condition
61
+ * @param trueBranch - Function for when condition is true
62
+ * @param falseBranch - Function for when condition is false
63
+ */
64
+ export declare function piecewise(x: Interval, condition: (x: Interval) => BoolInterval, trueBranch: (x: Interval) => IntervalResult, falseBranch: (x: Interval) => IntervalResult): IntervalResult;
65
+ /**
66
+ * Clamp an interval to a range.
67
+ *
68
+ * clamp(x, lo, hi) returns x clamped to [lo, hi].
69
+ */
70
+ export declare function clamp(x: Interval, lo: Interval, hi: Interval): IntervalResult;
@@ -0,0 +1,100 @@
1
+ /* 0.35.0 */
2
+ * Elementary interval functions (sqrt, pow, exp, ln, abs, floor, ceil, min, max, mod)
3
+ *
4
+ * @module interval/elementary
5
+ */
6
+ import type { Interval, IntervalResult } from './types';
7
+ /**
8
+ * Square root of an interval (or IntervalResult).
9
+ *
10
+ * - Entirely negative: empty (no real values)
11
+ * - Entirely non-negative: straightforward monotonic
12
+ * - Straddles zero: partial result with lower bound clipped
13
+ */
14
+ export declare function sqrt(x: Interval | IntervalResult): IntervalResult;
15
+ /**
16
+ * Square an interval (or IntervalResult).
17
+ *
18
+ * Need to handle sign change at 0 since x^2 is not monotonic.
19
+ */
20
+ export declare function square(x: Interval | IntervalResult): IntervalResult;
21
+ /**
22
+ * Power function for intervals.
23
+ *
24
+ * Handles integer and fractional exponents differently:
25
+ * - Integer exponents: consider sign and parity
26
+ * - Negative integer: x^(-n) = 1/x^n, singular if base contains 0
27
+ * - Fractional: requires non-negative base for real result
28
+ */
29
+ export declare function pow(base: Interval, exp: number): IntervalResult;
30
+ /**
31
+ * Interval power where the exponent is also an interval.
32
+ *
33
+ * For simplicity, we evaluate at the four corners and take the hull.
34
+ * This requires base to be positive for real results.
35
+ */
36
+ export declare function powInterval(base: Interval, exp: Interval): IntervalResult;
37
+ /**
38
+ * Exponential function (e^x).
39
+ *
40
+ * Always valid, monotonically increasing.
41
+ */
42
+ export declare function exp(x: Interval | IntervalResult): IntervalResult;
43
+ /**
44
+ * Natural logarithm.
45
+ *
46
+ * Domain: positive reals (x > 0)
47
+ * - Entirely non-positive: empty
48
+ * - Entirely positive: straightforward monotonic
49
+ * - Contains/touches zero: partial with -Infinity lower bound
50
+ */
51
+ export declare function ln(x: Interval): IntervalResult;
52
+ /**
53
+ * Base-10 logarithm.
54
+ */
55
+ export declare function log10(x: Interval): IntervalResult;
56
+ /**
57
+ * Base-2 logarithm.
58
+ */
59
+ export declare function log2(x: Interval): IntervalResult;
60
+ /**
61
+ * Absolute value of an interval.
62
+ */
63
+ export declare function abs(x: Interval): IntervalResult;
64
+ /**
65
+ * Floor function (greatest integer <= x).
66
+ *
67
+ * Note: Produces step-function discontinuities when floor(x.lo) != floor(x.hi).
68
+ */
69
+ export declare function floor(x: Interval): IntervalResult;
70
+ /**
71
+ * Ceiling function (least integer >= x).
72
+ *
73
+ * Note: Produces step-function discontinuities when ceil(x.lo) != ceil(x.hi).
74
+ */
75
+ export declare function ceil(x: Interval): IntervalResult;
76
+ /**
77
+ * Round to nearest integer.
78
+ */
79
+ export declare function round(x: Interval): IntervalResult;
80
+ /**
81
+ * Minimum of two intervals.
82
+ */
83
+ export declare function min(a: Interval, b: Interval): IntervalResult;
84
+ /**
85
+ * Maximum of two intervals.
86
+ */
87
+ export declare function max(a: Interval, b: Interval): IntervalResult;
88
+ /**
89
+ * Modulo (remainder) operation.
90
+ *
91
+ * Has discontinuities and is complex with interval divisor.
92
+ * Conservative approach: if interval spans a period, return [0, |b|).
93
+ */
94
+ export declare function mod(a: Interval, b: Interval): IntervalResult;
95
+ /**
96
+ * Sign function.
97
+ *
98
+ * Returns -1, 0, or 1 depending on the sign.
99
+ */
100
+ export declare function sign(x: Interval): IntervalResult;
@@ -0,0 +1,93 @@
1
+ /* 0.35.0 */
2
+ * Interval arithmetic library for reliable function evaluation
3
+ *
4
+ * This module provides interval versions of mathematical operations
5
+ * that return guaranteed enclosures of the true result. It's designed
6
+ * for use in plotting applications to detect singularities and enable
7
+ * adaptive sampling.
8
+ *
9
+ * @module interval
10
+ */
11
+ import { ok as _ok, point as _point, containsExtremum as _containsExtremum, unionResults as _unionResults, mergeDomainClip as _mergeDomainClip, isPoint as _isPoint, containsZero as _containsZero, isPositive as _isPositive, isNegative as _isNegative, isNonNegative as _isNonNegative, isNonPositive as _isNonPositive, width as _width, midpoint as _midpoint, getValue as _getValue, unwrap as _unwrap, unwrapOrPropagate as _unwrapOrPropagate } from './util';
12
+ import { add as _add, sub as _sub, mul as _mul, div as _div, negate as _negate } from './arithmetic';
13
+ import { sqrt as _sqrt, square as _square, pow as _pow, powInterval as _powInterval, exp as _exp, ln as _ln, log10 as _log10, log2 as _log2, abs as _abs, floor as _floor, ceil as _ceil, round as _round, min as _min, max as _max, mod as _mod, sign as _sign } from './elementary';
14
+ import { sin as _sin, cos as _cos, tan as _tan, cot as _cot, sec as _sec, csc as _csc, asin as _asin, acos as _acos, atan as _atan, atan2 as _atan2, sinh as _sinh, cosh as _cosh, tanh as _tanh, asinh as _asinh, acosh as _acosh, atanh as _atanh } from './trigonometric';
15
+ import { less as _less, lessEqual as _lessEqual, greater as _greater, greaterEqual as _greaterEqual, equal as _equal, notEqual as _notEqual, and as _and, or as _or, not as _not, piecewise as _piecewise, clamp as _clamp } from './comparison';
16
+ export type { Interval, IntervalResult, BoolInterval } from './types';
17
+ export { ok, point, containsExtremum, unionResults, mergeDomainClip, isPoint, containsZero, isPositive, isNegative, isNonNegative, isNonPositive, width, midpoint, getValue, unwrap, unwrapOrPropagate, } from './util';
18
+ export { add, sub, mul, div, negate, _mul } from './arithmetic';
19
+ export { sqrt, square, pow, powInterval, exp, ln, log10, log2, abs, floor, ceil, round, min, max, mod, sign, } from './elementary';
20
+ export { sin, cos, tan, cot, sec, csc, asin, acos, atan, atan2, sinh, cosh, tanh, asinh, acosh, atanh, } from './trigonometric';
21
+ export { less, lessEqual, greater, greaterEqual, equal, notEqual, and, or, not, piecewise, clamp, } from './comparison';
22
+ /**
23
+ * The complete interval arithmetic library object.
24
+ *
25
+ * This is the runtime library injected as `_IA` in compiled
26
+ * interval arithmetic functions.
27
+ */
28
+ export declare const IntervalArithmetic: {
29
+ ok: typeof _ok;
30
+ point: typeof _point;
31
+ containsExtremum: typeof _containsExtremum;
32
+ unionResults: typeof _unionResults;
33
+ mergeDomainClip: typeof _mergeDomainClip;
34
+ isPoint: typeof _isPoint;
35
+ containsZero: typeof _containsZero;
36
+ isPositive: typeof _isPositive;
37
+ isNegative: typeof _isNegative;
38
+ isNonNegative: typeof _isNonNegative;
39
+ isNonPositive: typeof _isNonPositive;
40
+ width: typeof _width;
41
+ midpoint: typeof _midpoint;
42
+ getValue: typeof _getValue;
43
+ unwrap: typeof _unwrap;
44
+ unwrapOrPropagate: typeof _unwrapOrPropagate;
45
+ add: typeof _add;
46
+ sub: typeof _sub;
47
+ mul: typeof _mul;
48
+ div: typeof _div;
49
+ negate: typeof _negate;
50
+ sqrt: typeof _sqrt;
51
+ square: typeof _square;
52
+ pow: typeof _pow;
53
+ powInterval: typeof _powInterval;
54
+ exp: typeof _exp;
55
+ ln: typeof _ln;
56
+ log10: typeof _log10;
57
+ log2: typeof _log2;
58
+ abs: typeof _abs;
59
+ floor: typeof _floor;
60
+ ceil: typeof _ceil;
61
+ round: typeof _round;
62
+ min: typeof _min;
63
+ max: typeof _max;
64
+ mod: typeof _mod;
65
+ sign: typeof _sign;
66
+ sin: typeof _sin;
67
+ cos: typeof _cos;
68
+ tan: typeof _tan;
69
+ cot: typeof _cot;
70
+ sec: typeof _sec;
71
+ csc: typeof _csc;
72
+ asin: typeof _asin;
73
+ acos: typeof _acos;
74
+ atan: typeof _atan;
75
+ atan2: typeof _atan2;
76
+ sinh: typeof _sinh;
77
+ cosh: typeof _cosh;
78
+ tanh: typeof _tanh;
79
+ asinh: typeof _asinh;
80
+ acosh: typeof _acosh;
81
+ atanh: typeof _atanh;
82
+ less: typeof _less;
83
+ lessEqual: typeof _lessEqual;
84
+ greater: typeof _greater;
85
+ greaterEqual: typeof _greaterEqual;
86
+ equal: typeof _equal;
87
+ notEqual: typeof _notEqual;
88
+ and: typeof _and;
89
+ or: typeof _or;
90
+ not: typeof _not;
91
+ piecewise: typeof _piecewise;
92
+ clamp: typeof _clamp;
93
+ };
@@ -0,0 +1,105 @@
1
+ /* 0.35.0 */
2
+ * Trigonometric interval functions
3
+ *
4
+ * @module interval/trigonometric
5
+ */
6
+ import type { Interval, IntervalResult } from './types';
7
+ /**
8
+ * Sine of an interval.
9
+ *
10
+ * Sin is bounded [-1, 1] and periodic with extrema at pi/2 + n*pi.
11
+ */
12
+ export declare function sin(x: Interval): IntervalResult;
13
+ /**
14
+ * Cosine of an interval.
15
+ *
16
+ * Cos is bounded [-1, 1] and periodic with extrema at n*pi.
17
+ */
18
+ export declare function cos(x: Interval): IntervalResult;
19
+ /**
20
+ * Tangent of an interval.
21
+ *
22
+ * Has singularities at pi/2 + n*pi. Within a single branch,
23
+ * tan is monotonically increasing.
24
+ */
25
+ export declare function tan(x: Interval): IntervalResult;
26
+ /**
27
+ * Cotangent of an interval.
28
+ *
29
+ * cot(x) = cos(x)/sin(x), has singularities at n*pi.
30
+ */
31
+ export declare function cot(x: Interval): IntervalResult;
32
+ /**
33
+ * Secant of an interval.
34
+ *
35
+ * sec(x) = 1/cos(x), has singularities at pi/2 + n*pi.
36
+ */
37
+ export declare function sec(x: Interval): IntervalResult;
38
+ /**
39
+ * Cosecant of an interval.
40
+ *
41
+ * csc(x) = 1/sin(x), has singularities at n*pi.
42
+ */
43
+ export declare function csc(x: Interval): IntervalResult;
44
+ /**
45
+ * Arc sine (inverse sine).
46
+ *
47
+ * Domain: [-1, 1], Range: [-pi/2, pi/2]
48
+ */
49
+ export declare function asin(x: Interval): IntervalResult;
50
+ /**
51
+ * Arc cosine (inverse cosine).
52
+ *
53
+ * Domain: [-1, 1], Range: [0, pi]
54
+ */
55
+ export declare function acos(x: Interval): IntervalResult;
56
+ /**
57
+ * Arc tangent (inverse tangent).
58
+ *
59
+ * Domain: all reals, Range: (-pi/2, pi/2)
60
+ * Monotonically increasing.
61
+ */
62
+ export declare function atan(x: Interval): IntervalResult;
63
+ /**
64
+ * Two-argument arc tangent.
65
+ *
66
+ * atan2(y, x) gives the angle of the point (x, y).
67
+ * Handles all quadrants correctly.
68
+ */
69
+ export declare function atan2(y: Interval, x: Interval): IntervalResult;
70
+ /**
71
+ * Hyperbolic sine.
72
+ *
73
+ * Domain: all reals, monotonically increasing.
74
+ */
75
+ export declare function sinh(x: Interval): IntervalResult;
76
+ /**
77
+ * Hyperbolic cosine.
78
+ *
79
+ * Domain: all reals, minimum at x=0.
80
+ */
81
+ export declare function cosh(x: Interval): IntervalResult;
82
+ /**
83
+ * Hyperbolic tangent.
84
+ *
85
+ * Domain: all reals, Range: (-1, 1), monotonically increasing.
86
+ */
87
+ export declare function tanh(x: Interval): IntervalResult;
88
+ /**
89
+ * Inverse hyperbolic sine.
90
+ *
91
+ * Domain: all reals, monotonically increasing.
92
+ */
93
+ export declare function asinh(x: Interval): IntervalResult;
94
+ /**
95
+ * Inverse hyperbolic cosine.
96
+ *
97
+ * Domain: [1, +Infinity)
98
+ */
99
+ export declare function acosh(x: Interval): IntervalResult;
100
+ /**
101
+ * Inverse hyperbolic tangent.
102
+ *
103
+ * Domain: (-1, 1)
104
+ */
105
+ export declare function atanh(x: Interval): IntervalResult;
@@ -0,0 +1,50 @@
1
+ /* 0.35.0 */
2
+ * Interval arithmetic types for reliable function evaluation
3
+ *
4
+ * @module interval/types
5
+ */
6
+ /**
7
+ * A closed interval [lo, hi] representing a range of real numbers.
8
+ *
9
+ * Bounds may be -Infinity or +Infinity for unbounded ranges.
10
+ * Invariant: lo <= hi (empty intervals are represented differently)
11
+ */
12
+ export interface Interval {
13
+ /** Lower bound (toward -Infinity), may be -Infinity */
14
+ lo: number;
15
+ /** Upper bound (toward +Infinity), may be +Infinity */
16
+ hi: number;
17
+ }
18
+ /**
19
+ * Result of an interval operation.
20
+ *
21
+ * Operations return structured results that preserve information for plotting:
22
+ * - `interval`: Normal computation with valid interval
23
+ * - `empty`: No valid values (e.g., ln([-2, -1]))
24
+ * - `entire`: Result spans all reals (-Infinity, +Infinity)
25
+ * - `singular`: Contains pole/asymptote, needs subdivision
26
+ * - `partial`: Valid interval with domain clipping info
27
+ */
28
+ export type IntervalResult = {
29
+ kind: 'interval';
30
+ value: Interval;
31
+ } | {
32
+ kind: 'empty';
33
+ } | {
34
+ kind: 'entire';
35
+ } | {
36
+ kind: 'singular';
37
+ at?: number;
38
+ } | {
39
+ kind: 'partial';
40
+ value: Interval;
41
+ domainClipped: 'lo' | 'hi' | 'both';
42
+ };
43
+ /**
44
+ * Three-valued logic for interval comparisons.
45
+ *
46
+ * - `true`: Definitely true for all values in the intervals
47
+ * - `false`: Definitely false for all values in the intervals
48
+ * - `maybe`: Indeterminate - intervals overlap
49
+ */
50
+ export type BoolInterval = 'true' | 'false' | 'maybe';