# Denominator split of the band-limited minorant certificate for route 143 (job 4314). Builds on # minorant4293.py (#1927): same sieve t, same Selberg minorant m of [-1/2, h-1/2] at bandwidth 2/h, # same DC convention. Step (#1927, copied by #1932): # X_m(N) = (1/q) sum_{r != 0, |r|/q < 2/h} T(r) conj(M(r)) e(rN/q), mean_m = V * h/2. # Group in-band r by reduced denominator d = q/gcd(r,q) (r = a q/d, gcd(a,d) = 1). # X_{<=D} = part with d <= D; tail(D) = (1/q) sum_{in band, d > D} |T(r)||M(r)|. # Hybrid certificate: H(D) = max_N |X_{<=D}(N)| + tail(D) < mean_m => |X_m| < mean_m => S_m > 0 # => every length-h window meets the sifted set (m <= 1_[0,h), t >= 0). # Supplement (not in the step): sup_gt(D) = max|X_{>D}| measured exactly and H2(D) = max|X_{<=D}| + sup_gt(D), # which separates L1 mass of the large-denominator part from its actual size after phase cancellation. # Per curve row D = d: blk_sup = max|block_d|/mean_m and blk_L1 = L1 mass of block d / mean_m (within-block cancellation). # Method: the d-block is periodic mod d (e(rN/q) = e(aN/d)), so each block is one inverse FFT of size d; # X_{<=D} is accumulated over the divisors of q in increasing order by tiling blocks over Z/q. # D = 1: X_{<=1} = 0 (all-L1 baseline). D = q: H = max|X_m| (tail 0), the k -> infinity limit of #1927's # moment certificate. # GATES: (a) sum of all blocks == irfft of the in-band spectrum (max abs diff); (b) max|X_m|/mean_m at D = q # equals #1927's recorded m.max for that h (4 decimals); (c) band term count equals #1932's premise count. # usage: split4314.py results4293.json x dim [steps=1] stdout: one JSON line per h; progress on stderr import sys, json, math import numpy as np res = json.load(open(sys.argv[1])) x, dim = int(sys.argv[2]), int(sys.argv[3]) rec = res['%d_%d' % (x, dim)] P = [p for p in range(2, x + 1) if all(p % r for r in range(2, int(p ** 0.5) + 1))] q = math.prod(P) assert q == rec['q'] t = np.ones(q, dtype=np.float64) for p in P: t[0::p] = 0 if dim == 2: t[(p - 2) % p::p] = 0 V = t.sum() / q T = np.fft.rfft(t) xi = np.arange(len(T), dtype=np.float64) def Mhat(h): # copied from minorant4293.py (#1927), unchanged d = 2.0 / h; a, b = -0.5, h - 0.5 tt = xi / q; tau = tt / d M = np.zeros(len(xi), dtype=np.complex128) inb = tau < 1 ti, ta = tt[inb], tau[inb] with np.errstate(divide='ignore', invalid='ignore'): Jh = np.where(ta == 0, 1.0, np.pi * ta * (1 - ta) / np.tan(np.pi * ta) + ta) ea, eb = np.exp(-2j * np.pi * ti * a), np.exp(-2j * np.pi * ti * b) chi = np.where(ti == 0, b - a, (ea - eb) / (2j * np.pi * ti)) M[inb] = Jh * chi - (1.0 / (2 * d)) * (1 - ta) * (ea + eb) return M, int(inb.sum()) rows = sorted(rec['rows'], key=lambda r: r['h']) hm = rec['summary']['m']['h_cert'] hs_grid = [r['h'] for r in rows] i = hs_grid.index(hm) STEPS = int(sys.argv[4]) if len(sys.argv) > 4 else 1 targets = [('h_m', hm)] + [('h_m+%d' % s, hs_grid[i + s]) for s in range(1, STEPS + 1) if i + s < len(hs_grid)] e = lambda v: round(math.log(v) / math.log(x), 3) for which, h in targets: M, _ = Mhat(h) mean_m = V * M[0].real R = int(np.flatnonzero(np.abs(M) > 0).max()) # last in-band r (one-sided, r >= 1 below) r = np.arange(1, R + 1) g = np.gcd(r, q); den = q // g coef = T[1:R + 1] * np.conj(M[1:R + 1]) # one-sided; X = (2/q) Re sum coef e(rN/q) absc = 2.0 * np.abs(coef) / q # L1 weight of the +-r pair nzT = np.abs(T[1:R + 1]) > 1e-6 * T[0].real ds = sorted(set(den.tolist())) spec = np.zeros(len(T), dtype=np.complex128); spec[1:R + 1] = coef Xm = np.fft.irfft(spec, n=q) supX = float(np.abs(Xm).max()) acc = np.zeros(q) total_L1 = float(absc.sum()) L1_by_d = {d: float(absc[den == d].sum()) for d in ds} out_rows = []; cum_terms = 0; cum_nz = 0; tail = total_L1 base = {'D': 1, 'sup': 0.0, 'tail': round(total_L1 / mean_m, 6), 'H': round(total_L1 / mean_m, 6), 'terms': 0, 'terms_nonzeroT': 0, 'sup_gt': round(supX / mean_m, 6), 'H2': round(supX / mean_m, 6)} out_rows.append(base) for d in ds: sel = den == d a = (r[sel] * d) // q # numerators a (1 <= a < 2d/h) blk = np.zeros(d, dtype=np.complex128) blk[a % d] = coef[sel] # block(N) = (2/q) Re sum_a coef_a e(aN/d), N mod d; np.fft.ifft includes 1/d b = (2.0 / q) * np.real(np.fft.ifft(blk)) * d acc += np.tile(b, q // d) tail -= L1_by_d[d] cum_terms += 2 * int(sel.sum()); cum_nz += 2 * int((sel & nzT).sum()) sup = float(np.abs(acc).max()); sgt = float(np.abs(Xm - acc).max()) out_rows.append({'D': d, 'sup': round(sup / mean_m, 6), 'tail': round(max(tail, 0.0) / mean_m, 6), 'H': round((sup + max(tail, 0.0)) / mean_m, 6), 'terms': cum_terms, 'terms_nonzeroT': cum_nz, 'sup_gt': round(sgt / mean_m, 6), 'H2': round((sup + sgt) / mean_m, 6), 'blk_sup': round(float(np.abs(b).max()) / mean_m, 9), 'blk_L1': round(L1_by_d[d] / mean_m, 9)}) # gates gate_a = float(np.abs(Xm - acc).max() / mean_m) recmax = next(rr['m']['max'] for rr in rows if rr['h'] == h) gate_b = {'max_over_mean': round(float(np.abs(Xm).max() / mean_m), 4), 'recorded_1927': recmax} cert = [o for o in out_rows if o['H'] < 1] least = cert[0] if cert else None first_below = None # least D from which H stays < 1 for all larger D for o in reversed(out_rows): if o['H'] >= 1: break first_below = o line = {'x': x, 'dim': dim, 'q': q, 'which': which, 'h': h, 'exp_h': e(h), 'mean_m': round(mean_m, 6), 'band_terms': 2 * R, 'band_terms_nonzeroT': 2 * int(nzT.sum()), 'n_denominators': len(ds), 'min_band_d': ds[0], 'L1_over_mean': round(total_L1 / mean_m, 4), 'least_D': None if least is None else least['D'], 'least_D_log': None if least is None else round(math.log(least['D']) / math.log(x), 3), 'least_D_terms': None if least is None else least['terms'], 'D_from_which_all_certify': None if first_below is None else first_below['D'], 'H_at_D_le_h': min((o for o in out_rows if o['D'] <= h), key=lambda o: o['H'])['H'], 'H_at_D_lt_q_over_x': min((o for o in out_rows if o['D'] < q / x), key=lambda o: o['H'])['H'], 'H2_at_D_le_h': min((o for o in out_rows if o['D'] <= h), key=lambda o: o['H2'])['H2'], 'H2_at_D_lt_q_over_x': min((o for o in out_rows if o['D'] < q / x), key=lambda o: o['H2'])['H2'], 'sup_gt_at_D_le_h': [o for o in out_rows if o['D'] <= h][-1]['sup_gt'], 'gate_a_blocks_vs_irfft': float('%.3e' % gate_a), 'gate_b': gate_b, 'curve': out_rows} print(json.dumps(line), flush=True) print('x', x, 'dim', dim, which, 'h', h, 'least_D', line['least_D'], 'gate_a', line['gate_a_blocks_vs_irfft'], gate_b, file=sys.stderr, flush=True)