# Absolute-value (fraction-count) majorant of the full-period moments, the quantity MV/Bloom-Maynard-style # positivity arguments bound. With f(N) = S_h(N) - mu on Z/q (q = x#), M_2k = sum_N f(N)^2k exactly, and # M^abs_2k = sum_N g(N)^2k with g = IFFT(|FFT f|) >= M_2k (it drops every phase in the fraction expansion). # For each h: least k <= KMAX with M_2k < mu^2k (true certificate) and with M^abs_2k < mu^2k (majorant certificate). # usage: python3 abs_majorant.py x dim h1,h2,... [kmax] (dim 1: gcd(n,x#)=1; dim 2: gcd(n(n+2),x#)=1) import sys, json, math import numpy as np x, dim, hl = int(sys.argv[1]), int(sys.argv[2]), [int(v) for v in sys.argv[3].split(',')] KMAX = int(sys.argv[4]) if len(sys.argv) > 4 else 64 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) t = np.ones(q, dtype=np.int8) for p in P: t[0::p] = 0 if dim == 2: t[(p - 2) % p::p] = 0 V = t.sum() / q c = np.concatenate(([0], np.cumsum(np.concatenate((t, t)), dtype=np.int64))) def lse(v): m = v.max(); return m + math.log(np.exp(v - m).sum()) rows = [] for h in sorted(hl): S = (c[h:h + q] - c[:q]).astype(np.float64) # S[N] = sum_{i