// ============================================================================ // JOB #593 — THE ANCHORED MARGIN'S EXTREMAL ORDER STATISTICS // // QUESTION. ZONE-POSTULATE.md section 4 fixes the anchored margin // margin(p) = (p_next^2 - p) / (distance from p to the TOP of the first twin // strictly above p) // and reports, for the whole run to 1e11, ONE number per decade: the minimum // margin in that decade, with the distance that achieved it. Its reading is // "the first-twin distance grows like ln^2 p times a slowly growing extremal // factor, call it ln^3 p to be safe, while the window grows like p^2. The // margin runs away like p^2/polylog, and nothing in eleven decades hints at // the postulate being tight anywhere." // // THE DECISION THIS INFORMS. G2-STATE.md section 9 item 4 / ZONE-POSTULATE.md // section 8 item 3 want the window/G2 ratio UNBOUNDED (weak ZP, TPC-implying) // and record that their evidence is ONE-SIDED: the certificate is a lower bound // on G2, so x^2/certificate is an upper bound on x^2/G2 and the direction of // inference has to be stated every time it is used. The anchored quantity here // is the other side of that ledger. Section 8 item 5 adds that "an origin-side // statement that survives past S = x'^2" is what is missing, and that // everything found so far expires at or before the zone's own width. // // WHAT THE RETAINED CENSUS COULD NOT DECIDE. window-check.js is a single-pass // running MINIMUM: it keeps worst/latest per decade and discards the two-point // sample it computed, so no question about the SHAPE of the extremal growth can // be asked of it. Its own reading of the extremal factor is checked at exactly // two primes by hand (17x against ~19 at p = 65,095,731,749; 12.3x against ~18 // at p ~ 4.3e9) and nowhere else. A one-extremum-per-decade record cannot say // whether the first-twin distance's growth is carried by ONE prime per decade // or by the whole top of the tail. // // THE STATISTIC. Per decade k, report the top m distances // d1 >= d2 >= ... >= dm (m = 5) // i.e. the m-th order statistics of the anchored distance, not just d1. Then ask // the two questions the retained census cannot: // (S1) Do d2, d3, ... follow d1's growth curve, or is d1 alone an outlier? // The census's "extremal factor grows like ln p" sentence is a statement // about d1. If d1/d2 -> 1 with the level, the growth is a property of the // whole upper tail and the sentence is safe; if d1/d2 DRIFTS UP, the // sentence is being carried by single primes and must be reworded. // (S2) Does d1 respect the published ceiling? Kourbatov, J. Integer Seq. 16 // (2013) 13.5.2 = arXiv:1301.2242, Table 1 / Figure 1: "Maximal gaps // between twin primes are less than 0.76 log^3 p" (his C_2 = 0.75739 is // our 1/(2 C_2), the notation collision ZONE-POSTULATE.md section 4 // flags). d(p) <= 0.76 ln^3 p is the guard the record adopts by hand. // // PRE-REGISTERED FALSIFIER (written before any run, sealed here). // F1. S1: if d1/d2 rises over three consecutive decades, the reading "the // extremal factor grows like ln p" is FALSE as a tail statement and must // be restricted to d1. Threshold: a monotone rise in d1/d2 across three // consecutive decades with the decade's pair count still increasing. // F2. S2: if d1 > 0.76 ln^3 p at ANY decade, the adopted guard is violated at // that level (a published-ceiling violation is reported as such, not // explained away). // F3. S1': if d2/d3 does NOT approach 1 as the level grows, the top of the // anchored tail is not a single-parameter family and any two-point // extremal-factor comparison is under-powered by construction. // Each is a statement about THIS run's range; none is an asymptotic claim. // // MATCHED CONTROL (declared here, and external so it is not fitted). // The null is Kourbatov's own twin-gap model on the same primes and the same // decades: mean twin gap a(p) = 0.75739 ln^2 p, i.e. the load // load(p) = d(p) / (0.75739 ln^2 p), whose predicted extremal factor over the // P twin pairs of a decade is ln P (the record's own two-point check). The // control is applied to the ORDER STATISTICS, not to a single prime: report // load(d_j) for j = 1..5 against ln P_k. This is the record's hand check // promoted to a per-decade, control-matched test, and the control constant is // published (Kourbatov 2013), so nothing is tuned to the data. // // SCALE AT WHICH AN EFFECT WOULD BE VISIBLE. d1..d5 are stable only once a // decade holds many twin pairs; the record's own run finds 224,376,048 pairs by // 1e11, so by decade 6 the order statistics are already over-determined. The // drift tests F1/F3 need consecutive decades, i.e. at least six decades, which // this run reaches. // // COST. Same sieve as the published script, one extra top-5 insert per twin // close: the record ran 1e11 in 599 s with a 4M segment, so 1e10 is about a // minute and this script adds no order of magnitude. // // house format: the question is this comment block; the code follows; the run's // actual output is in stat593.out beside it (NOT embedded in a hand-edited // OUTPUT block, which the qc embed check hashes and would flag). // ============================================================================ 'use strict'; import fs from 'node:fs'; const N = +(process.argv[2] || 1e10); const M = 5; // order statistics retained per decade const SEG = 1 << 22; const t0 = Date.now(); const lim = Math.floor(Math.sqrt(N)) + 1; const sm = new Uint8Array(lim + 1); const base = []; for (let i = 2; i <= lim; i++) if (!sm[i]) { base.push(i); for (let j = i * i; j <= lim; j += i) sm[j] = 1; } let lastPrime = 0, prevPrime = 0; const pend = []; // p, p_next awaiting the first twin strictly above p let nPrimes = 0, nTwins = 0; const dec = []; // per decade: { d:[top M], pairs, m, mAt, mD, mW, maxD, maxDat } function D(e) { return dec[e] || (dec[e] = { d: [], pairs: 0, m: Infinity, mAt: 0, mD: 0, mW: 0n, maxD: 0, maxDat: 0 }); } function insert(arr, v) { // keep the top M, descending if (arr.length < M) { arr.push(v); arr.sort((a, b) => b - a); return; } if (v <= arr[arr.length - 1]) return; arr[arr.length - 1] = v; arr.sort((a, b) => b - a); } const winExact = (pn, p) => BigInt(pn) * BigInt(pn) - BigInt(p); function onPrime(q) { nPrimes++; if (prevPrime) pend.push(prevPrime, lastPrime); if (lastPrime && q - lastPrime === 2) { nTwins++; const a = lastPrime, top = q; let k = 0; while (k < pend.length) { const p = pend[k], pn = pend[k + 1]; if (p < a) { // the decade is the DECADE OF p, as in the published script: bucketing by // the twin's position instead puts p = 71 in 10^2 and silently moves the // per-decade minima. (Caught by comparing against section 4's table.) const e = Math.floor(Math.log10(p)); const R = D(e); R.pairs++; const d = top - p; insert(R.d, d); if (d > R.maxD) { R.maxD = d; R.maxDat = p; } const m = (pn * pn - p) / d; // double ratio; every printed window is re-formed exactly if (m < R.m) { R.m = m; R.mAt = p; R.mD = d; R.mW = winExact(pn, p); } k += 2; } else break; } if (k) pend.splice(0, k); } prevPrime = lastPrime; lastPrime = q; } const seg = new Uint8Array(SEG); for (let lo = 2; lo <= N; lo += SEG) { const hi = Math.min(lo + SEG - 1, N); seg.fill(0, 0, hi - lo + 1); for (const p of base) { if (p * p > hi) break; const s = Math.max(p * p, Math.ceil(lo / p) * p); for (let j = s; j <= hi; j += p) seg[j - lo] = 1; } for (let i = lo; i <= hi; i++) if (!seg[i - lo]) onPrime(i); } const secs = (Date.now() - t0) / 1000; const lines = []; const say = (s) => { lines.push(s); console.log(s); }; say(`ANCHORED FIRST-TWIN DISTANCE: EXTREMAL ORDER STATISTICS`); say(`N = ${N.toExponential(2)} primes ${nPrimes.toLocaleString('en-US')} twin pairs ${nTwins.toLocaleString('en-US')} [${secs.toFixed(1)}s, node ${process.version}]`); say(`load(p) = d(p) / (0.75739 ln^2 p); control: extremal load ~ ln(pairs), Kourbatov 2013`); say(''); say(`decade | pairs | d1 | d2 | d3 | d1/d2 | d2/d3 | load d1 | ln P | load d1/lnP | 0.76ln^3p / d1 | min margin`); for (let e = 0; e < dec.length; e++) { const R = dec[e]; if (!R || R.d.length === 0) continue; const p1 = Math.pow(10, e + 1); const lnp = Math.log(p1); const d = R.d; const d1 = d[0] ?? 0, d2 = d[1] ?? 0, d3 = d[2] ?? 0; const load1 = d1 / (0.75739 * lnp * lnp); const lnP = Math.log(R.pairs); const guard = 0.76 * lnp * lnp * lnp; say(`10^${String(e).padStart(2)} | ${String(R.pairs).padStart(11)} | ${String(d1).padStart(12)} | ${String(d2).padStart(12)} | ${String(d3).padStart(12)} | ` + `${(d1 / d2).toFixed(4)} | ${d2 && d3 ? (d2 / d3).toFixed(4) : '-'} | ${load1.toFixed(1).padStart(7)} | ${lnP.toFixed(2).padStart(5)} | ` + `${(load1 / lnP).toFixed(3).padStart(11)} | ${(guard / d1).toFixed(2).padStart(14)} | ${R.m === Infinity ? '-' : R.m.toFixed(1)}`); } say(''); say('decade | worst-margin p | its d | window (exact BigInt) | largest d in decade'); for (let e = 0; e < dec.length; e++) { const R = dec[e]; if (!R || R.m === Infinity) continue; say(`10^${String(e).padStart(2)} | ${String(R.mAt).padStart(21)} | ${String(R.mD).padStart(10)} | ${String(R.mW).padStart(26)} | ${String(R.maxD).padStart(10)} at ${R.maxDat}`); } say(''); const dd = dec.filter((R) => R && R.d.length >= 2); const ratio = dd.map((R, i) => R.d[0] / R.d[1]); say(`F1 (d1/d2 rising over three consecutive decades): ratios ${ratio.map((x) => x.toFixed(3)).join(', ')}`); let rise = 0, run = 0; for (let i = 1; i < ratio.length; i++) { if (ratio[i] > ratio[i - 1]) { run++; rise = Math.max(rise, run + 1); } else run = 0; } say(` longest strictly rising run = ${rise} decade(s) -> F1 ${rise >= 3 ? 'FIRES' : 'does not fire'}`); const f2 = dec.map((R, e) => R && R.d.length ? { e, d1: R.d[0], guard: 0.76 * Math.pow(Math.log(Math.pow(10, e + 1)), 3) } : null) .filter((x) => x && x.d1 > x.guard); say(`F2 (d1 > 0.76 ln^3 p): ${f2.length === 0 ? 'does not fire' : 'FIRES at decades ' + f2.map((x) => '10^' + x.e).join(', ')}`); const last = dd.length >= 3 ? dd[dd.length - 1] : null; const r23 = last ? last.d[1] / last.d[2] : 0; say(`F3 (d2/d3 -> 1 at the top level): at 10^${dd.length - 1} d2/d3 = ${r23.toFixed(4)} -> F3 ${r23 < 1.5 ? 'does not fire (top of the tail is a single-parameter family)' : 'FIRES (d2 and d3 differ by x' + r23.toFixed(2) + ')'}`); say(''); say(`VERDICT: ${lines.length ? 'see F1/F2/F3 above' : ''}`); fs.writeFileSync('stat593.out', lines.join('\n') + '\n');