(
Fk: BoxedExpression,
fk: BoxedExpression,
assignment: Record<string, number>,
xv: number | C
)
| 260 | // real-axis samples retained for the region-phase (formal) analysis |
| 261 | type Sample = { k: number; x: number; lhs: C; rhs: C; err: number }; |
| 262 | const realSamples: Sample[] = []; |
| 263 | const exprByAssignment = new Map< |
| 264 | number, |
| 265 | { Fk: BoxedExpression; fk: BoxedExpression } |
| 266 | >(); |
| 267 | let assignmentIndex = -1; |
| 268 | // checks one sample point; returns true when enough evidence gathered |
| 269 | const checkPoint = ( |
| 270 | Fk: BoxedExpression, |
| 271 | fk: BoxedExpression, |
| 272 | assignment: Record<string, number>, |
| 273 | xv: number | C |
| 274 | ): void => { |
| 275 | const mag = |
| 276 | typeof xv === 'number' ? Math.abs(xv) : Math.hypot(xv.re, xv.im); |
| 277 | const h = 1e-4 * Math.max(0.01, mag); |
| 278 | const lhs = dF(Fk, p.variable, xv, h); |
| 279 | const rhs = complexAt(fk, p.variable, xv); |
| 280 | if (!lhs || !rhs) return; |
| 281 | const scale = |
| 282 | 1 + Math.hypot(rhs.re, rhs.im) + Math.hypot(lhs.re, lhs.im); |
| 283 | const err = Math.hypot(lhs.re - rhs.re, lhs.im - rhs.im) / scale; |
| 284 | worst = Math.max(worst, err); |
| 285 | if (typeof xv === 'number') |
| 286 | realSamples.push({ k: assignmentIndex, x: xv, lhs, rhs, err }); |
| 287 | if (err < REL_TOL) passes++; |
| 288 | else if (err > 1e-3) { |
| 289 | fails++; |
| 290 | failPoints.push( |
no test coverage detected