// Deterministic check of the per-block BFI II saving above sqrt(x) (route 111, #1351 item 1). // For x = 2^k, blocks Q_j = sqrt(x) 2^j up to x^(1/2+eps'), eps' = 1/60: // saving per block s_j = (log y_j / log x)^2 with y_j = Q_j^2/x = 4^j, i.e. s_j = (2 j log 2 / log x)^2. // Compares BLOCKSUM = sum_j s_j with the asymptotic (4 eps'^3 / (3 log 2)) log x and with the top-block value 4 eps'^2. const eps = 1 / 60; for (const k of [200, 1000, 10000, 100000]) { const lx = k * Math.LN2, J = Math.floor(eps * k); let s = 0; for (let j = 1; j <= J; j++) s += (2 * j * Math.LN2 / lx) ** 2; const asym = (4 * eps ** 3 / (3 * Math.LN2)) * lx; console.log(`log2x=${k} blocks=${J} top_block=${((2 * J * Math.LN2 / lx) ** 2).toExponential(4)} BLOCKSUM=${s.toExponential(4)} asym=${asym.toExponential(4)} ratio=${(s / asym).toFixed(4)}`); }