--- docs/research_discrepancy-two-class.js 2026-09-11 14:38:11 +++ discrepancy-two-class-x31.js 2026-09-11 14:44:20 @@ -256,7 +256,72 @@ console.log(' (D_x = prod_{3<=q<=x}(q-2); the slot set is mirror-symmetric under'); console.log(' r -> W-2-r, which is why max = -min to the printed digits.)'); +// =========================================================================== +// PART B31 — x = 31 added in a scratch copy (solveathome job #36; not part of the served file) // =========================================================================== +// Segmented mod-30 walk over [1, 31#]: every twin slot is 11, 17 or 29 mod 30 (odd, 2 mod 3, and +// neither 0 nor 3 mod 5). The discrepancy numerator num_k = k*W - N*r_k = W * DeltaPhi_2 just after +// the k-th slot changes by W - N*gap per slot and stays far below 2^53 in size, so max, min and the +// rising zeroes are carried exactly in integers; the running Psi is k itself. accPush/accClose run +// alongside, unchanged, for sd and for the float engine's own rising-zero count. The exact row is +// printed before accClose, so a float-drift assertion there cannot suppress it. +{ + const X = 31, PBIG = [7, 11, 13, 17, 19, 23, 29, 31]; + const W = PBIG.reduce((a, p) => a * p, 30), N = PBIG.reduce((a, p) => a * (p - 2), 3); + assert(W === 200560490130 && N === 6226553025, 'x = 31 period and D'); + const LANES = [11, 17, 29], SEG = 1 << 20, MB = W / 30; + const inv30 = (p) => { for (let t = 1; t < p; t++) if ((30 * t) % p === 1) return t; return 0; }; + // block m kills lane c at prime p when 30m + c = 0 or -2 (mod p) + const START = LANES.map(c => PBIG.map(p => { + const iv = inv30(p); + return [(((-c % p) + p) % p) * iv % p, (((-c - 2) % p + p) % p) * iv % p]; + })); + const lane = LANES.map(() => new Uint8Array(SEG)); + const acc = newAcc(W, N); + let k = 0, num = 0, prev = 0, maxNum = -Infinity, minNum = Infinity, rzC = 0, rzS = 0; + const tB = Date.now(); + for (let m0 = 0; m0 < MB; m0 += SEG) { + const len = Math.min(SEG, MB - m0); + for (let li = 0; li < 3; li++) { + const arr = lane[li]; arr.fill(0, 0, len); + for (let pi = 0; pi < PBIG.length; pi++) { + const p = PBIG[pi], off = m0 % p; + for (const s0 of START[li][pi]) for (let j = ((s0 - off) % p + p) % p; j < len; j += p) arr[j] = 1; + } + } + const l0 = lane[0], l1 = lane[1], l2 = lane[2]; + for (let j = 0; j < len; j++) { + if (l0[j] & l1[j] & l2[j]) continue; + const base = 30 * (m0 + j); + for (let li = 0; li < 3; li++) { + if (lane[li][j]) continue; + const r = base + LANES[li]; + k++; + num = (k === 1) ? W - N * r : num + W - N * (r - prev); + prev = r; + if (num > maxNum) maxNum = num; + if (num - W < minNum) minNum = num - W; + if (num >= 0 && num <= W) rzC++; + if (num > 0 && num < W) rzS++; + accPush(acc, r); + } + } + } + assert(k === N, `x = 31 slot count ${k} != D ${N}`); + assert(Math.abs(num) < 2 ** 52 && Math.abs(maxNum) < 2 ** 52 && Math.abs(minNum) < 2 ** 52, 'numerator left the exact range'); + const max = maxNum / W, min = minNum / W; + console.log(` ${String(X).padStart(2)} | ${String(W).padStart(9)} | ${String(N).padStart(11)}` + + ` | ${f(W / N, 4).padStart(8)} | ${f(max, 4).padStart(10)} | ${f(min, 4).padStart(10)}` + + ` | ${f(max - min, 4).padStart(7)} | ${String(rzC).padStart(10)} | ${(rzC / N * 100).toFixed(2)}% <- x = 31, scratch copy, exact integers`); + let s = null; + try { s = accClose(acc); } catch (e) { console.log(` x = 31 float engine: ${e.message}`); } + console.log(` x = 31 detail: max = ${maxNum}/${W}, min = ${minNum}/${W}; rising zeroes closed ${rzC}, strict ${rzS}; ` + + (s ? `float engine: max ${f(s.max, 6)}, min ${f(s.min, 6)}, rising zeroes ${s.rz}, sd ${f(s.sd, 4)}, drift ${s.drift.toExponential(2)}` : 'float engine: no result') + + `; ${((Date.now() - tB) / 1000).toFixed(0)} s`); + if (s) TWO[31] = s; +} + +// =========================================================================== // PART C — THE L2 DISCREPANCY, AND THE PARSEVAL IDENTITY TO natal-cap-29 // =========================================================================== // PROVEN (Parseval). For ANY periodic point set T mod W with S(j) = sum_{r in T}