Repository navigation
Solve one equation at the default zero tolerance, and decline where an exact root is shown not to be one - #2456
Merged
Conversation
…n exact root is shown not to be one (#2448) With (1 + sqrt(2))^n = P + Q sqrt(2), x^2 + (P_70 + Q_70 sqrt(2)) x - 3 was solved as { -2 P_70 }, which leaves -2; x^2 + (P_70 - Q_70 sqrt(2)) x - 3 as { sqrt(3), -sqrt(3) }, the coefficient dropped; and at n = 20 the discriminant b^2 + 12 was read as 12. EquationSolver.Solve ran under PrecisionErrorZeroRange = 1e-12, which widens the downcasting tolerance from 1e-50, and checked its roots inside the same scope. The override is gone: SolveEquation now solves as Solve on the equation already did, and n = 20..60 come out right. Where the default 1e-50 still rounds, WithoutSpuriousRoots, shared by both entry points, now weighs an exact root against an interval: - a root with only exact numbers in it, in an equation with only exact numbers, whose residual's PreciseEvaluation enclosure leaves out zero, declines the equation (a ConditionalSet), rather than being dropped, which would answer an incomplete set; - a root the decimal evidence took for spurious is kept where the residual is exact and algebraic and its enclosure holds zero: the small root -b/2 + sqrt(b^2 + 12)/2 keeps 46 digits at a hundred and left 5.9e-48 against terms of 3, which dropped it from 70 to 120. The enclosure is taken only where the residual, evaluated without downcasting at the working digits plus those of the largest number in the tree, is above 1e-95: an interval for every exact root doubled the allocation of solving x^2 + x + 1. A system whose elimination leaves an equation unsolved at a leaf is declined too, where the rows of the other branches were returned as all of them; RowsThatHold uses the same enclosure-aware evidence. Measured, roots checked against the true ones at 400 digits, 2.7.0/master -> branch, SolveEquation: n = 5, 10 right -> right n = 20..60 wrong (+ at 40..60 unsolved) -> right n = 70..120 + wrong { -2P } -> right n = 70..120 - wrong { (-b +- 2 sqrt(3))/2 } or { +-sqrt(3) } -> declined n = 140, 200 wrong -> declined n = 160 + wrong -> declined; - wrong -> still wrong (residual near 1e-123, past a hundred digits) Solve on the equation: right to 60 before and after; 70..120 + missed the small root -> both roots; the rest as above. System y^2 - 2, x^2 + (P - Q y) x - 3: n = 20..60 declined -> four rows; 70..200 declined -> declined. With the override removed alone, n = 80 and 120 came back with 3 and 2 of the 4 rows; the leaf decline is what stops that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2456 +/- ##
=======================================
Coverage 86.96% 86.97%
=======================================
Files 319 319
Lines 71013 71063 +50
Branches 20716 20734 +18
=======================================
+ Hits 61759 61807 +48
- Misses 4966 4970 +4
+ Partials 4288 4286 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
The kernel performance gate on this PR's first run reported SolveHard at 8,514,589 B/op, 10.6% below the 9,526,556 recorded at 190a6c8, and every other gated benchmark within its band. The file is that run's own measurement (benchmark-results artifact of run 43747235590), copied over the baseline as the gate asks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
The kernel performance gate failed as expected, on SolveHard alone: 8,514,589 B/op against the baseline's 9,526,556, 10.6% lower; every other gated benchmark stayed within its band. The baseline is updated in this PR from that run's own measurement (run 43747235590). |
This was referenced Nov 15, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With (1 + sqrt(2))^n = P + Q sqrt(2), x^2 + (P_70 + Q_70 sqrt(2)) x - 3 was
solved as { -2 P_70 }, which leaves -2; x^2 + (P_70 - Q_70 sqrt(2)) x - 3
as { sqrt(3), -sqrt(3) }, the coefficient dropped; and at n = 20 the
discriminant b^2 + 12 was read as 12.
EquationSolver.Solve ran under PrecisionErrorZeroRange = 1e-12, which
widens the downcasting tolerance from 1e-50, and checked its roots inside
the same scope. The override is gone: SolveEquation now solves as Solve on
the equation already did, and n = 20..60 come out right.
Where the default 1e-50 still rounds, WithoutSpuriousRoots, shared by both
entry points, now weighs an exact root against an interval:
numbers, whose residual's PreciseEvaluation enclosure leaves out zero,
declines the equation (a ConditionalSet), rather than being dropped,
which would answer an incomplete set;
is exact and algebraic and its enclosure holds zero: the small root
-b/2 + sqrt(b^2 + 12)/2 keeps 46 digits at a hundred and left 5.9e-48
against terms of 3, which dropped it from 70 to 120.
The enclosure is taken only where the residual, evaluated without
downcasting at the working digits plus those of the largest number in the
tree, is above 1e-95: an interval for every exact root doubled the
allocation of solving x^2 + x + 1.
A system whose elimination leaves an equation unsolved at a leaf is
declined too, where the rows of the other branches were returned as all
of them; RowsThatHold uses the same enclosure-aware evidence.
Measured, roots checked against the true ones at 400 digits, 2.7.0/master
-> branch, SolveEquation:
n = 5, 10 right -> right
n = 20..60 wrong (+ at 40..60 unsolved) -> right
n = 70..120 + wrong { -2P } -> right
n = 70..120 - wrong { (-b +- 2 sqrt(3))/2 } or { +-sqrt(3) } -> declined
n = 140, 200 wrong -> declined
n = 160 + wrong -> declined; - wrong -> still wrong (residual
near 1e-123, past a hundred digits)
Solve on the equation: right to 60 before and after; 70..120 + missed the
small root -> both roots; the rest as above.
System y^2 - 2, x^2 + (P - Q y) x - 3: n = 20..60 declined -> four rows;
70..200 declined -> declined. With the override removed alone, n = 80 and
120 came back with 3 and 2 of the 4 rows; the leaf decline is what stops
that.
Measured
Roots checked against the true roots at 400 digits; 2.7.0 and master give the same answers.
P,Qare Pell numbers, the equationx^2 + (P ± Q sqrt(2)) x - 3.SolveEquation, masterSolve, master{-2P}The system
y^2 - 2, x^2 + (P - Q y) x - 3: 4 rows at n = 10 before and after; n = 20..60 declined → 4 rows; n = 70..200 declined → declined.n = 160 with
−is still wrong: the residual is about 1e-123, past the 100 digits the evaluation works to. That is downcasting, which v3 removes (#1019), so this is part of #2448 rather than all of it.Removing the override alone made the system above answer 3 of 4 rows at n = 80 and 2 of 4 at n = 120, where master declined; the
InSolveSystemchange (an unsolved last equation of a branch declines the system rather than counting as no rows) is what stops that.Solver cross-checks (cxcheck 300, radcheck 400 + 300, logcheck 400) run through
SolveEquation: identical on master, the override removed alone, and this branch, 0 wrong or missed. Full check on this commit before the rebase onto 840075a, which was clean: 19,871 unit tests, 0 failed; MCP 431, Terminal 69, F# 134, Interactive 19; AOT OK; BoundCheck 0 disagreements, RootCheck 596/596, CasBench 120/121 with 0 wrong, PropCheck 1355/0, SimpSweep 10463/10463, RuleCheck clean, CanonCheck and Confluence at their baselines.Allocation per call falls (SolveHard 9.51M → 8.49M bytes), which the kernel performance gate will flag; the baseline follows from this PR's own benchmark run.
Part of #2448.
🤖 Generated with Claude Code