@mark1russell7/interval 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +38 -2
- package/build/index.d.ts +419 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +828 -0
- package/build/index.js.map +1 -0
- package/build/rolldown-runtime-D3KUYPsf.js +12 -0
- package/package.json +64 -3
- package/src/ball.ts +377 -0
- package/src/index.ts +13 -0
- package/src/interval.ts +376 -0
- package/src/rounding.ts +70 -0
package/build/index.js
ADDED
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.js";
|
|
2
|
+
// src/interval.ts
|
|
3
|
+
var interval_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
WHOLE: () => WHOLE,
|
|
5
|
+
add: () => add$1,
|
|
6
|
+
div: () => div$1,
|
|
7
|
+
eq: () => eq$1,
|
|
8
|
+
le: () => le$1,
|
|
9
|
+
lt: () => lt$1,
|
|
10
|
+
max: () => max$1,
|
|
11
|
+
min: () => min$1,
|
|
12
|
+
mul: () => mul$1,
|
|
13
|
+
neg: () => neg$1,
|
|
14
|
+
nextDown: () => nextDown,
|
|
15
|
+
nextUp: () => nextUp,
|
|
16
|
+
pow: () => pow$1,
|
|
17
|
+
productError: () => productError,
|
|
18
|
+
quotientIsExact: () => quotientIsExact,
|
|
19
|
+
root: () => root$1,
|
|
20
|
+
sub: () => sub$1,
|
|
21
|
+
sumError: () => sumError
|
|
22
|
+
});
|
|
23
|
+
/** The interval that contains every real. */
|
|
24
|
+
const WHOLE = [-Infinity, Infinity];
|
|
25
|
+
const view = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
26
|
+
/**
|
|
27
|
+
* This function gives the next float above a value.
|
|
28
|
+
*
|
|
29
|
+
* @param x - The value.
|
|
30
|
+
* @returns The smallest float that is larger than `x`. `Infinity` stays `Infinity`, and `NaN` stays `NaN`.
|
|
31
|
+
*/
|
|
32
|
+
function nextUp(x) {
|
|
33
|
+
if (Number.isNaN(x) || x === Infinity) return x;
|
|
34
|
+
if (x === 0) return Number.MIN_VALUE;
|
|
35
|
+
view.setFloat64(0, x);
|
|
36
|
+
const bits = view.getBigUint64(0);
|
|
37
|
+
view.setBigUint64(0, x > 0 ? bits + 1n : bits - 1n);
|
|
38
|
+
return view.getFloat64(0);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* This function gives the next float below a value.
|
|
42
|
+
*
|
|
43
|
+
* @param x - The value.
|
|
44
|
+
* @returns The largest float that is smaller than `x`. `-Infinity` stays `-Infinity`, and `NaN` stays `NaN`.
|
|
45
|
+
*/
|
|
46
|
+
function nextDown(x) {
|
|
47
|
+
return -nextUp(-x);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* This function gives the exact error of a float sum. It uses the error term of `TwoSum` (Knuth).
|
|
51
|
+
*
|
|
52
|
+
* @param a - The first value.
|
|
53
|
+
* @param b - The second value.
|
|
54
|
+
* @param s - The float sum `a + b`.
|
|
55
|
+
* @returns The float `e` with `a + b = s + e` exactly, or `NaN` when `s` is not finite and the term is not reliable.
|
|
56
|
+
*/
|
|
57
|
+
function sumError(a, b, s) {
|
|
58
|
+
if (!Number.isFinite(s)) return NaN;
|
|
59
|
+
const bb = s - a;
|
|
60
|
+
return a - (s - bb) + (b - bb);
|
|
61
|
+
}
|
|
62
|
+
const SPLIT = 134217729;
|
|
63
|
+
/**
|
|
64
|
+
* This function gives the exact error of a float product. It uses the error term of `TwoProduct` (Dekker). Near
|
|
65
|
+
* overflow or underflow the term is not reliable, so the function then gives `NaN`.
|
|
66
|
+
*
|
|
67
|
+
* @param a - The first value.
|
|
68
|
+
* @param b - The second value.
|
|
69
|
+
* @param p - The float product `a * b`.
|
|
70
|
+
* @returns The float `e` with `a * b = p + e` exactly, or `NaN` when the term is not reliable.
|
|
71
|
+
*/
|
|
72
|
+
function productError(a, b, p) {
|
|
73
|
+
if (a === 0 || b === 0) return 0;
|
|
74
|
+
const m = Math.abs(p);
|
|
75
|
+
if (!(m > 2 ** -900 && m < 2 ** 990) || Math.abs(a) > 2 ** 990 || Math.abs(b) > 2 ** 990) return NaN;
|
|
76
|
+
const ca = SPLIT * a;
|
|
77
|
+
const ah = ca - (ca - a);
|
|
78
|
+
const al = a - ah;
|
|
79
|
+
const cb = SPLIT * b;
|
|
80
|
+
const bh = cb - (cb - b);
|
|
81
|
+
const bl = b - bh;
|
|
82
|
+
return al * bl - (p - ah * bh - al * bh - ah * bl);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* This function gives a lower bound of `v + e` for a float `v` and its exact error `e`. An exact `v` is the bound.
|
|
86
|
+
* Else the bound is one float lower. Round to nearest puts `v + e` within half a step of `v`, so one step is enough.
|
|
87
|
+
* An error of `NaN` is not known, and it gives the step. The sign of `e` is not used, so that each bound of A1 stays
|
|
88
|
+
* the same.
|
|
89
|
+
*/
|
|
90
|
+
const below = (v, e) => e === 0 ? v : nextDown(v);
|
|
91
|
+
/** This function gives an upper bound of `v + e`, with the rule of `below`. */
|
|
92
|
+
const above = (v, e) => e === 0 ? v : nextUp(v);
|
|
93
|
+
/**
|
|
94
|
+
* This function gives the sum of two intervals, rounded outward.
|
|
95
|
+
*
|
|
96
|
+
* @param x - The first interval.
|
|
97
|
+
* @param y - The second interval.
|
|
98
|
+
* @returns An interval that contains each sum of a point of `x` and a point of `y`.
|
|
99
|
+
*/
|
|
100
|
+
function add$1(x, y) {
|
|
101
|
+
if (x === null || y === null) return null;
|
|
102
|
+
const lo = x[0] + y[0];
|
|
103
|
+
const hi = x[1] + y[1];
|
|
104
|
+
return [below(lo, sumError(x[0], y[0], lo)), above(hi, sumError(x[1], y[1], hi))];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* This function gives the negation of an interval. It is exact.
|
|
108
|
+
*
|
|
109
|
+
* @param x - The interval.
|
|
110
|
+
* @returns The interval of the negated points.
|
|
111
|
+
*/
|
|
112
|
+
function neg$1(x) {
|
|
113
|
+
return x === null ? null : [-x[1], -x[0]];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* This function gives the difference of two intervals, rounded outward.
|
|
117
|
+
*
|
|
118
|
+
* @param x - The first interval.
|
|
119
|
+
* @param y - The interval to subtract.
|
|
120
|
+
* @returns An interval that contains each difference of a point of `x` and a point of `y`.
|
|
121
|
+
*/
|
|
122
|
+
function sub$1(x, y) {
|
|
123
|
+
return add$1(x, neg$1(y));
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* This function gives one float product for an interval bound. A zero times an infinite bound is zero, because the
|
|
127
|
+
* infinite bound stands for large reals, not for infinity.
|
|
128
|
+
*/
|
|
129
|
+
function boundProduct(a, b) {
|
|
130
|
+
return a === 0 || b === 0 ? 0 : a * b;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* This function gives the product of two intervals, rounded outward.
|
|
134
|
+
*
|
|
135
|
+
* @param x - The first interval.
|
|
136
|
+
* @param y - The second interval.
|
|
137
|
+
* @returns An interval that contains each product of a point of `x` and a point of `y`.
|
|
138
|
+
*/
|
|
139
|
+
function mul$1(x, y) {
|
|
140
|
+
if (x === null || y === null) return null;
|
|
141
|
+
let lo = Infinity;
|
|
142
|
+
let hi = -Infinity;
|
|
143
|
+
for (const a of x) for (const b of y) {
|
|
144
|
+
const p = boundProduct(a, b);
|
|
145
|
+
const e = productError(a, b, p);
|
|
146
|
+
lo = Math.min(lo, below(p, e));
|
|
147
|
+
hi = Math.max(hi, above(p, e));
|
|
148
|
+
}
|
|
149
|
+
return [lo, hi];
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* This function tells if a float quotient is exact: the product `q * b` is exact and is `a`.
|
|
153
|
+
*
|
|
154
|
+
* @param a - The dividend.
|
|
155
|
+
* @param b - The divisor.
|
|
156
|
+
* @param q - The float quotient `a / b`.
|
|
157
|
+
* @returns `true` when `q` is the exact quotient.
|
|
158
|
+
*/
|
|
159
|
+
function quotientIsExact(a, b, q) {
|
|
160
|
+
const p = q * b;
|
|
161
|
+
return p === a && productError(q, b, p) === 0;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* This function gives the quotient of two intervals, rounded outward. A divisor interval that contains zero gives the
|
|
165
|
+
* whole line, and the point zero gives the empty interval. A quotient of two finite bounds moves one step outward on
|
|
166
|
+
* each side when it is not exact. A quotient with an infinite bound is `0` or infinite, and it is a bound as it is.
|
|
167
|
+
*
|
|
168
|
+
* @param x - The dividend.
|
|
169
|
+
* @param y - The divisor.
|
|
170
|
+
* @returns An interval that contains each quotient of a point of `x` and a nonzero point of `y`.
|
|
171
|
+
*/
|
|
172
|
+
function div$1(x, y) {
|
|
173
|
+
if (x === null || y === null) return null;
|
|
174
|
+
if (y[0] === 0 && y[1] === 0) return null;
|
|
175
|
+
if (y[0] <= 0 && y[1] >= 0) return WHOLE;
|
|
176
|
+
let lo = Infinity;
|
|
177
|
+
let hi = -Infinity;
|
|
178
|
+
for (const a of x) for (const b of y) if (Number.isFinite(a) && Number.isFinite(b)) {
|
|
179
|
+
const q = a / b;
|
|
180
|
+
const exact = quotientIsExact(a, b, q);
|
|
181
|
+
lo = Math.min(lo, exact ? q : nextDown(q));
|
|
182
|
+
hi = Math.max(hi, exact ? q : nextUp(q));
|
|
183
|
+
} else {
|
|
184
|
+
const q = Number.isFinite(b) ? a / b : Number.isFinite(a) ? 0 : a > 0 === b > 0 ? Infinity : -Infinity;
|
|
185
|
+
lo = Math.min(lo, q);
|
|
186
|
+
hi = Math.max(hi, q);
|
|
187
|
+
}
|
|
188
|
+
return [lo, hi];
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* This function gives the square of an interval, rounded outward. It is tighter than `mul(x, x)` for an interval
|
|
192
|
+
* that contains zero.
|
|
193
|
+
*/
|
|
194
|
+
function square(x) {
|
|
195
|
+
const [a, b] = x;
|
|
196
|
+
if (a >= 0) return mul$1(x, x);
|
|
197
|
+
if (b <= 0) return mul$1(neg$1(x), neg$1(x));
|
|
198
|
+
const m = Math.max(-a, b);
|
|
199
|
+
const top = mul$1([m, m], [m, m]);
|
|
200
|
+
return top === null ? null : [0, top[1]];
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* This function gives an interval to a whole power, rounded outward. The power zero gives the point one, also for a
|
|
204
|
+
* base of zero. A negative power is the reciprocal of the positive power.
|
|
205
|
+
*
|
|
206
|
+
* @param x - The base.
|
|
207
|
+
* @param n - The exponent. It must be a whole number.
|
|
208
|
+
* @returns An interval that contains each power of a point of `x`.
|
|
209
|
+
*/
|
|
210
|
+
function pow$1(x, n) {
|
|
211
|
+
if (x === null) return null;
|
|
212
|
+
if (!Number.isInteger(n)) throw new RangeError(`pow needs a whole exponent, not ${n}.`);
|
|
213
|
+
if (n < 0) return div$1([1, 1], pow$1(x, -n));
|
|
214
|
+
let result = [1, 1];
|
|
215
|
+
let base = x;
|
|
216
|
+
for (let k = n; k > 0; k = Math.floor(k / 2)) {
|
|
217
|
+
if (k % 2 === 1) result = mul$1(result, base);
|
|
218
|
+
if (k > 1 && base !== null) base = square(base);
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
/** This function tells if `r * r` is exactly `a`. */
|
|
223
|
+
function isSquareOf(r, a) {
|
|
224
|
+
const p = r * r;
|
|
225
|
+
return p === a && productError(r, r, p) === 0;
|
|
226
|
+
}
|
|
227
|
+
/** This function gives the smallest power of the interval `[z, z]`, rounded downward. */
|
|
228
|
+
function powLow(z, k) {
|
|
229
|
+
const p = pow$1([z, z], k);
|
|
230
|
+
return p === null ? NaN : p[0];
|
|
231
|
+
}
|
|
232
|
+
/** This function gives the largest power of the interval `[z, z]`, rounded upward. */
|
|
233
|
+
function powHigh(z, k) {
|
|
234
|
+
const p = pow$1([z, z], k);
|
|
235
|
+
return p === null ? NaN : p[1];
|
|
236
|
+
}
|
|
237
|
+
const rootOf = (m, k) => k === 3 ? Math.cbrt(m) : Math.pow(m, 1 / k);
|
|
238
|
+
/** The most steps of the search of `rootUp` and `rootDown`. After them, each function gives its trivial bound. */
|
|
239
|
+
const STEPS = 64;
|
|
240
|
+
/**
|
|
241
|
+
* This function gives a float `z >= 0` with `z^k >= m`, for `m >= 0`. The check uses the outward powers of `pow`.
|
|
242
|
+
* Near overflow the check cannot pass, and the function gives `Infinity`.
|
|
243
|
+
*/
|
|
244
|
+
function rootUp(m, k) {
|
|
245
|
+
let z = rootOf(m, k);
|
|
246
|
+
for (let i = 0; z < Infinity && i < STEPS; i++) {
|
|
247
|
+
if (powLow(z, k) >= m) return z;
|
|
248
|
+
z = i < 8 ? nextUp(z) : z * (1 + 2 ** (i - 60));
|
|
249
|
+
}
|
|
250
|
+
return Infinity;
|
|
251
|
+
}
|
|
252
|
+
/** This function gives a float `z >= 0` with `z^k <= m`, for `m >= 0`. After `STEPS` steps it gives `0`. */
|
|
253
|
+
function rootDown(m, k) {
|
|
254
|
+
let z = rootOf(m, k);
|
|
255
|
+
if (m === Infinity) return z;
|
|
256
|
+
for (let i = 0; z > 0 && i < STEPS; i++) {
|
|
257
|
+
if (powHigh(z, k) <= m) return z;
|
|
258
|
+
z = i < 8 ? nextDown(z) : z * (1 - 2 ** (i - 60));
|
|
259
|
+
}
|
|
260
|
+
return 0;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* This function gives the root of an interval, rounded outward. The square root uses `Math.sqrt`, which is correctly
|
|
264
|
+
* rounded, and one step on each bound. A larger index starts from `Math.pow` and moves each bound until the outward
|
|
265
|
+
* power of `pow` shows the side of the bound. The root is monotone, so the bounds of the ends are the bounds. An odd
|
|
266
|
+
* index takes negative points as `-root(-x)`. An even index ignores negative points.
|
|
267
|
+
*
|
|
268
|
+
* @param x - The radicand.
|
|
269
|
+
* @param k - The index of the root. It must be a whole number of 2 or more.
|
|
270
|
+
* @returns An interval that contains the real root of each point of `x` that has one.
|
|
271
|
+
*/
|
|
272
|
+
function root$1(x, k) {
|
|
273
|
+
if (x === null) return null;
|
|
274
|
+
if (!Number.isInteger(k) || k < 2) throw new RangeError(`root needs a whole index of 2 or more, not ${k}.`);
|
|
275
|
+
let [a, b] = x;
|
|
276
|
+
if (k % 2 === 0) {
|
|
277
|
+
if (b < 0) return null;
|
|
278
|
+
a = Math.max(a, 0);
|
|
279
|
+
}
|
|
280
|
+
if (k === 2) {
|
|
281
|
+
const lo = Math.sqrt(a);
|
|
282
|
+
const hi = Math.sqrt(b);
|
|
283
|
+
return [isSquareOf(lo, a) ? lo : Math.max(0, nextDown(lo)), isSquareOf(hi, b) ? hi : nextUp(hi)];
|
|
284
|
+
}
|
|
285
|
+
return [a < 0 ? -rootUp(-a, k) : rootDown(a, k), b < 0 ? -rootDown(-b, k) : rootUp(b, k)];
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* This function gives the interval of the smallest of the points. It is exact.
|
|
289
|
+
*
|
|
290
|
+
* @param x - The first interval.
|
|
291
|
+
* @param y - The second interval.
|
|
292
|
+
* @returns The interval of `min(p, q)` for `p` in `x` and `q` in `y`.
|
|
293
|
+
*/
|
|
294
|
+
function min$1(x, y) {
|
|
295
|
+
return x === null || y === null ? null : [Math.min(x[0], y[0]), Math.min(x[1], y[1])];
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* This function gives the interval of the largest of the points. It is exact.
|
|
299
|
+
*
|
|
300
|
+
* @param x - The first interval.
|
|
301
|
+
* @param y - The second interval.
|
|
302
|
+
* @returns The interval of `max(p, q)` for `p` in `x` and `q` in `y`.
|
|
303
|
+
*/
|
|
304
|
+
function max$1(x, y) {
|
|
305
|
+
return x === null || y === null ? null : [Math.max(x[0], y[0]), Math.max(x[1], y[1])];
|
|
306
|
+
}
|
|
307
|
+
/** The interval of a truth value: `1` is true and `0` is false. */
|
|
308
|
+
const TRUE = [1, 1];
|
|
309
|
+
const FALSE = [0, 0];
|
|
310
|
+
const UNKNOWN = [0, 1];
|
|
311
|
+
/**
|
|
312
|
+
* This function compares two intervals with `<`. The result is the interval of the truth value, with `1` for true.
|
|
313
|
+
*
|
|
314
|
+
* @param x - The left side.
|
|
315
|
+
* @param y - The right side.
|
|
316
|
+
* @returns `[1, 1]` when `p < q` for each pair of points, `[0, 0]` when for none, and `[0, 1]` when it is not known.
|
|
317
|
+
*/
|
|
318
|
+
function lt$1(x, y) {
|
|
319
|
+
if (x === null || y === null) return null;
|
|
320
|
+
if (x[1] < y[0]) return TRUE;
|
|
321
|
+
if (x[0] >= y[1]) return FALSE;
|
|
322
|
+
return UNKNOWN;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* This function compares two intervals with `<=`. The result is the interval of the truth value, with `1` for true.
|
|
326
|
+
*
|
|
327
|
+
* @param x - The left side.
|
|
328
|
+
* @param y - The right side.
|
|
329
|
+
* @returns `[1, 1]` when `p <= q` for each pair of points, `[0, 0]` when for none, and `[0, 1]` when it is not known.
|
|
330
|
+
*/
|
|
331
|
+
function le$1(x, y) {
|
|
332
|
+
if (x === null || y === null) return null;
|
|
333
|
+
if (x[1] <= y[0]) return TRUE;
|
|
334
|
+
if (x[0] > y[1]) return FALSE;
|
|
335
|
+
return UNKNOWN;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* This function compares two intervals with `=`. The result is the interval of the truth value, with `1` for true.
|
|
339
|
+
*
|
|
340
|
+
* @param x - The left side.
|
|
341
|
+
* @param y - The right side.
|
|
342
|
+
* @returns `[1, 1]` when both are the same point, `[0, 0]` when they do not meet, and `[0, 1]` when it is not known.
|
|
343
|
+
*/
|
|
344
|
+
function eq$1(x, y) {
|
|
345
|
+
if (x === null || y === null) return null;
|
|
346
|
+
if (x[0] === x[1] && y[0] === y[1] && x[0] === y[0]) return TRUE;
|
|
347
|
+
if (x[1] < y[0] || y[1] < x[0]) return FALSE;
|
|
348
|
+
return UNKNOWN;
|
|
349
|
+
}
|
|
350
|
+
// src/rounding.ts
|
|
351
|
+
/**
|
|
352
|
+
* Directed rounding of nonnegative floats, from the exact error terms of `interval.ts`. Each function gives the
|
|
353
|
+
* correctly rounded result when it is exact, and else the result one float step in the stated direction.
|
|
354
|
+
*
|
|
355
|
+
* @packageDocumentation
|
|
356
|
+
*/
|
|
357
|
+
/**
|
|
358
|
+
* This function gives the sum of two nonnegative floats, rounded upward.
|
|
359
|
+
*
|
|
360
|
+
* @param x - The first value, 0 or more.
|
|
361
|
+
* @param y - The second value, 0 or more.
|
|
362
|
+
* @returns A float that is at least `x + y`, and at most one step above it.
|
|
363
|
+
*/
|
|
364
|
+
function addUp(x, y) {
|
|
365
|
+
const s = x + y;
|
|
366
|
+
return sumError(x, y, s) <= 0 ? s : nextUp(s);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* This function gives the product of two nonnegative floats, rounded upward.
|
|
370
|
+
*
|
|
371
|
+
* @param x - The first value, 0 or more.
|
|
372
|
+
* @param y - The second value, 0 or more.
|
|
373
|
+
* @returns A float that is at least `x * y`, and at most one step above it.
|
|
374
|
+
*/
|
|
375
|
+
function mulUp(x, y) {
|
|
376
|
+
const p = x * y;
|
|
377
|
+
return productError(x, y, p) <= 0 ? p : nextUp(p);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* This function gives the quotient of two nonnegative floats, rounded upward. A correctly rounded quotient is at most
|
|
381
|
+
* one step low.
|
|
382
|
+
*
|
|
383
|
+
* @param x - The dividend, 0 or more.
|
|
384
|
+
* @param y - The divisor, above 0.
|
|
385
|
+
* @returns A float that is at least `x / y`, and at most one step above it.
|
|
386
|
+
*/
|
|
387
|
+
function divUp(x, y) {
|
|
388
|
+
const q = x / y;
|
|
389
|
+
return x === 0 || quotientIsExact(x, y, q) ? q : nextUp(q);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* This function gives the difference `x - y` of two nonnegative floats, rounded downward.
|
|
393
|
+
*
|
|
394
|
+
* @param x - The first value, 0 or more.
|
|
395
|
+
* @param y - The value to subtract, 0 or more.
|
|
396
|
+
* @returns A float that is at most `x - y`, and at most one step below it.
|
|
397
|
+
*/
|
|
398
|
+
function subDown(x, y) {
|
|
399
|
+
const s = x - y;
|
|
400
|
+
return sumError(x, -y, s) >= 0 ? s : nextDown(s);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* This function gives the float root of index `k`. The square root is correctly rounded. A larger index uses
|
|
404
|
+
* `Math.cbrt` or `Math.pow`, which are not correctly rounded. An odd root of a negative value is negative.
|
|
405
|
+
*
|
|
406
|
+
* @param r - The radicand.
|
|
407
|
+
* @param k - The index of the root, 2 or more.
|
|
408
|
+
* @returns The float root.
|
|
409
|
+
*/
|
|
410
|
+
function floatRoot(r, k) {
|
|
411
|
+
if (k === 2) return Math.sqrt(r);
|
|
412
|
+
const f = (m) => k === 3 ? Math.cbrt(m) : Math.pow(m, 1 / k);
|
|
413
|
+
return k % 2 === 1 && r < 0 ? -f(-r) : f(r);
|
|
414
|
+
}
|
|
415
|
+
// src/ball.ts
|
|
416
|
+
/**
|
|
417
|
+
* Balls of real numbers: a float midpoint and a float radius, with the "midrad" arithmetic of Rump and of Arb. Each
|
|
418
|
+
* function is a plain function of `{ mid, rad }` values. The midpoint of a result is the float result of the same
|
|
419
|
+
* operation on the midpoints. The radius is the propagated radius of the parts plus the error of the rounding of the
|
|
420
|
+
* midpoint. Each operation of the radius rounds upward.
|
|
421
|
+
*
|
|
422
|
+
* A finite radius is a claim. The exact result of the operation on each point of the input balls is at most the
|
|
423
|
+
* radius from the midpoint. A radius of `Infinity` makes no claim. The radius rounds upward by one float step only
|
|
424
|
+
* when its float operation is not exact, so an exact result has the radius zero.
|
|
425
|
+
*
|
|
426
|
+
* Proof sketch of the bound. Let the exact inputs of an operation be `X = a + dx` and `Y = b + dy`, with `|dx| <= ra`
|
|
427
|
+
* and `|dy| <= rb`. Let `m` be the float result and `e` the error of its rounding.
|
|
428
|
+
*
|
|
429
|
+
* - A sum: `X + Y - m = e + dx + dy`, so `ra + rb + |e|` is a radius. `TwoSum` gives `e` exactly.
|
|
430
|
+
* - A product: `XY - m = e + a dy + b dx + dx dy`, so `|a| rb + |b| ra + ra rb + |e|` is a radius. `TwoProduct`
|
|
431
|
+
* gives `e` exactly away from overflow and underflow. Else `u |m| + 2^-1074` bounds `|e|`.
|
|
432
|
+
* - A quotient, with `rb < |b|` so that `Y` is not zero: `X / Y - a / b = (b dx - a dy) / (b Y)`, and
|
|
433
|
+
* `|b Y| >= |b| (|b| - rb)`. So `(ra + |a / b| rb) / (|b| - rb) + |e|` is a radius. Else the radius is `Infinity`.
|
|
434
|
+
* - The smallest and the largest move at most by the largest radius of a part. `min` and `max` are 1-Lipschitz in
|
|
435
|
+
* the largest distance. When the two balls do not meet, the extreme is one of them, so its radius is enough.
|
|
436
|
+
* - A root goes through `interval.root` of `[m - r, m + r]`, rounded outward. The radius is the largest distance from
|
|
437
|
+
* the midpoint to an end. An even root of a ball that holds a negative value has the radius `Infinity`.
|
|
438
|
+
* - A comparison is decided when the outward intervals of the two balls decide it. The midpoint is then the truth
|
|
439
|
+
* value and the radius is zero. Else the radius is one.
|
|
440
|
+
*
|
|
441
|
+
* The radius functions (`sumRadius`, `productRadius`, `quotientRadius`, `extremeRadius` and `rootRadius`) make no
|
|
442
|
+
* object. An evaluator that keeps the midpoint and the radius in two numbers uses them.
|
|
443
|
+
*
|
|
444
|
+
* @packageDocumentation
|
|
445
|
+
*/
|
|
446
|
+
var ball_exports = /* @__PURE__ */ __exportAll({
|
|
447
|
+
NO_CLAIM: () => NO_CLAIM,
|
|
448
|
+
add: () => add,
|
|
449
|
+
ball: () => ball,
|
|
450
|
+
claim: () => claim,
|
|
451
|
+
div: () => div,
|
|
452
|
+
eq: () => eq,
|
|
453
|
+
extremeRadius: () => extremeRadius,
|
|
454
|
+
fromInterval: () => fromInterval,
|
|
455
|
+
le: () => le,
|
|
456
|
+
lt: () => lt,
|
|
457
|
+
max: () => max,
|
|
458
|
+
min: () => min,
|
|
459
|
+
mul: () => mul,
|
|
460
|
+
neg: () => neg,
|
|
461
|
+
pow: () => pow,
|
|
462
|
+
productRadius: () => productRadius,
|
|
463
|
+
quotientRadius: () => quotientRadius,
|
|
464
|
+
root: () => root,
|
|
465
|
+
rootRadius: () => rootRadius,
|
|
466
|
+
roundingBound: () => roundingBound,
|
|
467
|
+
sub: () => sub,
|
|
468
|
+
sumRadius: () => sumRadius,
|
|
469
|
+
toInterval: () => toInterval
|
|
470
|
+
});
|
|
471
|
+
const U = 2 ** -53;
|
|
472
|
+
const MIN = Number.MIN_VALUE;
|
|
473
|
+
/** The ball that makes no claim. */
|
|
474
|
+
const NO_CLAIM = {
|
|
475
|
+
mid: NaN,
|
|
476
|
+
rad: Infinity
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* This function gives a bound of the error `|e|` of the rounding of a float result `m`. An exact error term `e`
|
|
480
|
+
* gives `|e|`. An error term of `NaN` is not known, and it gives `u |m| + 2^-1074`, rounded upward.
|
|
481
|
+
*
|
|
482
|
+
* @param e - The exact error term, or `NaN`.
|
|
483
|
+
* @param m - The float result.
|
|
484
|
+
* @returns A bound of the error, rounded upward.
|
|
485
|
+
*/
|
|
486
|
+
function roundingBound(e, m) {
|
|
487
|
+
return e === e ? Math.abs(e) : addUp(mulUp(U, Math.abs(m)), MIN);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* This function keeps a radius as a claim only when the midpoint is finite and the radius is a number.
|
|
491
|
+
*
|
|
492
|
+
* @param m - The midpoint.
|
|
493
|
+
* @param r - The radius.
|
|
494
|
+
* @returns `r`, or `Infinity` when `m` is not finite or `r` is `NaN`.
|
|
495
|
+
*/
|
|
496
|
+
function claim(m, r) {
|
|
497
|
+
return m - m === 0 && r <= Infinity ? r : Infinity;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* This function makes a ball. A midpoint that is not finite gives the radius `Infinity`.
|
|
501
|
+
*
|
|
502
|
+
* @param mid - The midpoint.
|
|
503
|
+
* @param rad - The radius, 0 or more. The default is 0.
|
|
504
|
+
* @returns The ball.
|
|
505
|
+
* @throws RangeError when the radius is negative or `NaN`.
|
|
506
|
+
*/
|
|
507
|
+
function ball(mid, rad = 0) {
|
|
508
|
+
if (!(rad >= 0)) throw new RangeError(`The radius of a ball must be 0 or more, not ${rad}.`);
|
|
509
|
+
return {
|
|
510
|
+
mid,
|
|
511
|
+
rad: claim(mid, rad)
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* This function gives the interval `[mid - rad, mid + rad]` of a ball, rounded outward.
|
|
516
|
+
*
|
|
517
|
+
* @param x - The ball.
|
|
518
|
+
* @returns An interval that contains each point of the ball. A ball that makes no claim gives the whole line.
|
|
519
|
+
*/
|
|
520
|
+
function toInterval(x) {
|
|
521
|
+
if (!(x.rad < Infinity)) return WHOLE;
|
|
522
|
+
return add$1([x.mid, x.mid], [-x.rad, x.rad]);
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* This function gives a ball that contains an interval. The midpoint is the float midpoint of the ends, and the
|
|
526
|
+
* radius is the larger distance to an end, rounded upward.
|
|
527
|
+
*
|
|
528
|
+
* @param x - The interval.
|
|
529
|
+
* @returns A ball that contains each point of `x`. The empty interval and an infinite end give `NO_CLAIM`.
|
|
530
|
+
*/
|
|
531
|
+
function fromInterval(x) {
|
|
532
|
+
if (x === null || !(x[0] - x[0] === 0 && x[1] - x[1] === 0)) return NO_CLAIM;
|
|
533
|
+
const [lo, hi] = x;
|
|
534
|
+
const mid = lo / 2 + hi / 2;
|
|
535
|
+
const d = sub$1([hi, hi], [mid, mid]);
|
|
536
|
+
const e = sub$1([mid, mid], [lo, lo]);
|
|
537
|
+
return {
|
|
538
|
+
mid,
|
|
539
|
+
rad: claim(mid, Math.max(d[1], e[1], 0))
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* This function gives the radius of a sum `m = fl(a + b)`.
|
|
544
|
+
*
|
|
545
|
+
* @param m - The float sum of the midpoints.
|
|
546
|
+
* @param a - The first midpoint.
|
|
547
|
+
* @param ra - The first radius.
|
|
548
|
+
* @param b - The second midpoint.
|
|
549
|
+
* @param rb - The second radius.
|
|
550
|
+
* @returns The radius of the sum, rounded upward.
|
|
551
|
+
*/
|
|
552
|
+
function sumRadius(m, a, ra, b, rb) {
|
|
553
|
+
return claim(m, addUp(addUp(ra, rb), roundingBound(sumError(a, b, m), m)));
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* This function gives the radius of a product `m = fl(a * b)`.
|
|
557
|
+
*
|
|
558
|
+
* @param m - The float product of the midpoints.
|
|
559
|
+
* @param a - The first midpoint.
|
|
560
|
+
* @param ra - The first radius.
|
|
561
|
+
* @param b - The second midpoint.
|
|
562
|
+
* @param rb - The second radius.
|
|
563
|
+
* @returns The radius of the product, rounded upward.
|
|
564
|
+
*/
|
|
565
|
+
function productRadius(m, a, ra, b, rb) {
|
|
566
|
+
return claim(m, addUp(addUp(addUp(mulUp(Math.abs(a), rb), mulUp(Math.abs(b), ra)), mulUp(ra, rb)), roundingBound(productError(a, b, m), m)));
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* This function gives the radius of a quotient `q = fl(a / b)`.
|
|
570
|
+
*
|
|
571
|
+
* @param q - The float quotient of the midpoints.
|
|
572
|
+
* @param a - The midpoint of the dividend.
|
|
573
|
+
* @param ra - The radius of the dividend.
|
|
574
|
+
* @param b - The midpoint of the divisor.
|
|
575
|
+
* @param rb - The radius of the divisor.
|
|
576
|
+
* @returns The radius of the quotient, rounded upward, or `Infinity` when the ball of the divisor can hold zero.
|
|
577
|
+
*/
|
|
578
|
+
function quotientRadius(q, a, ra, b, rb) {
|
|
579
|
+
const m = Math.abs(b);
|
|
580
|
+
if (!(rb < m) || !(q - q === 0)) return Infinity;
|
|
581
|
+
return claim(q, addUp(divUp(addUp(ra, mulUp(q === 0 ? 0 : nextUp(Math.abs(q)), rb)), subDown(m, rb)), quotientIsExact(a, b, q) ? 0 : addUp(mulUp(U, Math.abs(q)), MIN)));
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* This function gives the radius of the largest (`sign = 1`) or the smallest (`sign = -1`) of two balls. When the
|
|
585
|
+
* outward intervals of the balls do not meet, the extreme is one ball, and its radius is the radius. Else the radius
|
|
586
|
+
* is the larger radius.
|
|
587
|
+
*
|
|
588
|
+
* @param sign - `1` for the largest, `-1` for the smallest.
|
|
589
|
+
* @param a - The first midpoint.
|
|
590
|
+
* @param ra - The first radius.
|
|
591
|
+
* @param b - The second midpoint.
|
|
592
|
+
* @param rb - The second radius.
|
|
593
|
+
* @returns The radius of the extreme. Give it to `claim` with the midpoint of the extreme.
|
|
594
|
+
*/
|
|
595
|
+
function extremeRadius(sign, a, ra, b, rb) {
|
|
596
|
+
const sa = add$1([sign * a, sign * a], [-ra, ra]);
|
|
597
|
+
const sb = add$1([sign * b, sign * b], [-rb, rb]);
|
|
598
|
+
if (sa[0] >= sb[1]) return ra;
|
|
599
|
+
if (sb[0] >= sa[1]) return rb;
|
|
600
|
+
return Math.max(ra, rb);
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* This function gives the radius of a root `v = floatRoot(r, k)`. The radius is the largest distance from `v` to an
|
|
604
|
+
* end of `interval.root` of the ball of the radicand, rounded upward.
|
|
605
|
+
*
|
|
606
|
+
* @param v - The float root of the midpoint.
|
|
607
|
+
* @param r - The midpoint of the radicand.
|
|
608
|
+
* @param rr - The radius of the radicand.
|
|
609
|
+
* @param k - The index of the root, a whole number of 2 or more.
|
|
610
|
+
* @returns The radius of the root, or `Infinity` when an even root can meet a negative value.
|
|
611
|
+
*/
|
|
612
|
+
function rootRadius(v, r, rr, k) {
|
|
613
|
+
if (!(rr < Infinity) || !(v - v === 0)) return Infinity;
|
|
614
|
+
const span = add$1([r, r], [-rr, rr]);
|
|
615
|
+
if (span === null || k % 2 === 0 && span[0] < 0) return Infinity;
|
|
616
|
+
const d = sub$1([v, v], root$1(span, k));
|
|
617
|
+
return d === null ? Infinity : claim(v, Math.max(-d[0], d[1]));
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* This function gives the sum of two balls.
|
|
621
|
+
*
|
|
622
|
+
* @param x - The first ball.
|
|
623
|
+
* @param y - The second ball.
|
|
624
|
+
* @returns A ball that contains each sum of a point of `x` and a point of `y`.
|
|
625
|
+
*/
|
|
626
|
+
function add(x, y) {
|
|
627
|
+
const m = x.mid + y.mid;
|
|
628
|
+
return {
|
|
629
|
+
mid: m,
|
|
630
|
+
rad: sumRadius(m, x.mid, x.rad, y.mid, y.rad)
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* This function gives the difference of two balls.
|
|
635
|
+
*
|
|
636
|
+
* @param x - The first ball.
|
|
637
|
+
* @param y - The ball to subtract.
|
|
638
|
+
* @returns A ball that contains each difference of a point of `x` and a point of `y`.
|
|
639
|
+
*/
|
|
640
|
+
function sub(x, y) {
|
|
641
|
+
const m = x.mid - y.mid;
|
|
642
|
+
return {
|
|
643
|
+
mid: m,
|
|
644
|
+
rad: sumRadius(m, x.mid, x.rad, -y.mid, y.rad)
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* This function gives the negative of a ball. It is exact.
|
|
649
|
+
*
|
|
650
|
+
* @param x - The ball.
|
|
651
|
+
* @returns The ball of the negative points.
|
|
652
|
+
*/
|
|
653
|
+
function neg(x) {
|
|
654
|
+
return {
|
|
655
|
+
mid: -x.mid,
|
|
656
|
+
rad: x.rad
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* This function gives the product of two balls.
|
|
661
|
+
*
|
|
662
|
+
* @param x - The first ball.
|
|
663
|
+
* @param y - The second ball.
|
|
664
|
+
* @returns A ball that contains each product of a point of `x` and a point of `y`.
|
|
665
|
+
*/
|
|
666
|
+
function mul(x, y) {
|
|
667
|
+
const m = x.mid * y.mid;
|
|
668
|
+
return {
|
|
669
|
+
mid: m,
|
|
670
|
+
rad: productRadius(m, x.mid, x.rad, y.mid, y.rad)
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* This function gives the quotient of two balls.
|
|
675
|
+
*
|
|
676
|
+
* @param x - The dividend.
|
|
677
|
+
* @param y - The divisor.
|
|
678
|
+
* @returns A ball that contains each quotient of a point of `x` and a point of `y`. A divisor that can hold zero gives
|
|
679
|
+
* the radius `Infinity`.
|
|
680
|
+
*/
|
|
681
|
+
function div(x, y) {
|
|
682
|
+
const q = x.mid / y.mid;
|
|
683
|
+
return {
|
|
684
|
+
mid: q,
|
|
685
|
+
rad: quotientRadius(q, x.mid, x.rad, y.mid, y.rad)
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* This function gives the smallest of two balls.
|
|
690
|
+
*
|
|
691
|
+
* @param x - The first ball.
|
|
692
|
+
* @param y - The second ball.
|
|
693
|
+
* @returns A ball that contains `min(p, q)` for each point `p` of `x` and `q` of `y`.
|
|
694
|
+
*/
|
|
695
|
+
function min(x, y) {
|
|
696
|
+
const m = Math.min(x.mid, y.mid);
|
|
697
|
+
return {
|
|
698
|
+
mid: m,
|
|
699
|
+
rad: claim(m, extremeRadius(-1, x.mid, x.rad, y.mid, y.rad))
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* This function gives the largest of two balls.
|
|
704
|
+
*
|
|
705
|
+
* @param x - The first ball.
|
|
706
|
+
* @param y - The second ball.
|
|
707
|
+
* @returns A ball that contains `max(p, q)` for each point `p` of `x` and `q` of `y`.
|
|
708
|
+
*/
|
|
709
|
+
function max(x, y) {
|
|
710
|
+
const m = Math.max(x.mid, y.mid);
|
|
711
|
+
return {
|
|
712
|
+
mid: m,
|
|
713
|
+
rad: claim(m, extremeRadius(1, x.mid, x.rad, y.mid, y.rad))
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* This function gives a ball to a whole power, with repeated squares. Each product uses the rule of `mul`. A negative
|
|
718
|
+
* power is the quotient of one by the positive power. The power zero gives one, with the radius zero when the base
|
|
719
|
+
* makes a claim.
|
|
720
|
+
*
|
|
721
|
+
* @param x - The base.
|
|
722
|
+
* @param n - The exponent, a whole number.
|
|
723
|
+
* @returns A ball that contains the power of each point of `x`.
|
|
724
|
+
*/
|
|
725
|
+
function pow(x, n) {
|
|
726
|
+
if (!Number.isInteger(n)) throw new RangeError(`pow needs a whole exponent, not ${n}.`);
|
|
727
|
+
let bv = x.mid;
|
|
728
|
+
let br = x.rad;
|
|
729
|
+
if (n === 0) return {
|
|
730
|
+
mid: 1,
|
|
731
|
+
rad: br < Infinity ? 0 : Infinity
|
|
732
|
+
};
|
|
733
|
+
let rv = 1;
|
|
734
|
+
let rr = 0;
|
|
735
|
+
let first = true;
|
|
736
|
+
for (let k = Math.abs(n); k > 0; k = Math.floor(k / 2)) {
|
|
737
|
+
if (k % 2 === 1) {
|
|
738
|
+
if (first) {
|
|
739
|
+
rv = bv;
|
|
740
|
+
rr = br;
|
|
741
|
+
first = false;
|
|
742
|
+
} else {
|
|
743
|
+
const m = rv * bv;
|
|
744
|
+
rr = productRadius(m, rv, rr, bv, br);
|
|
745
|
+
rv = m;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (k > 1) {
|
|
749
|
+
const s = bv * bv;
|
|
750
|
+
br = productRadius(s, bv, br, bv, br);
|
|
751
|
+
bv = s;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
if (n > 0) return {
|
|
755
|
+
mid: rv,
|
|
756
|
+
rad: rr
|
|
757
|
+
};
|
|
758
|
+
const v = 1 / rv;
|
|
759
|
+
return {
|
|
760
|
+
mid: v,
|
|
761
|
+
rad: quotientRadius(v, 1, 0, rv, rr)
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* This function gives the root of index `k` of a ball.
|
|
766
|
+
*
|
|
767
|
+
* @param x - The radicand.
|
|
768
|
+
* @param k - The index of the root, a whole number of 2 or more.
|
|
769
|
+
* @returns A ball that contains the real root of each point of `x`. An even root of a ball that can hold a negative
|
|
770
|
+
* value gives the radius `Infinity`.
|
|
771
|
+
*/
|
|
772
|
+
function root(x, k) {
|
|
773
|
+
if (!Number.isInteger(k) || k < 2) throw new RangeError(`root needs a whole index of 2 or more, not ${k}.`);
|
|
774
|
+
const v = floatRoot(x.mid, k);
|
|
775
|
+
return {
|
|
776
|
+
mid: v,
|
|
777
|
+
rad: rootRadius(v, x.mid, x.rad, k)
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
/** This function decides a comparison of two balls with the outward intervals of the balls. */
|
|
781
|
+
function comparison(kind, x, y) {
|
|
782
|
+
if (!(x.rad < Infinity && y.rad < Infinity)) return NO_CLAIM;
|
|
783
|
+
const truth = interval_exports[kind](toInterval(x), toInterval(y));
|
|
784
|
+
if (truth[0] === truth[1]) return {
|
|
785
|
+
mid: truth[0],
|
|
786
|
+
rad: 0
|
|
787
|
+
};
|
|
788
|
+
const a = x.mid;
|
|
789
|
+
const b = y.mid;
|
|
790
|
+
return {
|
|
791
|
+
mid: (kind === "lt" ? a < b : kind === "le" ? a <= b : a === b) ? 1 : 0,
|
|
792
|
+
rad: 1
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* This function compares two balls with `<`.
|
|
797
|
+
*
|
|
798
|
+
* @param x - The first ball.
|
|
799
|
+
* @param y - The second ball.
|
|
800
|
+
* @returns The truth value `1` or `0` with the radius zero when the balls decide it. Else the float truth value of
|
|
801
|
+
* the midpoints with the radius one.
|
|
802
|
+
*/
|
|
803
|
+
function lt(x, y) {
|
|
804
|
+
return comparison("lt", x, y);
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* This function compares two balls with `<=`.
|
|
808
|
+
*
|
|
809
|
+
* @param x - The first ball.
|
|
810
|
+
* @param y - The second ball.
|
|
811
|
+
* @returns The truth value with the rule of `lt`.
|
|
812
|
+
*/
|
|
813
|
+
function le(x, y) {
|
|
814
|
+
return comparison("le", x, y);
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* This function compares two balls with `=`.
|
|
818
|
+
*
|
|
819
|
+
* @param x - The first ball.
|
|
820
|
+
* @param y - The second ball.
|
|
821
|
+
* @returns The truth value with the rule of `lt`.
|
|
822
|
+
*/
|
|
823
|
+
function eq(x, y) {
|
|
824
|
+
return comparison("eq", x, y);
|
|
825
|
+
}
|
|
826
|
+
export { WHOLE, addUp, ball_exports as ball, divUp, floatRoot, interval_exports as interval, mulUp, nextDown, nextUp, productError, quotientIsExact, subDown, sumError };
|
|
827
|
+
|
|
828
|
+
//# sourceMappingURL=index.js.map
|