# -*- coding: utf-8 -*- """The same ratios with the corpus's own 2,3,5 layer put back in. The pre-registration defines R with lam0, lam1 and Delta_{de}(c_{de}) only. The corpus's actual weight is D_y lam0 lam1 lam1 times the 2,3,5 factors, and the 5-part is NOT a constant across pairs: it enters as the layer m = 5n with the three classes c5 = 0,1,4 (mod 5) and weights 15, 7.5, 7.5, exactly as the corpus's PART B reconstructs the whole object at x = 7. This script answers whether that layer moves R. """ import importlib.util, math, sys sys.stdout.reconfigure(encoding='utf-8') spec = importlib.util.spec_from_file_location('km', 'work/kl-measure.py') km = importlib.util.module_from_spec(spec) spec.loader.exec_module(km) FIVE = [(0, 15.0), (1, 7.5), (4, 7.5)] def run(x, band=True, N_div=1): L, y = km.LV[x] ps = [p for p in km.primes_upto(y) if p >= 7] N = int(L * math.log(y) ** 2) // N_div Bc = L ** 0.4 K = L / 6.0 # the corpus's own K = L/6 (h = 6k) acc = [0.0, 0.0, 0] def crt(c, n, c5): m = 5 * n for a in range(c % n, m, n): if a % 5 == c5: return a return None def add(s, l0s, l1s, t, l0t, l1t): n = s * t for (dd, ee, w0, w1) in ((s, t, l0s, l1t), (t, s, l0t, l1s)): tau = (2 * pow(dd, -1, ee)) % ee c = (dd * tau) % n for c5, w5 in FIVE: cc = crt(c, n, c5) m = 5 * n r = K % m R = (max(0, r - cc) + max(0, r + cc - m) - r * r / m) / K v = w0 * w1 * w5 * R acc[0] += v acc[1] += abs(v) acc[2] += 1 def rec_s(i, s, sprimes, l0s, l1s): for j in range(i, len(ps)): p = ps[j] ss = s * p if ss > Bc: break ns = sprimes + (p,) nl0, nl1 = l0s * 2.0 / (p - 4), l1s * 1.0 / (p - 4) lim = N // ss if lim >= ss: allowed = [q for q in ps if q <= lim and q not in ns] def rec_t(k, t, l0t, l1t): if t >= ss: add(ss, nl0, nl1, t, l0t, l1t) for mm in range(k, len(allowed)): q = allowed[mm] if t * q > lim: break rec_t(mm + 1, t * q, l0t * 2.0 / (q - 4), l1t * 1.0 / (q - 4)) for k in range(len(allowed)): q = allowed[k] if q > lim: break rec_t(k + 1, q, 2.0 / (q - 4), 1.0 / (q - 4)) rec_s(j + 1, ss, ns, nl0, nl1) rec_s(0, 1, (), 1.0, 1.0) return acc for x in (13, 17): a = run(x) print("x=%-2d with the 2,3,5 layer: signed=%+.6f abs=%.6f R=%.6f (contributions %d)" % (x, a[0], a[1], abs(a[0]) / a[1], a[2]))