A' code frozen BEFORE the corpus-4 run (PREREG_close_sub): close (borrowed Dekker/Brent tolerance step, only after a kept promise) and sub (overshoot branch m <= 2/3; the shallow memory is not cleared by the exit - amendment documented). Development on the five seen corpora (uniform sign-change criterion): A' below A everywhere; vs Chandrupatla APS 103/31, CHA 31/10, new-1 109/65, Roots.jl 44/20 p=0.004, applied 48/32 p=0.09 with total 1382 vs 1380. Tests: 1223 passed (full), 358 (gate files).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+44
-3
@@ -764,19 +764,21 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
# category variables below then carry the same string the old tests compared.
|
||||
if "+" in prestep:
|
||||
parts = prestep.split("+")
|
||||
cats = ({"defect"}, {"contra"}, {"exp"}, {"half"}, {"flatanalog", "flatanalogmem", "flatanalogpt",
|
||||
cats = ({"defect"}, {"contra"}, {"exp"}, {"half"}, {"close"}, {"sub"},
|
||||
{"flatanalog", "flatanalogmem", "flatanalogpt",
|
||||
"flatanalogmempt"})
|
||||
if (len(parts) != len(set(parts)) or any(not any(p in c for c in cats) for p in parts)
|
||||
or any(sum(p in c for p in parts) > 1 for c in cats)):
|
||||
raise ValueError(f"unknown composite prestep {prestep!r}")
|
||||
if "exp" in parts and not any(p.startswith("flatanalog") for p in parts):
|
||||
if (("exp" in parts or "sub" in parts)
|
||||
and not any(p.startswith("flatanalog") for p in parts)):
|
||||
# the translation limit changes how the analogy reads its order; without the
|
||||
# flat regime there is no analogy to read (PREREG_flat_exp_limit)
|
||||
raise ValueError("prestep component 'exp' needs a flatanalog* component")
|
||||
elif prestep not in ("none", "progress", "slope", "band", "defect", "simpair", "flat",
|
||||
"flat2", "flatcreep", "flatstick", "flatstickmid", "flatstickexit",
|
||||
"flatjudge", "flatanalog", "flatanalogmem", "contra",
|
||||
"flatanalogpt", "flatanalogmempt", "half"):
|
||||
"flatanalogpt", "flatanalogmempt", "half", "close"):
|
||||
raise ValueError(f"unknown prestep {prestep!r}")
|
||||
parts = prestep.split("+")
|
||||
pre_dec = next((p for p in parts if p in ("band", "defect", "simpair")), "none")
|
||||
@@ -788,6 +790,8 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
pre_contra = "contra" in parts
|
||||
pre_exp = "exp" in parts # PREREG_flat_exp_limit: translation similarity, m = inf
|
||||
pre_half = "half" in parts # PREREG_half_contra: the half promised vs the bracket
|
||||
pre_close = "close" in parts # PREREG_close_sub: the tolerance step (borrowed)
|
||||
pre_sub = "sub" in parts # PREREG_close_sub: the overshoot branch, m <= 2/3
|
||||
if pre_dec != "none" and scale not in (
|
||||
"derived3", "derived3_cap", "derived3_m", "bracket", "far"):
|
||||
# the decision reads a TRIPLE; under the two-point scale there is no third point
|
||||
@@ -847,6 +851,8 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
analogy_seen = False # flatanalogmem: the run has been judged analogous to its past
|
||||
analogy_m = math.inf # flatanalog*pt: the order read from the latest analogous pair
|
||||
regime_target = None # flatanalog*pt: the point the regime step aimed at
|
||||
shallow_seen = False # sub: the run has been judged analogous with m <= 2/3
|
||||
shallow_m = math.inf # sub: the order of that pair
|
||||
if stats is not None:
|
||||
stats['forced'] = 0
|
||||
stats['pre_refused'] = 0
|
||||
@@ -1079,15 +1085,32 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
and fx / f_prev >= 0.25)
|
||||
m_pair = _analogy_order(cur, configs, translation=pre_exp)
|
||||
steep = m_pair is not None and m_pair >= 2.0
|
||||
# PREREG_close_sub 2026-09-21 (sub): the tangent step loses to a halving
|
||||
# when |1 - 1/m| > 1/2 - for m > 2 (undershoot, the branch above) AND
|
||||
# for m < 2/3 (overshoot). The overshoot shows as an unkept promise WITH
|
||||
# a sign change; the pair's order says which branch it is.
|
||||
shallow = (pre_sub and m_pair is not None
|
||||
and 0.0 < m_pair <= 2.0 / 3.0)
|
||||
flag_over = (pre_sub and sticky_m is None and last_model
|
||||
and f_prev != 0.0 and fx / f_prev <= -0.25)
|
||||
if flat_mem:
|
||||
if steep:
|
||||
analogy_seen = True
|
||||
analogy_m = m_pair
|
||||
if shallow:
|
||||
shallow_seen = True
|
||||
shallow_m = m_pair
|
||||
enter = flag and analogy_seen
|
||||
if not enter and flag_over and shallow_seen:
|
||||
enter = True
|
||||
analogy_m = shallow_m
|
||||
else:
|
||||
enter = flag and steep
|
||||
if enter:
|
||||
analogy_m = m_pair
|
||||
elif flag_over and shallow:
|
||||
enter = True
|
||||
analogy_m = m_pair
|
||||
if enter:
|
||||
sticky_m = math.inf
|
||||
if stats is not None:
|
||||
@@ -1207,6 +1230,19 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
reach = abs(far - x)
|
||||
step = (longer if abs(longer) <= reach
|
||||
else math.copysign(reach, step))
|
||||
if (pre_close and abs(step) < 0.5 * xtol and last_model
|
||||
and f_prev != 0.0 and abs(fx / f_prev) < 0.25):
|
||||
# Only a CREDIBLE promise is closed on: the model's previous step
|
||||
# kept its own promise (|f| fell below the flag's 1/4). Measured in
|
||||
# development on x^19: at the start, a slope dominated by f(100) =
|
||||
# 1e38 promises the root at x = -10, and closing on that promise
|
||||
# replaced the midpoint by near-duplicate points (23 -> 32).
|
||||
# PREREG_close_sub 2026-09-21 (close) - BORROWED: Dekker (1969) and
|
||||
# Brent (1973) step at least the tolerance. A model promising the
|
||||
# root closer than xtol/2 is taken at its word one step further: the
|
||||
# new point lands past the root and the bracket closes to the
|
||||
# tolerance, instead of being halved down from the far end.
|
||||
step = math.copysign(0.5 * xtol, far - x)
|
||||
model_target = x + step # the model's own proposal
|
||||
if stats is not None and "trace" in stats:
|
||||
# DIAGNOSTIC HOOK, behaviour-neutral: records the state each
|
||||
@@ -1272,6 +1308,11 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
# flatanalogmem: "linear" refutes "flat" - the remembered analogy is
|
||||
# cleared and must be established anew (PREREG_flat_analogy_mem)
|
||||
analogy_seen = False
|
||||
# NOT shallow_seen (PREREG_close_sub, amendment): the exit judgment - f nearer
|
||||
# the line than 0 - tells a flat root from a simple one; at a root of order
|
||||
# m < 1 f is far from 0 on both sides, the exit fires falsely, and keeping the
|
||||
# shallow memory lets the regime resume at the next overshoot (development:
|
||||
# sqrt|x| sgn 19 with it, 65 without)
|
||||
if stats is not None:
|
||||
stats['stick_exits'] = stats.get('stick_exits', 0) + 1
|
||||
if prestep == "flatjudge":
|
||||
|
||||
Reference in New Issue
Block a user