PREREG_flat_stick outcome: NOT accepted. Sticky regime under the projection: CHA 3220 -> 3019 (W1 holds), flat fun3-6 1823 -> 1057 (W4, near pure bisection 1044), guarantee holds (W3), but APS 2806 -> 6781 (W2 fails): the unkept-promise flag enters on 134/154 APS problems and 20/25 non-flat CHA problems, and a false entry now sticks to the end of the run. W6 fails: the order read from the promise is m = inf in 163/174 entries (r >= 1/e; our step is not a pure tangent), so the derived split equals the midpoint on CHA (3019 both). Audit bug fixed and pinned: an infinite |f| at an end made the split nan. Server regression x2: 999 passed, 1 failed = the expected paper-number check.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+62
-1
@@ -549,6 +549,50 @@ def _slope3(x2, f2, x1, f1, x0, f0):
|
||||
return s if math.isfinite(s) else d12
|
||||
|
||||
|
||||
def _order_from_promise(r):
|
||||
"""The order m that a tangent step's unkept promise r = |f_new/f_old| implies.
|
||||
|
||||
PREREG_flat_stick 2026-09-21. On an order-m approach a tangent step leaves
|
||||
r = (1 - 1/m)^m, which rises monotonically from 1/4 at m = 2 to 1/e as m -> inf.
|
||||
Inverted on u = 1/m by halving until the float interval stops shrinking - a
|
||||
precision, not a chosen number. r >= 1/e has no finite solution: m = inf.
|
||||
Called only with r >= 1/4 (the flag's own condition); below it m = 2 is returned,
|
||||
the end of the range the flag admits."""
|
||||
if r >= math.exp(-1.0):
|
||||
return math.inf
|
||||
target = math.log(r)
|
||||
lo, hi = 0.0, 0.5 # u = 1/m in (0, 1/2]; h(u) = ln(1-u)/u falls with u
|
||||
while True:
|
||||
mid = 0.5 * (lo + hi)
|
||||
if mid == lo or mid == hi:
|
||||
break
|
||||
if math.log1p(-mid) / mid > target:
|
||||
lo = mid
|
||||
else:
|
||||
hi = mid
|
||||
return 1.0 / hi
|
||||
|
||||
|
||||
def _order_split(A, FA, B, FB, m):
|
||||
"""The point where |f| ~ |x - r|^m puts the root: the ends are at distances
|
||||
dA : dB = |FA|^(1/m) : |FB|^(1/m) from it. m = inf is the midpoint. Worked in
|
||||
logarithms so neither ratio can overflow; a point that lands on an end is caught
|
||||
by the loop's own fallback to the midpoint."""
|
||||
if math.isinf(m):
|
||||
return 0.5 * (A + B)
|
||||
lq = (math.log(abs(FA)) - math.log(abs(FB))) / m # ln (|FA|/|FB|)^(1/m)
|
||||
if not math.isfinite(lq):
|
||||
# an infinite |f| at an end: no power law to read, and a nan step would reach
|
||||
# the safeguard's bookkeeping before the loop's own finiteness check
|
||||
return 0.5 * (A + B)
|
||||
if lq > 0.0:
|
||||
t = 1.0 / (1.0 + math.exp(-lq))
|
||||
else:
|
||||
e = math.exp(lq)
|
||||
t = e / (1.0 + e)
|
||||
return A + t * (B - A)
|
||||
|
||||
|
||||
def _local_order(x2, f2, x1, f1, x0, f0):
|
||||
"""The local order m of f, from three evaluations and nothing else.
|
||||
|
||||
@@ -666,7 +710,7 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
if space not in SPACES:
|
||||
raise ValueError(f"unknown space {space!r}")
|
||||
if prestep not in ("none", "progress", "slope", "band", "defect", "simpair", "flat",
|
||||
"flat2", "flatcreep"):
|
||||
"flat2", "flatcreep", "flatstick", "flatstickmid"):
|
||||
raise ValueError(f"unknown prestep {prestep!r}")
|
||||
if prestep in ("band", "defect", "simpair") and scale not in (
|
||||
"derived3", "derived3_cap", "derived3_m", "bracket", "far"):
|
||||
@@ -721,6 +765,7 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
slope_prev = None
|
||||
last_model = False # was the step just evaluated the model's own? (flat gate)
|
||||
unkept_run = 0 # consecutive model steps whose promise failed (flat2)
|
||||
sticky_m = None # order read at entry to the sticky flat regime (flatstick*)
|
||||
if stats is not None:
|
||||
stats['forced'] = 0
|
||||
stats['pre_refused'] = 0
|
||||
@@ -914,6 +959,22 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
# late, before the crossing (flat2's failure).
|
||||
step = 0.5 * (A + B) - x
|
||||
pre_refused += 1
|
||||
if step is None and prestep in ("flatstick", "flatstickmid"):
|
||||
# PREREG_flat_stick 2026-09-21. The same entry as "flat", but the
|
||||
# regime is a property of the root, not of one step: once the
|
||||
# promise has failed, every later step splits the bracket. The
|
||||
# single flag replaced one step and the model undershot again.
|
||||
# flatstick splits where |f| ~ |x-r|^m puts the root, m read from
|
||||
# the failed promise itself; flatstickmid halves (the ablation).
|
||||
if (sticky_m is None and last_model and f_prev != 0.0
|
||||
and fx / f_prev >= 0.25):
|
||||
sticky_m = _order_from_promise(fx / f_prev)
|
||||
if sticky_m is not None:
|
||||
if prestep == "flatstick":
|
||||
step = _order_split(A, FA, B, FB, sticky_m) - x
|
||||
else:
|
||||
step = 0.5 * (A + B) - x
|
||||
pre_refused += 1
|
||||
if step is None and prestep == "flat2" and unkept_run >= 2:
|
||||
# PREREG_flat_twice 2026-09-21. The same unkept promise as
|
||||
# "flat" (model step, no crossing, r >= 1/4), but only after it has
|
||||
|
||||
Reference in New Issue
Block a user