Skip to content

Correctly round AA conversion to float - #42710

Open
cxzhong wants to merge 1 commit into
sagemath:developfrom
cxzhong:codex/aa-float-correct-rounding
Open

Correctly round AA conversion to float#42710
cxzhong wants to merge 1 commit into
sagemath:developfrom
cxzhong:codex/aa-float-correct-rounding

Conversation

@cxzhong

@cxzhong cxzhong commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #42545.

Problem

AlgebraicReal.__float__ delegated to float(RR(self)). The intermediate 53-bit MPFR value can introduce double rounding, and a lazy algebraic expression that is exactly zero can therefore become a small nonzero Python float. This caused the matrix failure reported in #42545.

Changes

  • Convert algebraic interval endpoints through their exact rational values before binary64 rounding.
  • Refine the enclosure until both endpoints identify one rounding cell.
  • Resolve adjacent-float midpoint and overflow boundaries by exact comparison.
  • Preserve representable normal and subnormal values.
  • Return a canonical positive zero only when an underflow-sized enclosure still contains zero and its exact sign remains unresolved.
  • Update indirect QQbar and LazyAlgebraic float doctests.

This PR contains no matrix or LDLT changes.

Verification

Checklist

  • The title is concise and informative.
  • The description explains the change.
  • Tests cover the changed behavior and boundary cases.
  • Modified doctests pass.

Convert algebraic interval endpoints through exact rationals, refine until a binary64 rounding cell is determined, and compare exactly at midpoint boundaries. This fixes lazy exact zeros without discarding representable tiny values and covers subnormal, tie, signed-zero, and overflow edges.\n\nFixes sagemath#42545.
@github-actions

Copy link
Copy Markdown

Documentation preview for this PR (built with commit 52938f8; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

is_positive_semidefinite() throws ZeroDivisionError: division by zero in algebraic field

1 participant