#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Step (b)/(c) bookkeeping, measured: the three quantities the write-out needs. 1. C := sum_m |h(m)|/m^{1/2} = prod_{p>=7} (1 + 4/((p-4) p^{1/2})) -- the truncation-tail constant. Partial sums show it converges to a value < 3, so the tail is C * Phi_bl / sqrt(T). 2. W := sum_{m<=N} |h(m)| tau(m) -- is the m-weight really only a log power? (The corpus note guessed log^8 T; the Dirichlet series prod_p (1 + 8/((p-4)p) + ...) converges, so it should be O(1).) 3. the condition split. In step (b) the constraints live on the product e = m e': e y-friable <=> m and e' both y-friable; e squarefree <=> both squarefree and (m,e') = 1. Since e' <= 2E/m, once 2E/m <= y BOTH conditions on e' are vacuous (every integer <= y is y-friable, and squarefree-ness is still a condition -- so measure them separately). The m for which the *friability* of e' binds are the only m where step (c) has to sieve. """ from math import gcd, isqrt import importlib.util import os HERE = os.path.dirname(os.path.abspath(__file__)) _spec = importlib.util.spec_from_file_location("sbc", os.path.join(HERE, "steps-bc-check.py")) sbc = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(sbc) def n_divisors(n): c = 0 for i in range(1, isqrt(n) + 1): if n % i == 0: c += 1 if i * i == n else 2 return c def is_friable(n, y, spf): while n > 1: p = spf[n] if p > y: return False while n % p == 0: n //= p return True def is_squarefree(n, spf): while n > 1: p = spf[n] k = 0 while n % p == 0: n //= p k += 1 if k > 1: return False return True def main(): L, y = sbc.build(17) # L = 17# = 510510, y = 709 spf, f = sbc.sieve_tables(200000, y) print("== 1. truncation-tail constant C(N) = sum_{m<=N} |h(m)| / sqrt(m) ==") for N in (1000, 10000, 100000): tot = 0.0 for m in range(1, N + 1): h = sbc.h_of(m, y, spf) if h is not None: tot += abs(float(h)) / m ** 0.5 print(" N=%-7d C(N) = %.6f" % (N, tot)) prod = 1.0 for p in sbc.primes_upto(3001): if p >= 7: prod *= 1.0 + 4.0 / ((p - 4) * p ** 0.5) print(" Euler product, 7 <= p <= 3001 : %.6f (converges; limit < 3)" % prod) print("== 2. m-weight W(N) = sum_{m<=N} |h(m)| tau(m) ==") for N in (100, 1000, 10000, 100000): tot = 0.0 for m in range(1, N + 1): h = sbc.h_of(m, y, spf) if h is not None: tot += abs(float(h)) * n_divisors(m) print(" N=%-7d W(N) = %.6f" % (N, tot)) print("== 2b. the same W with y huge (friability never binds): does it grow like (log N)^8 ? ==") import math spf2, _ = sbc.sieve_tables(2000000, 10 ** 7) for N in (100, 1000, 10000, 100000, 1000000): tot = 0.0 for m in range(1, N + 1): h = sbc.h_of(m, 10 ** 7, spf2) if h is not None: tot += abs(float(h)) * n_divisors(m) print(" N=%-8d W(N) = %-14.4f (log N)^8 = %-14.4f ratio = %.3e" % (N, tot, math.log(N) ** 8, tot / math.log(N) ** 8)) for E in (2000,): print("== 3. conditions on e' : e' in (E/m, 2E/m], E=%d, y=%d ; 2E/y = %.2f ==" % (E, y, 2 * E / y)) for m in (1, 2, 3, 4, 5, 6, 8, 16, 64): lo, hi = E // m + 1, 2 * E // m if lo > hi or lo > 200000: continue tot = fri = sqf = 0 for ep in range(lo, hi + 1): if gcd(ep, 30) != 1: continue tot += 1 if not is_friable(ep, y, spf): fri += 1 if not is_squarefree(ep, spf): sqf += 1 print(" m=%-3d e' in (%d,%d] coprime to 30: %-5d | not y-friable: %-5d (%5.2f%%) " "| not squarefree: %-5d (%5.2f%%)" % (m, lo - 1, hi, tot, fri, 100.0 * fri / max(1, tot), sqf, 100.0 * sqf / max(1, tot))) return 0 if __name__ == "__main__": raise SystemExit(main())