Files
sim-numerics/diag_flat_detectable.py
T
vvsandClaude Opus 5 de1f8f726d The new sections move into the canonical text, article/sim_numerics.md (Valeri's decision): section 7 'Where the similarity is read' with 7.1 per-place similarity, 7.2 the decision place, 7.3 the fun7 scoring artefact, 7.4 the gap decomposition; negative results 8-11 appended so items 1-7 keep their numbers; abstract paragraph; Future work rewritten (the refuted log transform removed); item 6 now says aps.13.00 is a scoring artefact, not a method failure. Translated into the .md's revised names: code 'ratio' = the tent max(0,1-|z|), code 'rational' = the ratio similarity 1/(1+|z|); the proposed method stays the .md's (tent, 3-point, projection).
Found on the way: negative item 'log change of variable' compared 3474 with 4516, the total of a DIFFERENT configuration; the honest pair is the same configuration in x, CHA 3643 -> 3474, APS 5822 -> 6940. Fixed in both texts. The gap-decomposition numbers were only traced to saved logs; they are now RECOMPUTED by verify_article.py from fresh runs of the diagnosis scripts (which return their values): 216 checks OK on Linux, 762 tests pass twice.

Open, for Valeri: the .md still says the projection's doubling is 'not a tuning constant', which simroot/pure.py (project_credit) refutes and which is why the .tex proposes credit; the .md's Tables 2-3 predate Chandrupatla's own method as a baseline (2785 APS, first place), so its 'parity' abstract is out of date; Brent 2890/4101 in the .md against 2889/4099 in the current sweep.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 07:48:55 +01:00

70 lines
2.7 KiB
Python

"""Is the flat regime DETECTABLE from evaluations already paid for?
Established by diag_model_order.py and its checks: two thirds of the wide-bracket gap sit
on the flat families (fun3-fun6), where Chandrupatla bisects 93-100% of his steps and our
step removes 0.41-0.81 halvings of the bracket per evaluation - less than bisection's 1.
On an approach |f| ~ K e^m the tangent step lands at e(1 - 1/m): it beats bisection's
halving only while 1 - 1/m < 1/2, i.e. m < 2. The 2 is bisection's 1/2 rewritten, not a
chosen number. m is what _local_order reads from the three latest evaluations.
Question measured here, BEFORE anything is built: does "m >= 2" separate the states of
the flat families from the states of the canonical set? _local_order is known to fire
falsely (derived3_m: m > 1 on 27.9% of APS steps, excursions to 34.8), so the separation
is the whole question. If APS states cross m >= 2 about as often as flat ones, the regime
is NOT detectable this way and no gate may be built on it.
python -u diag_flat_detectable.py
"""
from __future__ import annotations
from collections import defaultdict
from scipy.optimize._tstutils import _APS_TESTS_DICTS, _CHANDRUPATLA_TESTS_DICTS
from diag_model_order import ACC, MAXFEV, OURS, XTOL
from simroot.pure import _local_order, pure_root
FLAT = ("fun3", "fun4", "fun5", "fun6")
def states(f, a, b, r):
st = {"trace": []}
x, _n, conv = pure_root(f, a, b, XTOL, MAXFEV, stats=st, **OURS)
if not (conv and abs(float(x) - r) <= ACC):
return []
out = []
for s in st["trace"]:
if s["xp2"] is None:
continue
out.append(_local_order(s["x"], s["fx"], s["xp"], s["fp"], s["xp2"], s["fp2"]))
return out
def main():
groups = defaultdict(list)
for d in _APS_TESTS_DICTS:
a, b = (float(v) for v in d["bracket"])
f = (lambda ff, aa: lambda t: ff(t, *aa))(d["f"], d.get("args", ()))
groups["APS (canonical)"] += states(f, a, b, float(d["root"]))
for d in _CHANDRUPATLA_TESTS_DICTS:
a, b = (float(v) for v in d["bracket"])
fam = str(d["ID"]).split(".")[0]
key = "CHA flat fun3-6" if fam in FLAT else "CHA other"
groups[key] += states(d["f"], a, b, float(d["root"]))
print(f"{'group':<18} {'states':>7} {'m > 1':>8} {'m >= 2':>8}")
shares = {}
for k in ("APS (canonical)", "CHA other", "CHA flat fun3-6"):
ms = groups[k]
n = max(len(ms), 1)
gt1 = 100.0 * sum(m > 1.0 for m in ms) / n
ge2 = 100.0 * sum(m >= 2.0 for m in ms) / n
shares[k] = (len(ms), gt1, ge2)
print(f"{k:<18} {len(ms):7d} {gt1:7.1f}% {ge2:7.1f}%")
return shares # for verify_article.py
if __name__ == "__main__":
main()