// Independently derive #156's tail bound U (case C) rather than accept it. // Case C: b <= T < b^k. Then r(b^(k+1)) and r(b^k) are both bounded by EPS // (Dusart, y > T), and r(b) is exact. So the beta bracket // r(b^(k+1)) - r(b^k) - r(b) <= 2*EPS + max_{3<=b<=T} ( -r(b) ), r(y)=ln(theta(y)/y). const T = 1e7; const comp = new Uint8Array(T + 1); for (let i = 2; i * i <= T; i++) if (!comp[i]) for (let j = i * i; j <= T; j += i) comp[j] = 1; const TH = new Float64Array(T + 1); { let s = 0, c = 0; for (let n = 2; n <= T; n++) { if (!comp[n]) { const y = Math.log(n) - c, t = s + y; c = (t - s) - y; s = t; } TH[n] = s; } } let best = -Infinity, at = 0; for (let b = 3; b <= T; b++) { const v = Math.log(b) - Math.log(TH[b]); if (v > best) { best = v; at = b; } } const EPS = -Math.log(1 - 0.2 / (Math.log(T) ** 2)); console.log('max over 3<=b<=1e7 of -r(b) = ln(b/theta(b)) : ' + best.toFixed(9) + ' at b=' + at); console.log('EPS : ' + EPS.toExponential(6)); console.log('U = max(-r(b)) + 2*EPS : ' + (best + 2 * EPS).toFixed(6)); console.log("#156 states U = 0.804637, attained in case C at b = 4"); console.log('max_A (beta coeff) : 1.166713'); console.log('margin max_A - U : ' + (1.166713 - (best + 2 * EPS)).toFixed(6) + ' (#156: 0.362077)'); console.log('strict? : ' + ((best + 2 * EPS) < 1.166713));