"""Limit check: an infinite half-life (stock frozen at the no-AI path) must equal eps = 0 in the paper's instantaneous rule, run for run and month by month, to within 1e-12. It is not bitwise: the frozen run carries forward the stock the capital market cleared at, a bisection root accurate to about 1e-16, rather than exactly 1. Usage: python -I frozen_check.py PKG_DIR """ import math import sys from dataclasses import replace sys.path.insert(0, sys.argv[1]) from econ_scenarios import EXTREME, MODEST, SUBSTANTIAL, Calibration, simulate # noqa: E402 worst, identical, n = 0.0, True, 0 for s in (MODEST, SUBSTANTIAL, EXTREME): for xi in (0.0, 0.5, 0.9): cal = replace(Calibration(), xi=xi) frozen = simulate(s, cal, capital_half_life=math.inf).series eps0 = simulate(s, replace(cal, eps=0.0)).series n += 1 for name in frozen: for x, y in zip(frozen[name], eps0[name], strict=True): if x != y and not (math.isnan(x) and math.isnan(y)): identical = False worst = max(worst, abs(x - y)) print(f"runs compared: {n}; bitwise identical: {identical}; largest abs difference: {worst:.3g}") print("PASS (within 1e-12)" if worst <= 1e-12 else "FAIL") sys.exit(0 if worst <= 1e-12 else 1)