// ============================================================================ // varE-theta2-step.js — scratchpad-grade support for varE-theta2-step.md // The DECOUPLING step of varE-spectral.md section 2, attacked at theta = 2. // ============================================================================ // WHAT THIS IS. varE-spectral.md evaluates X(L) = sum_{nu != 0 mod M} What(nu) // K_L(nu/M) after replacing every local coefficient hat f_p(nu) by its mean // gamma_p over nonzero frequencies. That replacement is an identity at one // excluded class and false pointwise at two. This file computes BOTH sums // exactly, in real space, at six diagonal levels, and splits the exact one // into the four groups the replacement conflates. // // THE REDUCTION (algebra, PART 0 checks it against the corpus's own numbers): // K_L(t) = sum_{|h| X = sum_{|h|= 7 gives 3^omega groups. Group 1 (every // prime takes p|h) is the ONLY one whose CRT class is 0, i.e. the only one // Fact A evaluates with no equidistribution assumption. // // PART 0 validation: X against variance-note section 7's nine exact points, // X_dec against varE-spectral PART 2's divisor enumeration. // PART 1 the exact per-prime identity that makes group 1 and the model // share a limit. // PART 2 X_dec EXACT at x = 13, 17, 19, 23 (new; the corpus had 7 and 11). // PART 3 the four-group split and its 1/ln y diagnostics. // node research/history/staging/varE-theta2-step.js (~5 s, ~1.2 GB peak) // ============================================================================ 'use strict'; const T0=Date.now(); const el=()=>((Date.now()-T0)/1000).toFixed(1)+'s'; function assert(c,m){ if(!c) throw new Error('ASSERT FAIL: '+m); } function primesUpTo(n){const s=new Uint8Array(n+1),o=[];for(let i=2;i<=n;i++){if(!s[i]){o.push(i);for(let j=i*i;j<=n;j+=i)s[j]=1}}return o} function inv6(p){for(let k=1;kp>=7); let delta=1; for(const p of allp){const a=(p===2||p===3)?1:(p===5?2:p-2); delta*=a/p;} // constants over p >= 7 let D=1,C=1,b1=1,b2=1; for(const p of ps){ const q=(p-2)*(p-2); D*=p*(p-4)/q; C*=1-2/((p-1)*(p-2)); b1*=(q-2)/q; b2*=(q-3)/q; // group means: beta1 (c=0), beta2 (c=+-2) } const bmix=1-b1-2*b2; // per-prime identity that ties group 1's weight to the model's let ident=D/C; for(const p of ps) ident*=1+2/((p-1)*(p-4)); // sieve the three multiplicative pieces on k = h/6 const P0=new Float64Array(KK).fill(1), PM=new Float64Array(KK).fill(1), PP=new Float64Array(KK).fill(1), PV=new Float64Array(KK).fill(1); for(const p of ps){ const a=(p-2)/(p-4), b=(p-3)/(p-4), c=(p-1)/(p-3), i6=inv6(p); for(let k=p;k group 1 carries pi_p = 2/(p-2), the model carries pi_p = 2/(p-1);'); console.log(' E[ln n] differs by sum 2 ln p/((p-1)(p-2)) = O(1), not O(ln y).'); console.log('\n=== PART 2: the replacement error, EXACT, at six levels ==='); console.log(' x | ln y | delta*X (=Var/E) | delta*X_dec exact | corpus model (MC) | delta*(X-X_dec) | X/X_dec'); for(const o of OUT){ const dX=o.delta*o.X, dXd=o.delta*o.Xd; console.log(' '+String(o.x).padStart(2)+' | '+o.lny.toFixed(3).padStart(6)+' | ' +dX.toFixed(6).padStart(16)+' | '+dXd.toFixed(6).padStart(17)+' | ' +String(o.note.mdl).padStart(17)+' | '+(dX-dXd).toFixed(6).padStart(15)+' | '+(o.X/o.Xd).toFixed(6)); } console.log('\n=== PART 3: the four groups, and the 1/ln y diagnostics ==='); console.log(' X = X1 (c=0) + 2*X2 (c=+-2) + Xmix; only X1 needs no equidistribution'); console.log(' x | delta*X1 | delta*X2 (each) | delta*Xmix | (X1-Xdec)*d*lny | (X-X1)*d*lny | (X-Xdec)*d*lny'); for(const o of OUT){ const d=o.delta; console.log(' '+String(o.x).padStart(2)+' | '+(d*o.X1).toFixed(6).padStart(8)+' | ' +(d*o.X2).toFixed(6).padStart(15)+' | '+(d*o.Xmx).toFixed(6).padStart(10)+' | ' +(d*(o.X1-o.Xd)*o.lny).toFixed(5).padStart(15)+' | '+(d*(o.X-o.X1)*o.lny).toFixed(5).padStart(12) +' | '+(d*(o.X-o.Xd)*o.lny).toFixed(5).padStart(14)); } console.log('\n group masses (means over the period, p >= 7 only):'); for(const o of OUT) console.log(' y='+String(o.y).padStart(6)+' beta1='+o.b1.toFixed(6) +' beta2='+o.b2.toFixed(6)+' beta_mix='+o.bmix.toFixed(6)); console.log('\n done '+el()); // ============================================================================ // OUTPUT — EMBEDDED, do not hand-edit. Regenerate: // node research/qc/embed.js research/history/staging/varE-theta2-step.js // invocation: node research/history/staging/varE-theta2-step.js // code-sha256: 91aca27772eb7122c3422dbac2e9923f3d0ade1740e28ba87cf11e29efc5af26 // out-sha256: 1aafa94cadeab6d141d47fa9ebb48c818413e721dc3ef9afbb8665cec6281f64 // body-lines: 49 // forced: 2026-09-05, 12 of 119 figures in the replaced block not reproduced (first: 0.094199, -0.241840, 0.047843, -0.133037) // streams: stdout // node: v22.21.0 // embedded: 2026-09-05 // elapsed: 1.7 s // ============================================================================ // === PART 0: the real-space reduction, validated === // X = sum_{|h| group 1 carries pi_p = 2/(p-2), the model carries pi_p = 2/(p-1); // E[ln n] differs by sum 2 ln p/((p-1)(p-2)) = O(1), not O(ln y). // // === PART 2: the replacement error, EXACT, at six levels === // x | ln y | delta*X (=Var/E) | delta*X_dec exact | corpus model (MC) | delta*(X-X_dec) | X/X_dec // 7 | 2.565 | 0.152075 | 0.178193 | 0.1785 | -0.026118 | 0.853427 // 11 | 3.850 | 0.256267 | 0.266839 | 0.26744 | -0.010572 | 0.960382 // 13 | 5.153 | 0.299499 | 0.296592 | 0.2975 | 0.002907 | 1.009802 // 17 | 6.564 | 0.326772 | 0.325504 | 0.32579 | 0.001268 | 1.003895 // 19 | 8.042 | 0.347302 | 0.346800 | 0.34637 | 0.000502 | 1.001448 // 23 | 9.611 | 0.364320 | 0.363842 | 0.36214 | 0.000477 | 1.001312 // // === PART 3: the four groups, and the 1/ln y diagnostics === // X = X1 (c=0) + 2*X2 (c=+-2) + Xmix; only X1 needs no equidistribution // x | delta*X1 | delta*X2 (each) | delta*Xmix | (X1-Xdec)*d*lny | (X-X1)*d*lny | (X-Xdec)*d*lny // 7 | 0.205517 | -0.009235 | -0.034971 | 0.07008 | -0.13708 | -0.06699 // 11 | 0.293618 | 0.004509 | -0.046368 | 0.10310 | -0.14381 | -0.04070 // 13 | 0.322208 | 0.001365 | -0.025439 | 0.13201 | -0.11703 | 0.01498 // 17 | 0.345842 | 0.000736 | -0.020542 | 0.13350 | -0.12518 | 0.00832 // 19 | 0.363348 | 0.000394 | -0.016835 | 0.13308 | -0.12905 | 0.00404 // 23 | 0.377724 | 0.000236 | -0.013876 | 0.13342 | -0.12883 | 0.00459 // // group masses (means over the period, p >= 7 only): // y= 13 beta1=0.882453 beta2=0.826397 beta_mix=-1.535247 // y= 47 beta1=0.855794 beta2=0.789184 beta_mix=-1.434162 // y= 173 beta1=0.850465 beta2=0.781823 beta_mix=-1.414112 // y= 709 beta1=0.849206 beta2=0.780087 beta_mix=-1.409380 // y= 3109 beta1=0.848952 beta2=0.779738 beta_mix=-1.408427 // y= 14929 beta1=0.848902 beta2=0.779669 beta_mix=-1.408240 // // done 1.6s // ============================================================================ // READINGS // // 1. THE REDUCTION IS EXACT AND CHECKED AT SIX LEVELS. Writing the Fejer // kernel as sum_{|h|= 13, so the residual column there is partly MC noise. // 8. WHAT IS NOT SHOWN. No bound on X2 or Xmix is derived. Nothing here // proves the 1/ln y behaviour of reading 4 continues past x = 23, and // x = 29 is out of reach for this method (L/6 = 1.1e9 array entries). // // FIGURE PROVENANCE. Readings quote the block above verbatim except: // 0.0046 = 0.13342 - 0.12883, the two settled coefficients of PART 3. // 0.0017 = 0.363842 - 0.36214, PART 2's x = 23 row. // 1.1e9 = 6469693230/6, from variance-note section 7's L at x = 29; // not a figure of this run.