#!/usr/bin/env python3 """Job #4206 (route 165): price consumer (16)'s allowance -- is the LEVEL the binding constraint, or the sequence? Consumer (served as research/moving-cutoff-parity.md, sha256 ef7a1865...): x = 2^j, y = ceil(x^(12/25)), Q = floor(x/y), f(n) = Lambda(n-2)mu(n), and (13) |D_y| <= 2 * sum_{e<=Q, e odd} log(x/e) * max_t |Delta_e(t)|, with (16) met if that weighted sum is <= (2/25) x (the consumer's own remark: the first weighted absolute sum in (13) being <= 2x/25 suffices). What this prices. A statement of the CLASSICAL Bombieri-Vinogradov SHAPE for f at the consumer's own level, |Delta_e(t)| <= x / (phi(e) * log^A x) for every odd e <= Q, x/2 <= t <= x, (S_A) gives (13) <= 2 x / log^A x * T(j), where T(j) = sum_{e<=Q, e odd} log(x/e) / phi(e). So the allowance (2/25)x is met iff 2*T(j)/log^A x <= 2/25, i.e. T(j) <= log^A(x)/25. This script computes T(j) exactly (odd-e totient sum, exact integer cutoff y, Q), fits its growth, and reports * the minimum A that passes and the threshold log x above which it passes; * the same for other cutoffs y = x^theta (theta = 0.40, 0.48, 12/25, 0.60): the route's whole "which cutoff / which block" question, priced the same way; * controls: (i) trivial Delta_e bound (x/2)(1 + 1/phi(e)) in place of (S_A); (ii) phi(e) replaced by e; (iii) log(x/e) replaced by log x. Nothing here is a claim about (16), twin primes or the route's truth value: (S_A) is a HYPOTHETICAL input, and the point of the arithmetic is only whether the allowance is tight in the LEVEL/log-power currency. """ import json import math import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) sys.stdout.reconfigure(encoding="utf-8", errors="replace") JMAX = 44 THETA = (12, 25) def ceil_root(power, k): """smallest integer y >= 2^(power/k), exact integer arithmetic.""" lo, hi = 1, 1 << (power // k + 2) while lo < hi: mid = (lo + hi) // 2 if mid ** k >= (1 << power): hi = mid else: lo = mid + 1 return lo def cutoff(j, theta): """y = ceil(2^(j*theta)), Q = floor(2^j / y), exact.""" p, q = theta y = ceil_root(j * p, q) return y, (1 << j) // y def phi_sieve(n): phi = list(range(n + 1)) for i in range(2, n + 1): if phi[i] == i: for m in range(i, n + 1, i): phi[m] -= phi[m] // i return phi def main(): qmax = max(cutoff(j, THETA)[1] for j in range(8, JMAX + 1)) print("max modulus Q over j <= %d: %d (sieve)" % (JMAX, qmax)) PHI = phi_sieve(qmax) def T(j, theta=THETA, mode="bv", Qcap=None): x = 1 << j y, Q = cutoff(j, theta) if Qcap: Q = min(Q, Qcap) lx = j * math.log(2.0) tot = 0.0 for e in range(1, Q + 1, 2): w = lx if mode == "flat" else math.log(x / e) if mode == "trivial": tot += w * (x / 2.0) * (1.0 + 1.0 / PHI[e]) elif mode == "over_e": tot += w / e else: tot += w / PHI[e] return {"j": j, "x": x, "y": y, "Q": Q, "T": tot, "logx": lx} rows = [T(j) for j in range(8, JMAX + 1)] out = {"consumer_sha256": "ef7a18651d5d39ac45bb7f96727c0b2d6e16f39f620f359d63d220c6a7f2cd9d", "allowance_x": "2/25", "jmax": JMAX, "cutoff_1225": [{k: (round(v, 6) if isinstance(v, float) else v) for k, v in r.items()} for r in rows]} tail = [r for r in rows if r["j"] >= 32] out["growth_fit"] = {"c_max": max(r["T"] / r["logx"] ** 2 for r in tail), "c_min": min(r["T"] / r["logx"] ** 2 for r in tail), "c_last6": [round(r["T"] / r["logx"] ** 2, 5) for r in rows[-6:]]} c = out["growth_fit"]["c_max"] out["A_needed"] = [{"j": r["j"], "A_needed_real": math.log(25.0 * r["T"]) / math.log(r["logx"])} for r in rows] out["A_needed_max"] = max(q["A_needed_real"] for q in out["A_needed"]) thr = {} for A in range(1, 7): ok = [r["j"] for r in rows if 25 * r["T"] <= r["logx"] ** A] thr["A=%d" % A] = {"first_j_passing": ok[0] if ok else None, "n_passing": len(ok)} out["thresholds"] = thr out["asymptotic_logx_threshold"] = {("A=%d" % A): (round(math.log(25 * c) / (A - 2), 3) if A > 2 else None) for A in range(2, 7)} out["asymptotic_c"] = round(c, 5) sweep = {} for theta, name in (((2, 5), "theta=0.40"), ((12, 25), "theta=0.48"), ((13, 25), "theta=0.52"), ((3, 5), "theta=0.60")): sweep[name] = [] for j in (32, 36): # Q = x^(1-theta) must stay inside the shared sieve r = T(j, theta=theta) sweep[name].append({"j": j, "Q": r["Q"], "T": round(r["T"], 4), "A_needed_real": round(math.log(25 * r["T"]) / math.log(r["logx"]), 4)}) out["cutoff_sweep"] = sweep ctr = {} for mode in ("trivial", "over_e", "flat"): r = T(40, mode=mode) ctr[mode] = {"T": r["T"], "ratio_to_allowance": round(2 * r["T"] / (0.08 * (1 << 40)), 6)} r = T(40) ctr["bv_A3"] = {"T": round(r["T"], 4), "ratio_to_allowance": round(2 * r["T"] / (r["logx"] ** 3) / (0.08 * (1 << 40)), 6)} out["controls_j40"] = ctr with open(os.path.join(HERE, "price.json"), "w", encoding="utf-8", newline="\n") as fh: json.dump(out, fh, indent=1, sort_keys=True) fh.write("\n") print() print(" j Q T T/log^2x A_needed(real)") for r in rows[::4] + [rows[-1]]: print("%3d %10d %14.5f %11.6f %10.4f" % (r["j"], r["Q"], r["T"], r["T"] / r["logx"] ** 2, math.log(25.0 * r["T"]) / math.log(r["logx"]))) print() print("A_needed max over all computed j: %.4f" % out["A_needed_max"]) print("integer-A thresholds (first j passing):", {k: v["first_j_passing"] for k, v in thr.items()}) print("fitted c (T ~ c log^2x, tail max): %.5f" % c, " -> asymptotic log x thresholds:", out["asymptotic_logx_threshold"]) print("cutoff sweep:") for name, vs in sweep.items(): print(" %-11s" % name, [(v["j"], v["T"], v["A_needed_real"]) for v in vs]) print("controls at j=40:", json.dumps(ctr)) print("wrote price.json") if __name__ == "__main__": main()