Files
sim-numerics/diag_flat_detectable.py
T
vvsandClaude Opus 5 f5d036c9d8 Why the wide-bracket gap remains, taken apart on the SAME evaluations: 'order of the model' explains only a third. Of the 262 evaluations lost on 33 problems, 178 sit on fun3-fun6 - pure powers of order 3, 5, 9, 19 - where no interpolating model works (our step 0.41-0.81 bracket halvings per evaluation, IQI from our own points 0.01-0.17) and Chandrupatla wins by BISECTING 93-100% of his steps; our step is slower than bisection there and our 2x-bisection guarantee licenses it. His band inside our step confirms it per family: fun4/5/6 573/456/456 -> 296/239/235 against his 293/228/228, while +164/+111/+170/+144 on fun1/2/8/9 where it refuses good steps - slot 2's total was two opposite effects summed. Only fun1 (58) is model order: IQI from our three points 10.37 halvings against our 0.62; a convex two-point step cannot carry IQI's negative weight (428/428 non-degenerate states; five underflowed to -0.0).
The flat regime is not detectable by the three-point order estimate: m >= 2 (the exact condition for a tangent step to lose to a halving) fires on 0.2% of APS states and on only 5.8% of states of pure powers of order 3-19. Paper corrected where it said the whole gap is model order (widelimit, decision, abstract, future work - the refuted log transform removed). WARNING recorded in FINDINGS_model_order.md: article/sim_numerics.tex has carried a STALE header since the first commit (current text = sim_numerics.md, unchanged since 08-24); every paper edit of 09-20/21 went into the .tex, the .md has none of them. Which file is canonical is Valeri's call. The new text numbers trace to results_diag_*.txt but are not yet machine-checked by verify_article.py. Trace hook in pure_root is behaviour-neutral and pinned; 762 pass on the server twice.

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

67 lines
2.6 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}")
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
print(f"{k:<18} {len(ms):7d} {gt1:7.1f}% {ge2:7.1f}%")
if __name__ == "__main__":
main()