"""route176/growth_table.py -- the S(H) growth table from the engine's exact F values. Reads the served engine dump (outputs/job2038/F_dump.txt, the `def.c` output for h <= 4000) and reports S(H) = sum_{2<=h<=H} (F(h) - 1) with the two competing normalisations and the local exponent b in S ~ H^b. Exact floating-point summation of exact per-element values. This is the pre-registered falsifier of the c*H*loglogH law: H1 S/(H loglog H) must be flat; H2 the local exponent b must fall to 1. """ from __future__ import annotations import math import sys DUMP = "outputs/job2038/F_dump.txt" LEVELS = (500, 1000, 2000, 3000, 3998) def load(path: str = DUMP) -> dict[int, float]: vals: dict[int, float] = {} with open(path) as fh: for line in fh: parts = line.split() if len(parts) == 2: vals[int(parts[0])] = float(parts[1]) return vals def main() -> int: vals = load() tot = 0.0 rows = [] for h in range(2, max(LEVELS) + 1): tot += vals.get(h, 0.0) if h in LEVELS: rows.append((h, tot - h)) print(f"{'H':>6} {'S(H)':>14} {'S/H':>10} {'S/(H lnH)':>12} {'S/(H lnlnH)':>14}") for H, S in rows: print(f"{H:6d} {S:14.4f} {S/H:10.4f} {S/(H*math.log(H)):12.6f} " f"{S/(H*math.log(math.log(H))):14.6f}") print() print("local exponents b = log(S2/S1)/log(H2/H1):") for (H1, S1), (H2, S2) in zip(rows, rows[1:]): print(f" {H1:5d} -> {H2:5d}: b = {math.log(S2/S1)/math.log(H2/H1):.4f}" f" S/H: {S1/H1:.4f} -> {S2/H2:.4f}") return 0 if __name__ == "__main__": sys.exit(main())