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:
vvs
2026-09-21 20:02:43 +01:00
co-authored by Claude Opus 5
parent 657df10634
commit 8027d7f5ef
6 changed files with 255 additions and 3 deletions
+38
View File
@@ -449,3 +449,41 @@ def test_half_is_silent_on_a_line_and_breaks_the_fun9_flank():
guard="project", prestep=p)[1]
for p in ("defect+flatanalogmempt+exp", "defect+flatanalogmempt+exp+half")]
assert n[1] < n[0], n
# ---- PREREG_close_sub_2026-09-21: bracket closing (borrowed) and the overshoot branch ----
APRIME = "contra+flatanalogmempt+exp+half+close+sub"
@pytest.mark.parametrize("bad", ("sub", "defect+sub", "contra+sub"))
def test_sub_needs_the_flat_regime(bad):
with pytest.raises(ValueError):
pure_root(lambda t: t - 1.0, 0.0, 3.0, XTOL, MAXFEV, similarity="ratio",
scale="derived3", guard="project", prestep=bad)
@pytest.mark.parametrize("f,a,b", PROBS)
@pytest.mark.parametrize("guard", ("project", "credit"))
@pytest.mark.parametrize("pre", ("close", APRIME))
def test_the_guarantee_holds_with_close_and_sub(f, a, b, guard, pre):
x, n, ok = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
guard=guard, prestep=pre, extrapolate="pattern")
assert ok and min(a, b) <= x <= max(a, b)
half = math.ceil(math.log2(abs(b - a) / XTOL))
assert n <= (2 * half + 3 if guard == "project" else half + 4), n
def _n(f, a, b, pre):
return pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
guard="project", prestep=pre, extrapolate="pattern")[1]
def test_close_and_sub_measured_in_development():
"""Measured before pinning: sin[3,4] 24 -> 7, sqrt|x| sgn 84 -> 19, x^19 unchanged."""
a_ = "contra+flatanalogmempt+exp+half"
assert _n(math.sin, 3.0, 4.0, APRIME) < _n(math.sin, 3.0, 4.0, a_)
sq = lambda x: math.sqrt(abs(x)) * (0.0 if x == 0 else math.copysign(1.0, x)) # noqa: E731
assert _n(sq, -1 / 3, 1.0, APRIME) < _n(sq, -1 / 3, 1.0, a_)
p19 = lambda x: x ** 19 # noqa: E731
assert _n(p19, -10.0, 100.0, APRIME) == _n(p19, -10.0, 100.0, a_)
assert _n(lambda x: 3.0 * x - 1.0, -2.0, 5.0, APRIME) == 4