Files
sim-numerics/README.md
T

83 lines
4.8 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.
# sim-numerics — similarity as a step rule for root finding
Artifact for the paper `article/sim_numerics.tex`. Every claim in the paper is
produced by one of the scripts below; nothing in the text is transcribed by
hand, and `verify_article.py` checks all 72 stated numbers against the run
data as part of the test suite.
## Reproducing
```
python -m pytest tests/ -q # 490 tests
python sweep_full.py # the full grid, writes sweep_full.json
python verify_article.py # every paper number vs the data
```
Heavy runs go to a Linux machine (Python 3.12, run detached with a log,
`setsid nohup ... > sweep.log 2>&1`). **Use one platform for all numbers**: the
test functions call `libm`, whose last digit differs between Windows and Linux,
and the same SciPy version scores 2819 for TOMS 748 on Windows against 2820 on
Linux for the same set. The paper's numbers are the Linux ones.
## Where each claim comes from
| Paper | Claim | Script |
|---|---|---|
| Prop. 1 | the two-point similarity step **is** regula falsi | `tests/test_simroot.py::test_the_pure_two_point_similarity_step_is_regula_falsi_exactly` |
| Prop. 2, Table 1 | contraction law, predicted 0.1716 vs measured 0.1716 | `stage0c_why_pure_fails.py` |
| Cor. 1 | a chosen similarity fails on 5–8 of 8 problems | `stage0b_pure_similarity.py` |
| Cor. 2 | faster similarity is not better (`sqrt`, `cbrt`) | `stage0d_derived_similarity.py` |
| Cor. 3 | derived scale ⇒ the step is \|f\|/\|f'\| ⇒ superlinear | `stage0d_derived_similarity.py`, `stage0e_guard_cost.py` |
| §3 safeguards | bracket vs step vs both, and what each costs | `stage2_guard_modes.py`, `stage3_bound_check.py` |
| §3 order | 1.584 (2-point) vs 1.944 (3-point) | `stage5_three_point.py` |
| §3.1 | project vs replace; the guarantee costs nothing | `stage6_projection.py` |
| §3.1 | the projection invariant, instrumented per step | `stage6b_invariant.py` |
| §4 fairness | ITP is not handicapped; κ₁ and n₀ sweeps | `stage2b_itp_fairness.py` |
| Tables 2, 3 | the 154-configuration ranking on both sets | `sweep_full.py` → `report_sweep.py` |
| Table 4 | the law across the whole grid | `sweep_full.py` → `report_sweep.py` |
| §6 | approach vs endgame, order, boldness, step quality | `stage4_why.py` |
| §7.1 | the prototype-aggregation form loses 0/6/147 | `bench_full.py` (`SIM.pair2d.*`) |
| §7.2 | the 2× bound and high order are incompatible | `stage5_three_point.py`, `tests/test_three_point.py` |
| §7.4 | the symmetric ratio similarity degenerates | `simroot/pure.py` (`PURE_SIMS["ratio"]` docstring), `stage0d` |
## Layout
```
simroot/pure.py the method: one similarity, one step rule, three guards
simroot/baselines.py bisection, 4 false-position variants, Ridders, Brent,
TOMS 748 (SciPy), ITP (own, validated against its theorem)
simroot/sim.py the prototype-aggregation form — a NEGATIVE result, kept
because the paper reports it
stage0*..stage5* the derivation, in the order it was actually established
bench_full.py 17 methods on both sets
sweep_full.py 9 similarities x 4 scales x 4 guards + 10 baselines
report_sweep.py reads sweep_full.json, produces the paper's tables
verify_article.py asserts the paper against the data (72 checks)
tests/ 490 tests; every bug found in audit is pinned here
```
## Negative results, so they are not reopened
1. Similarity normalised by the two bracket ends **is** regula falsi, identically.
2. A faster-changing similarity is not better; what matters is the slope of
`1 - S` at zero matching the problem, and only the data supplies it.
3. Prototype-pair aggregation with softmax over the whole memory loses to the
simplest form: 0 wins / 6 ties / 147 losses against Brent on APS.
4. "Our safeguard fires less often" — refuted: Brent discards 53% of its
interpolations on the set it wins, 34% on the set it loses.
5. "Our steps are bolder" — refuted: on Chandrupatla Brent is bolder (56.3%
against 41.8%) and still loses. The mechanism is step *quality*: median
bracket removed 0.275 against 0.058.
6. Every safeguard that REPLACES the computed step with a midpoint destroys the
order: with the three-point scale, order falls from 1.94 to 1.00 and the APS
total from 2806 to 7260. **Resolved** by projecting the step onto the
admissible interval instead (`guard="project"`), which costs nothing on APS
(2806 either way) and gains on Chandrupatla (40/45 at 3220 against 35/45 at
4104 unguarded).
7. Zero slack in the projection is degenerate: a worst case of exactly bisection
demands a halving at every step, leaving the projection no freedom.
8. Writing the projection as a radius around the midpoint instead of a clamp
loses the invariant to cancellation — a relative 8.9e-5 overshoot on eleven
Chandrupatla problems.
```