Skip to content

Decline a modulus piece's root that is not decided real or inside, rather than leave it out (#2659) - #2673

Open
Rafael-SOWNet wants to merge 2 commits into
masterfrom
undecided-modulus-root-declines-2659
Open

Rafael-SOWNet wants to merge 2 commits into
masterfrom
undecided-modulus-root-declines-2659

Conversation

@Rafael-SOWNet

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

Copy link
Copy Markdown
Member

Fixes #2659

What was wrong

Over the reals, ModulusSolver.SolveOverTheReals kept a root of a piece only where its Evaled was a Real inside the piece. Every other root was left out as though it were known to be complex or outside. With x written 10^30 x, the decimals flushed the parts of the quartic's roots, which are near 10^-31, and read them as complex numbers near 2.27. All eight were left out, so (10^30 x)^4 - 10 (10^30 x)^2 + abs(10^30 x) + 1 = 0 was answered { }.

The fix

Each root is now read without the exponent floor and decided one of three ways:

  • Not real where a 40- or 80-digit enclosure (PreciseEvaluation) is off the real line. Where the interval evaluator finds no enclosure (the quartic formula's roots straddle a cut), a root is also not real where its imaginary part is clear of 1e-30 times the largest of the piece's roots, since a formula's rounding is relative to that size and not to the root's own.
  • Real where it evaluates to a real.
  • Anything else declines the equation (null).

The roots of a modulus's argument (the kinks) go through the same reading. A kink left out is two pieces read as one.

Membership of a piece, the order of two kinks and the sign of a modulus inside a piece are decided by one comparison:

  • exactly where both sides are rational;
  • by enclosures that are apart;
  • as equal where the two are written alike, or their difference InnerSimplifieds to 0;
  • by decimals beside the roots' size only where no enclosure exists.

Undecided declines. In particular, two decimals that agree no longer put a root on the closed end of a piece. A root equal to its kink is written alike.

Two more sites in the same method had the same shape:

  • A rational root the piece's equation is decided not to hold at declines. The quartic formula gave 0 in place of the root near -10^-150 of x^4 - 10 x^2 + x + 10^-150. The outer verification then dropped it, and x^4 - 10 x^2 - |x| + 10^-150 lost two of its four roots.
  • A constant piece is the whole piece only where it is decided 0.

RootsWhereZero (complex numbers) is unchanged from master. A first version judged a row's entries against the row's largest entry. With x scaled by 10^30 or 10^-30, the unknowns of a row differ in size by 10^30, and that version declined 18 + 7 equations over the complex numbers which master answered, most of them { } for equations with no root. It was reverted in the second commit.

LogarithmSolver and PolynomialCandidates were audited. Their realness and positivity drops act only on candidates already shown to leave a polynomial residual of 0, so they were left alone (see the last section).

Measured

On this branch (f180ed8) and on master 97f26c663:

master branch
UnitTests 21970 passed, 0 failed, 13 skipped
FSharpWrapperUnitTests 135 passed
CasBench 120/121, 0 wrong / 0 error / 0 timeout same, every answer identical
RootCheck 596/596 clean same
SimpSweep 10463/10463 agree same
BoundCheck 0 disagreements, 63 rewritten same

None of the harnesses changed any answer.

  • The e387 cross-check's equations: all 58 (cxcheck, x scaled by 10^-30 and by 10^30, complex codomain) now answer exactly as on master.
  • Scaled moduli over the reals: 298 generated equations with x written 10^30 x or x / 10^30. 16 answers changed, and none became a decline. Each new answer equals the unscaled equation's real roots, scaled. 13 of master's answers were missing roots, among them { } answers, and 3 were the same roots written another way.
  • Unscaled moduli: 272 generated equations over both codomains. Only the issue's answer changed.

All of this is in BREAKING-CHANGES.md.

Tests

SolverRegressionTest.Issue2659_*:

  • The issue's equation. It must not be { }. If it answers, the roots must be its four real roots, checked without the floor against 10^-30 times those of the unscaled equation.
  • The decline path, called on ModulusSolver directly. x^4 - 10 x^2 - abs(x) + 10^-150 and + 10^-70 must give either null or four real roots, two of them below 10^-60.
  • Guards that decided cases still answer. These include a root a hair past a kink, which only the 80-digit enclosure separates.

On master, the first two fail and the guards pass.

The tests hold whichever way the evaluation floor is settled (#2668). Once it is lifted the issue's equation may answer directly. The 10^-150 case still declines, because its small roots are what terms near 3 cancel to at a hundred digits.

Not fixed here (found on the way, master behaviour, floor-related)

  • ln(x) + ln(x + 1) + 600 = 0, ln(x) + ln(2 x) + 600 = 0 and ln(x) + 2 ln(x) + 900 = 0 answer { }. The candidates come from a polynomial in which e^-600 flushed to 0.
  • 2 x^2 - e^(-600) = 0 answers { 0 }.
  • x^2 - 10^(-300) = 0 answers only 1/10^150.
  • abs(x - 1) + x^2 - 1 - 10^(-99) = 0 answers { 0, 1 }, which is wrong. It comes from a route other than ModulusSolver, which now declines it.
  • x^4 - 10 x^2 - abs(x) + 10^(-150) = 0 still answers two of its four roots, through another route after ModulusSolver declines.

🤖 Generated with Claude Code

…ther than leave it out (#2659)

Over the reals ModulusSolver.SolveOverTheReals kept a root of a piece
only where its Evaled was a Real inside the piece, and left out every
other root as though it were known to be complex or outside. With x
written 10^30 x the decimals flushed the parts of the quartic's roots,
near 10^-31, and read them as complex numbers near 2.27; all eight were
left out and (10^30 x)^4 - 10 (10^30 x)^2 + |10^30 x| + 1 = 0 was
answered { }.

A root of a piece, and a root of a modulus's argument taken as a kink,
is now read without the exponent floor and decided three ways. It is not
real where a 40- or 80-digit enclosure of it is off the real line, or,
where the interval evaluator finds none (the quartic formula's roots
straddle a cut), where its imaginary part is clear of 1e-30 times the
largest of the roots it was found with, which is what a formula's
rounding is relative to. It is real where it evaluates to a real. Any
other root declines the equation. Membership of a piece, the order of
two kinks and the sign of a modulus inside a piece are decided exactly
for rationals, by enclosures that are apart, as equal where the two are
written alike or their difference simplifies to 0, and by decimals beside
the roots' size only where no enclosure is found; undecided declines. A
rational root the piece's equation is decided not to hold at declines
too: the quartic formula gave 0 in place of the root near -10^-150 of
x^4 - 10 x^2 + x + 10^-150, and the answer was left without it. A piece
with no x is the whole piece only where it is 0, not where it merely
failed to evaluate to 0.

RootsWhereZero, for the complex numbers, judged an entry's imaginary part
beside the entry's own size and a negative modulus beside max(1, |t|),
which is absolute below 1. Both are now judged beside the largest entry
of the row, so a part near 0 of a root near 1 is not read off the real
line by rounding alone, and an entry not decided declines.

The issue's equation now has its four real roots, 10^-30 times those of
x^4 - 10 x^2 + |x| + 1. CasBench 120/121, RootCheck 596/596, SimpSweep
10463/10463 and BoundCheck 0 disagreements, unchanged from master
97f26c6, with every answer identical. A sweep of 272 generated modulus
equations over both codomains changed two answers: the issue's, and
1 - 2 y + y |-2 - 3 y| with y = 10^30 x, the same root written as the
unscaled one is. No answer became a decline.

#2659

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.75000% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.70%. Comparing base (97f26c6) to head (f180ed8).

Files with missing lines Patch % Lines
...Continuous/Solvers/EquationSolver/ModulusSolver.cs 68.75% 25 Missing and 15 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2673      +/-   ##
==========================================
- Coverage   86.73%   86.70%   -0.03%     
==========================================
  Files         346      346              
  Lines       75913    76014     +101     
  Branches    22231    22273      +42     
==========================================
+ Hits        65841    65911      +70     
- Misses       5426     5447      +21     
- Partials     4646     4656      +10     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.20% <68.75%> (-0.03%) ⬇️
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 Δ
...Continuous/Solvers/EquationSolver/ModulusSolver.cs 76.24% <68.75%> (-3.76%) ⬇️

... and 6 files with indirect coverage changes

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

… no answer (#2659)

Reading each entry of a row against the largest entry declined
equations over the complex numbers that master answered. With x written
10^-30 x or 10^30 x, the unknowns of a row differ in size by 10^30. A
row's off-the-line entry, which was decided against its own size, was no
longer decided against the row's, and so equations with no root, such as
1 - 3x - 3 |3 - x| with x scaled, went from { } to unsolved. The e387
cross-check counted 18 new declines at 10^-30 and 7 at 10^30. The
argument for the row's scale was rounding under cancellation, and no
example of that was found. So RootsWhereZero goes back to master's
reading, and the real-line pieces keep theirs.

All 58 of the cross-check's equations, at both scales over the complex
numbers, now answer as on master. Over 298 generated equations in moduli
with x scaled by 10^30 or 10^-30 over the reals, 16 answers change and
none becomes a decline. Each new answer is the unscaled equation's real
roots, scaled; 13 of the old answers lacked roots, and 3 were the same
roots written another way. The BREAKING-CHANGES entry now gives those
measurements in place of the complex row it had.

UnitTests 21970 passed. CasBench 120/121, RootCheck 596/596, SimpSweep
10463/10463 and BoundCheck 0 disagreements, every answer as on master.

#2659

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

A root of a modulus piece that does not evaluate to a real is skipped, and the equation is answered { }

1 participant