Skip to content

Newton's solver, the spurious-root filter and Gruntz without catch-alls - #1568

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
newton-and-limits-without-catch-alls
Sep 29, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
newton-and-limits-without-catch-alls

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Closes #1547 (part of #1540's review of exceptions used for control flow).

Six catch (Exception) clauses wrapped code that already declines by returning NaN, null or false:

  • NewtonSolver, four:
    • the iteration step caught an OverflowException that System.Numerics.Complex arithmetic does not throw (it gives infinities and NaN, which the loop already handles), under a // TODO: remove try catch in for;
    • RealValueAt around the compiled function's call;
    • OnePerRoot's residual, which now ranks a residual that is not a finite number last by a test rather than a catch;
    • Satisfies, which already answers true for anything it cannot check.
  • The spurious-root filter (IsSpurious in SolveStatement.cs), which already keeps a root it cannot evaluate.
  • The Gruntz limit's entry, which already rethrew AngouriBugException and OperationCanceledException.

How it was decided. Each of the six sites, and the ten in #1546, was instrumented to log every exception it caught, then run over the whole unit suite and a 598-problem sample of Rubi's families 0 to 8. None of these six caught anything. So they go: a defect below them now reaches the caller instead of reading as a decline. The same goes for an OperationCanceledException from a cancellation checkpoint, which the four that caught Exception took for a decline.

No answer changes, so no BREAKING-CHANGES.md entry.

Measured against master 5f9e3db: the unit tests pass (net10.0, 13354 passed), every target builds, and the allocation gate passes on this tree: allocation is what the baseline says on all 19 gated benchmarks.

🤖 Generated with Claude Code

Six catches wrapped code that declines by returning NaN, null or false
already: four in Newton's solver (one catching an OverflowException that
System.Numerics.Complex arithmetic does not throw), the spurious-root filter's
residual check, and the Gruntz limit's entry. Each site was instrumented and
logged every exception it caught, over the whole unit suite and a 598-problem
sample of Rubi's families 0 to 8: none caught anything. They go, so that a
defect below them reaches the caller instead of reading as a decline, and so
does the OperationCanceledException that four of them took for one. A
residual Newton cannot rank, one that is not a finite number, still ranks
last, now by a test rather than a catch.

The unit tests pass (net10.0, 13354), every target builds, and the allocation
gate passes.

Closes #1547.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rafael-SOWNet
Rafael-SOWNet merged commit 882c1eb into master Sep 29, 2026
31 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the newton-and-limits-without-catch-alls branch October 29, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Newton's solver, the spurious-root filter and the Gruntz limit catch Exception

1 participant