Fix sign-assignment bug in usolve's assign_sign_left + regression tests - #362
Merged
Merged
Conversation
there because I identified another bug)
…nds). Extra tests are going to be added
Pairs the cubic-in-y from univariate-cubic-close-roots.ms (Issue algebraic-solving#358, one exact rational root plus two irrational roots extremely close together) with x=0, to check real root isolation determines the sign of every coordinate correctly in the genuinely multivariate code path. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Multivariate system whose rational univariate representation stresses usolve's real root isolation via assign_left, which was fixed in a previous commit and led to several failures of different kinds. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
One coordinate (y4) is a root extremely close to 0; msolve's real root isolation should still determine its sign correctly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ederc
reviewed
Sep 18, 2026
|
|
||
| #ifndef USOLVE | ||
| #define USOLVE | ||
| #include <stdio.h> |
Contributor
Author
There was a problem hiding this comment.
Stupid mistake from my side... I just removed it. Should affect nothing. Thanks for noticing it.
ederc
approved these changes
Sep 18, 2026
ederc
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me, I just do not understand why you need to include stdio.h in usolve/refine.c (see my comment on this).
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.
Summary
assign_sign_left(src/usolve/usolve.c): the loop assigningsigns to positive roots used
nbposdirectly as the upper bound instead ofnbneg + nbpos,which could mis-assign or skip sign bits for positive roots and led to failures of several
different kinds during real root isolation (Issue Bug in real root isolation #358 investigation).
refine_root_elim(src/msolve/msolve.c) where a bracket endpointevaluates to exactly 0: the root is now marked exact instead of tripping the
"BUG in get_values_at_bounds" guard.
univariate-assign-left— a genuinely multivariate system (4 vars) whose rationalunivariate representation stresses
assign_sign_leftdirectly.univariate-sgn— a coordinate (y4) that is a root extremely close to 0; checks thesign is still determined correctly.
issue-310-bivariate— bivariate variant of the Issue Bug in real root isolation #358 cubic (one exact rationalroot, two irrational roots very close together) paired with
x=0, checking signdetermination in the multivariate code path (Issue Segmentation fault with a simple example #310).
Test plan
make checkpasses for all three new tests (diff_univariate-assign-left.sh,diff_univariate-sgn.sh,diff_issue-310-bivariate.sh)-L/-l/-t/--random-seedcombinations at both
-p 128and-p 1024🤖 Generated with Claude Code