Skip to content

Clamp eigenvalue discriminant in solve_remix - #62

Merged
timholy merged 1 commit into
mainfrom
teh/disc
Jun 28, 2026
Merged

timholy merged 1 commit into
mainfrom
teh/disc

Conversation

@timholy

@timholy timholy commented Jun 28, 2026

Copy link
Copy Markdown
Member

solve_remix forms the eigenvalues of a symmetric 2x2 pencil as τ/2 ± sqrt(τ^2/4 - δ). The discriminant τ^2/4 - δ is nonnegative in exact arithmetic, but for a near-degenerate pair (orthogonal W columns and orthogonal H rows of equal norm) roundoff can drive it slightly below zero, throwing a DomainError from sqrt. Clamp it to zero.

The regression test constructs such a pair directly and also drives it through merge_pq.

`solve_remix` forms the eigenvalues of a symmetric 2x2 pencil as
τ/2 ± sqrt(τ^2/4 - δ). The discriminant τ^2/4 - δ is nonnegative in
exact arithmetic, but for a near-degenerate pair (orthogonal W columns
and orthogonal H rows of equal norm) roundoff can drive it slightly
below zero, throwing a DomainError from `sqrt`. Clamp it to zero.

The regression test constructs such a pair directly and also drives it
through `merge_pq`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@timholy
timholy merged commit 2c9635a into main Jun 28, 2026
3 checks passed
@timholy
timholy deleted the teh/disc branch June 28, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant