MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / checkPoint

Function checkPoint

scripts/rubi/benchmark.ts:262–287  ·  view source on GitHub ↗
(
      Fk: BoxedExpression,
      fk: BoxedExpression,
      assignment: Record<string, number>,
      xv: number | C
    )

Source from the content-addressed store, hash-verified

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(

Callers 1

runProblemFunction · 0.85

Calls 4

dFFunction · 0.85
complexAtFunction · 0.85
toPrecisionMethod · 0.80
absMethod · 0.65

Tested by

no test coverage detected