Files
sim-numerics/article/new_sections_8_9.md
T

124 lines
17 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 8. The flat regime, recognised by analogy
§7.4 left one decision open: *when to give the model up*. On the pure powers `fun3`–`fun6` the right move is to halve, Chandrupatla halves on up to all of his steps, and every reading of a single state measured so far confuses "the model is useless here" with something else. This section closes that decision, and the reading that closes it is not a similarity of the current state to a prototype but a similarity of the run to *its own past* — an analogy in Pólya's sense [8], two situations agreeing in more than one relation. Every rule below was pre-registered before its code and its run, with a stop rule; the rejected ones are listed in §10 with their numbers.
### 8.1 The flag: a promise that was not kept
A tangent step on an approach of local order $m$ lands at $e(1-1/m)$ and leaves the residual $r=|f_\text{new}/f_\text{old}|=(1-1/m)^m$ on the same side of the root. It beats a halving exactly when $|1-1/m|<\tfrac12$, that is for $\tfrac23<m<2$. At the upper end $r=(1-\tfrac12)^2=\tfrac14$. So a model step that did not cross the root and left $r\ge\tfrac14$ is a *promise not kept*: the model is in the regime where a halving would have done better. The constant is bisection's $\tfrac12$, carried through the formula.
The flag sees the regime — on the flat families it rises on most model steps — but acted upon step by step it does not pay. Replacing the one flagged step by a halving costs the canonical set 2806 → 3029, because a simple root far from convergence also breaks its promises (the flag rises at least once on 142 of the 154 canonical problems). Every refinement of *when* to halve that reads the moment alone — twice in a row, the promise together with a creep in one direction, a halving that sticks once begun, a judgment of the evaluated point against the line through the bracket — trades one set for the other (§10, items 12–14).
### 8.2 The analogy: similarity of a run to its own past
What distinguishes a pure power from a simple root is not the shape of one configuration — `fun1` on a wide bracket looks as non-linear as $x^9$ — but what happens under zoom. A pure power $f=c(x-r)^m$ is similar to itself: zooming about the root by $L$ scales $x-r$ by $L$ and $f$ by $L^m$, so the *dimensionless configuration* of the last three points,
$$\xi=\frac{x_k-x_{k-1}}{x_{k-2}-x_{k-1}},\qquad \varphi=\frac{f_k-f_{k-1}}{f_{k-2}-f_{k-1}},$$
recurs as the iteration proceeds. At a simple root, zooming in makes $f$ look like its tangent, and the configuration tends to the *linear prototype* $\varphi=\xi$ instead. Two prototypes, then: the line, and the run's own past. The judgment is ordinal — is the current $(\xi,\varphi)$ nearer to some earlier configuration of this run than to the line? — with the plane's Euclidean distance and the perpendicular to the line, the one geometric choice in this section, declared as such.
Nearness of configurations is one relation. An analogy in the full sense needs a second, and the pair supplies it: if the analogous pair shrank $x$ by $L_x$ and $f$ by $L_f$, the power law requires $L_f=L_x^{\,m}$, so the order is *read from the analogy itself*,
$$m=\frac{\ln L_f}{\ln L_x}.\tag{6}$$
A chance resemblance at a simple root reads $m\approx1$; a pure power of order 5 reads 4.9. The regime is the one where a tangent step loses, $m\ge2$ (§8.1) — no new constant. On the traces of the base rule, at the moments the flag rises, the three conditions together hold on 3 of the 154 canonical problems, on all 20 flat problems, and on none of `fun2`, `fun8`, `fun9`.
**The analogy belongs to the run, the flag to the moment.** In the cycle the base rule runs on a pure power — undershoot, undershoot, crossing, a nearly empty step — the flag rises in the phases whose configuration does *not* recur (the empty step grows emptier every cycle), while the recurring phases have the flag down. Requiring both in one state delayed the entry on the flat problems to their thirteenth state on average. Once established, the analogy is therefore remembered for the run, and the regime is entered at the next unkept promise (eighth state on average).
**The translation limit.** The exponential is self-similar by *translation*, $e^{x-1}=e^x/e$: along its flank the step does not shrink while $f$ does, so (6) is undefined or negative. That is the limit $m\to\infty$ of (6), steeper than any power, and it is read as $m=\infty$: when an analogous pair shows $L_f<1\le L_x$. A high power far from its root is locally an exponential, $x^m=e^{m\ln x}$, and it was there, not on the flank of `fun9` it was built for, that the limit paid.
**Exit.** Inside the regime the step splits the bracket (§8.3). At every split the evaluated $f$ is judged against two predictions: the line through the bracket ends, $F_A(1-t)+F_Bt$ at the split fraction $t$, and 0. Nearer the line, the regime is left and the remembered analogy is cleared. A sticky halving without this exit cost the canonical set 6897; with it, 3125 — the exit is what makes a false entry cheap.
### 8.3 Where to split: the point from the order
Halving is the answer when nothing is known about the shape; inside the regime the order is known. For $|f|\propto|x-r|^m$ the ends of the bracket lie at distances in the ratio $|F_A|^{1/m}:|F_B|^{1/m}$ from the root, so the regime splits at
$$t=\frac{|F_A|^{1/m}}{|F_A|^{1/m}+|F_B|^{1/m}},\tag{7}$$
which is exact for a pure power and becomes the midpoint as $m\to\infty$. The order read from a *failed promise*, $(1-1/m)^m=r$, was tried first and gave $m=\infty$ in 163 of 174 entries, because the base step is not a pure tangent; the order read from the *analogy* is the one that works. With it the flat families of the wide-bracket set cost 743–847 evaluations against 1044 for pure bisection and 1068 for Chandrupatla.
### 8.4 Four more readings
**The half the step promises.** $S(z)\ge\tfrac12$ means a step of at most half the way to the far end: the model promises the root in the half of the bracket *near* $x$. The line through the bracket ends puts it nearer the end with the smaller $|f|$. When the far end has the smaller $|f|$ the two disagree about the half, and the evaluation halves. On a steep flank — a slope dominated by $f(81)=1.5\cdot10^{35}$ on `fun9.5` — this is the false promise "the root is here", and removing it alone takes the canonical set from 2806 to 2564.
**The sign contradiction.** The bracket says which way $f$ must go between its ends; the last two points say which way it goes here. Opposite signs — the local picture contradicts the bracket — and the evaluation halves. It is the cause of the `fun9` well: a near-cancelling end reads the root as close while $|f|$ doubles for seventeen steps.
**The repeated step pattern.** Two successive moves the same way, of similar length, mean the iterate creeps along a geometric series whose remainder is $\text{step}\cdot s/(1-s)$; the step is lengthened by $1/(1-s)$, with $s$ the similarity of successive step lengths, but only when the pattern of successive length ratios repeats with a period read from the data (the lag of highest mean similarity) and that similarity exceeds $\tfrac12$.
**The overshoot branch.** §8.1's inequality has a second branch, $m<\tfrac23$: a root of order below one, where the tangent step overshoots and the iterate oscillates about the root ($\sqrt{|x|}\operatorname{sign}x$: 84 evaluations of the base rule). The flag for it is the unkept promise *with* a sign change, $f_\text{new}/f_\text{old}\le-\tfrac14$, and an analogous pair reading $0<m\le\tfrac23$; the split (7) is again exact for a pure power. The exit judgment of §8.2 separates a flat root from a simple one; at a root of order below one $f$ is far from 0 on both sides and the exit fires falsely, so the memory of this branch is *not* cleared by it (measured on the development corpora: 19 evaluations with the memory kept, 65 without).
**Borrowed: the tolerance step.** Once the root is reached from one side the bracket's far end can stay far: on $\sin$ over $[3,4]$ the base rule reaches $|f|\approx10^{-16}$ in 7 evaluations and then halves the remaining $1.3\cdot10^{-7}$ down to the tolerance in 17 more. Dekker [9] and Brent [2] step at least the tolerance; we do the same, $\varepsilon_x/2$ towards the far end, when the model's step is shorter — but only after the model has *kept* its previous promise ($r<\tfrac14$), because at the start of a run a slope dominated by a huge far value promises the root at an end. This element is not ours and is named as such.
### 8.5 The proposed method
The method this paper proposes, **A′**, is the base rule of §3 — tent similarity, three-point scale, projection with the declared multiplier $c=2$ — with the regime of §8.2–8.3 (the analogy remembered, its translation limit, the split (7), the exit) and the four readings of §8.4. Its constants are bisection's $\tfrac12$ and what follows from it: $\tfrac14=(1-\tfrac12)^2$ and the two branches $m\ge2$, $m\le\tfrac23$ of $|1-1/m|>\tfrac12$. Three choices are declared rather than derived: the multiplier $c$ of the projection (§3.1), the Euclidean geometry of the $(\xi,\varphi)$ plane, and the pattern test of the step lengthening (lags from 2 to half the history, threshold $\tfrac12$). The projection carries the guarantee, $2\lceil\log_2(w_0/\varepsilon_x)\rceil+3$ evaluations; it is verified with no violation on every corpus of this paper and under every safeguard of the grid.
**Table 8.** A′ on the protocol of §4 (published roots, failures charged 200). Per problem against each rival: wins/ties/losses, exact two-sided sign test.
| | APS-154 | CHA-45 | both | vs A′ per problem, APS | vs A′ per problem, CHA |
|---|---|---|---|---|---|
| **A′ (proposed)** | **2438** | **2005** | **4443** | — | — |
| A′, earned budget (no free constant) | 3608 | 2807 | 6415 | | |
| base rule (§3) | 2806 | 3220 | 6026 | | |
| Chandrupatla | 2787 | 2441 | 5228 | A′ 103/20/30, $p=1.5\cdot10^{-10}$ | A′ 29/4/7, $p=3\cdot10^{-4}$ |
| TOMS 748 | 2820 | 4000 | 6820 | A′ 127/6/20 | A′ 38/2/0 |
| Brent | 2889 | 4115 | 7004 | A′ 118/17/18 | A′ 33/3/2 |
| ITP, per-problem oracle | 3260 | 2647 | 5907 | A′ 126/7/20 | A′ 35/1/4 |
A′ is 12.5% below Chandrupatla on the canonical set and 17.9% below on the wide-bracket set, and beats every rival problem by problem on both. On the wide-bracket families it is ahead on eight of nine; the ninth is `fun9`, 65 against 55. The earned-budget form keeps its constant-free guarantee of bisection plus one step and pays for it as in §3.1.
**Table 9.** Leave-one-out ablation of A′ on all six corpora of §9 (uniform criterion, a sign change within $10^{-6}$). Δ = total without the component − total with it; positive means the component earns its place.
| component removed | APS | CHA | new-1 | Roots.jl | applied | fourth | sum |
|---|---|---|---|---|---|---|---|
| the whole regime | −7 | +1013 | +1660 | +324 | +77 | +2269 | **+5336** |
| the split (7) (midpoint instead) | −5 | +479 | +667 | +272 | +30 | +1672 | **+3115** |
| overshoot branch | −6 | 0 | −7 | +16 | +63 | +893 | +959 |
| tolerance step (borrowed) | +130 | +35 | +97 | +78 | +135 | −2 | +473 |
| the half the step promises | +249 | +65 | +82 | −16 | −5 | +1 | +376 |
| translation limit | +31 | +143 | +100 | −21 | −2 | +87 | +338 |
| repeated step pattern | −22 | −6 | +123 | −30 | −10 | +34 | +89 |
| sign contradiction | +11 | −12 | +29 | 0 | +1 | −1 | +28 |
Every component is positive in sum; the regime and the split carry the method. Two are marginal and we say so: the step pattern earns on two corpora of six and loses on four, and the sign contradiction is within noise (+28 over 855 problems). Removing both would change A′ by a few tenths of a per cent; they are kept because the pre-registered rule removes only a component that earns nowhere.
## 9. Out-of-sample evidence
Every decision above was taken on the two sets of §4. Pre-registration protects each decision but not the chain: the final configuration was selected on the same 199 problems. Four further corpora were therefore used, each fixed and committed before any method was run on it, each with its criteria and stop rule written down first.
1. **New corpus 1** — 206 problems: SciPy's `original` set (6) and five generated classes of 40 (seed 20260921): smooth simple roots, transcendental simple roots, multiple roots $|x-r|^p$ with $p\sim U(2,20)$, exponential flanks, and near-cancelling terms of the `fun9` kind.
2. **Roots.jl / ModAB** — the published bracketing benchmark of the Julia package Roots.jl [12], taken from the ModAB benchmark of Ganchovski and Traykov [10]: 91 problems, of which 13 coincide with APS or Chandrupatla functions (a seven-point identity test) and are excluded, leaving 78, many of them discontinuous or pathological.
3. **Applied and GSL** — the 10 bracketed problems of the GNU Scientific Library's root-finding test suite [11] and 122 equations from physics and engineering on grids fixed beforehand: Kepler's equation (eccentricity up to 0.999), Colebrook–White, Lambert's W, Planck/Wien, van der Waals for CO₂ (including near-critical), internal rate of return, the finite square well.
4. **Corpus 4** — 240 problems in six new families (seed 20260922): random polynomials with a simple root, polynomials with a multiple root, fractional powers $|x-r|^p$ with $p\sim U(0.15,0.95)$, sums of exponentials and sines, compositions $\tanh$, $\arctan$, $\log(1+q^2)$ of a cubic, and functions odd about the root. The code of A′ was committed *before* this corpus was run, and nothing was changed after.
Where roots are not known in closed form, and for uniformity on all six corpora, a run is solved when $f$ changes sign within $10^{-6}$ of its answer; the $x$-tolerance, the budget and the charge for a failure are those of §4.
**The history is part of the result.** The variant carried to corpora 1–3 was A′ without the tolerance step and the overshoot branch. It transferred to corpus 1 by every pre-registered criterion (total 10% below Chandrupatla, per problem 105/34/67, $p=0.005$), did *not* transfer to Roots.jl (total 6.5% below, but per problem 38/10/30, $p=0.4$) and lost on the applied corpus (14% above). The losses there were traced to two gaps of the base step — no closing of the bracket once the root is reached, and no recognition of roots of order below one — which became the last two readings of §8.4; they were developed on the seen corpora and tested once, on corpus 4.
**Table 10.** A′ against the library rivals on all six corpora (uniform criterion). Totals; in brackets the runs that break the $2\times$-bisection bound. Per problem against Chandrupatla: wins/ties/losses.
| corpus | A′ | Chandrupatla | Brent | TOMS 748 | A′ vs Chandrupatla |
|---|---|---|---|---|---|
| APS (154) | **2259** (0) | 2595 (0) | 2707 (0) | 2636 (0) | 103/20/31, $p=3\cdot10^{-10}$ |
| Chandrupatla (45) | **1074** (0) | 1505 (0) | 3238 (18) | 3088 (15) | 31/4/10, $p=0.001$ |
| new corpus 1 (206) | **3290** (0) | 3716 (0) | 6395 (38) | 5746 (22) | 108/33/65, $p=0.001$ |
| Roots.jl (78) | **1371** (0) | 1566 (0) | 2455 (11) | 2339 (9) | 44/14/20, $p=0.004$ |
| applied + GSL (132) | 1382 (0) | 1382 (0) | 1503 (1) | 1756 (1) | 48/52/32, $p=0.09$ |
| **corpus 4 (240), the one test** | **3656** (0) | 5717 (0) | 8267 (50) | 8084 (37) | **177/35/28, $p=10^{-27}$** |
| all 855 | **13032** | 16481 | 24565 | 23649 | |
Only the last line of corpora is evidence for A′ in the strict sense; the first five were seen while it was developed and are reported as a description. On corpus 4 A′ is 36% below Chandrupatla and wins 177 problems to 28. Without the two classes aimed at by the last two readings it is 2403 against 3569, per problem 107/31/22 ($p=10^{-14}$); on the simple-root classes alone, 737 against 747 (−1.3%), per problem 43/22/15 ($p=3\cdot10^{-4}$).
**Table 11.** Corpus 4 by class: totals of A′ / Chandrupatla, per problem wins/ties/losses.
| class | A′ | Chandrupatla | per problem |
|---|---|---|---|
| random polynomial, simple root | 433 | 419 | 20/8/12 |
| polynomial, multiple root | 1163 | 1805 | 39/1/0 |
| fractional power, $p<1$ | 924 | 1784 | 37/1/2 |
| sums of exponentials and sines | 304 | 328 | 23/14/3 |
| $\tanh$, $\arctan$, $\log(1+q^2)$ of a cubic | 503 | 1017 | 25/8/7 |
| odd about the root | 329 | 364 | 33/3/4 |
**What the evidence supports, and what it does not.** Against Brent and TOMS 748 A′ is ahead on every corpus, by 8% to 67% in total, and it keeps its bound on all 855 problems, which Brent breaks on 118 and TOMS 748 on 84. Against Chandrupatla it is ahead in total on five corpora and level on the sixth, and ahead problem by problem on five of six. The size of the lead is not uniform: it is large on multiple, fractional and nearly flat roots — the regime §8 recognises — and small on simple roots, where it is a matter of per cent. Where it is behind is named: `fun9` (65 against 55), the near-cancelling class of corpus 1 (491 against 391), random polynomials with a simple root in total (433 against 419, though ahead 20 to 12 in problems), and the smooth equations of the applied corpus, where the two are level.