Skip to content

Decline where rounding reached a root, rather than drop it (#2627) - #2631

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
rounding-residual-2627
Nov 28, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
rounding-residual-2627

Conversation

@Rafael-SOWNet

@Rafael-SOWNet Rafael-SOWNet commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

y^2 - 2 = 0, x^2 + (P - Q y) x - c = 0, with (1 + sqrt(2))^n = P + Q sqrt(2), has four solutions. Since #2612 the eliminator also solves for y from the second equation, through ((x^2 + P x - c)/(Q x))^2 = 2. At large n that quartic's small root, exact, evaluates at a hundred digits to a residual that rounding made, and it was dropped as spurious. There were two variants:

  • One-variable solve, on master: no enclosure can be worked out. At n = 90 the residual is -0.042 against terms of 3, and twice the digits evaluate it to something else.
  • System's row check, on Keep an exact number past the working digits exact (#2615) #2620 merged with master: the row's residual evaluates to -7.2e-21, while its enclosure leaves zero out by only about 6e-53. The row is exact and not zero, which means the elimination rounded.

StatementSolver.Weigh now returns cannot tell in both cases. A one-variable solve then declines the equation (ShownNotARoot, as it already did for a row that passes the tolerance but whose enclosure excludes zero), and a system declines in RowsThatHold. A residual that twice the digits leave where it was is still evidence, so extraneous roots are still dropped.

Solve("x", "y") master fc8aaf4c2 #2620 merged with master this PR (alone, or merged with #2620)
n ≤ 60, c = 2, 3, 5 4 rows 4 rows 4 rows
n = 70, c = 3 declined 3 rows declined
n = 80, c = 5 3 rows declined declined
n = 90, c = 2 and 5 3 rows 3 rows declined
n = 100, c = 2 3 rows 3 rows declined
n = 120, c = 2, 3, 5 3 rows 3 rows declined

2.10.0 declines every row above n = 60. The three-row answers came in with #2612 and have not been released, so there is no BREAKING-CHANGES.md entry.

Tests: ARowIsNotDroppedOnARoundedResidualTest, 8 cases. Each must be four rows that hold within 1e-60 by a 300-digit enclosure, or a decline.

The full UnitTests suite (net10.0) passes: 21757 passed, 0 failed, 13 skipped. The library builds with 0 errors for every target framework.

Closes #2627.

🤖 Generated with Claude Code

y^2 - 2 = 0, x^2 + (P - Q y) x - c = 0, with (1 + sqrt(2))^n = P + Q sqrt(2),
has four solutions. Since #2612 the eliminator also solves for y from the
second equation, through ((x^2 + P x - c)/(Q x))^2 = 2, a quartic in x
with coefficients near Q^2. At n = 90 the small root of that quartic,
exact, evaluated to a residual of -0.042 against terms of 3 at a hundred
digits, and no interval enclosure of it could be worked out. It was
dropped as spurious, and the system was answered with three rows. Master
answers three rows of four at n = 80, 90, 100 and 120 for several c.
2.10.0 declined all of them. Merged with #2620, which keeps P + Q sqrt(2)
exact, the same happens at n = 70 in the system's own row check: the row's
residual evaluates to -7.2e-21, while its enclosure leaves zero out by
only about 6e-53.

StatementSolver.Weigh now reads such a residual as rounding having
reached the root, and whether it is one cannot be told. That is so where
an enclosure leaves zero out but is within what IsEvidenceAgainst lets
rounding leave, and where no enclosure can be worked out and twice the
digits evaluate the residual to something else. A one-variable solve
then declines the equation, as ShownNotARoot already did, and a system
declines in RowsThatHold. A residual that more digits leave where it was
is still evidence, so an extraneous root is still dropped. Every case
measured is now four rows or a decline, on master and on master merged
with #2620.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.72%. Comparing base (fc8aaf4) to head (18e87a0).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ontinuous/Solvers/EquationSolver/SolveStatement.cs 88.57% 2 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2631      +/-   ##
==========================================
- Coverage   86.72%   86.72%   -0.01%     
==========================================
  Files         345      345              
  Lines       75366    75429      +63     
  Branches    22026    22044      +18     
==========================================
+ Hits        65360    65413      +53     
- Misses       5400     5404       +4     
- Partials     4606     4612       +6     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.22% <90.00%> (-0.01%) ⬇️
fsharp 32.79% <ø> (ø)
interactive 40.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ath/Functions/Continuous/Solvers/EquationSolver.cs 83.25% <100.00%> (+0.23%) ⬆️
...ontinuous/Solvers/EquationSolver/SolveStatement.cs 86.34% <88.57%> (+0.30%) ⬆️

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit fbc74d9 into master Nov 28, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 28, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the rounding-residual-2627 branch November 28, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

A system's root is dropped on a residual that rounding made: y^2 = 2, x^2 + (P - Q y) x = c is answered with 3 of its 4 rows

1 participant