Skip to content

Fix wrong parametrizations when Hankel inversion degenerates - #369

Open
wegank wants to merge 1 commit into
algebraic-solving:masterfrom
wegank:fix-hankel-degenerate-minimal
Open

wegank wants to merge 1 commit into
algebraic-solving:masterfrom
wegank:fix-hankel-degenerate-minimal

Conversation

@wegank

@wegank wegank commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

This PR is entirely prepared by Claude Code. Below is the commit message.

Fixes #331.
Fixes #368.


The parametrizations in shape position are obtained by solving Hankel systems with a Gohberg-Semencul type formula, which requires the constant coefficient of the first generator Z1 to be nonzero. For a random sequence this fails with probability about 1/p, when a sub-block of size dim - 1 of the Hankel matrix is singular. The code handling this case borders the Hankel matrix into one of size dim + 1, for which the formula applies, but it silently returned wrong parametrizations.

Fix the three issues of that code: build the bordered sequence from the points after undoing their mirroring, clear the polynomial used as scratch space by nmod_em_gcd_preinstantiated before filling it again, and recover the solutions of the original system from the bordered generators. invert_hankel_matrix now returns 2 in the bordered case so that solve_hankel can apply this correction.

This was the cause of the random failure of diff_cyclic5-16.sh seen in CI with SEED=1790795968. Add a regression test with that seed; it exercises the degenerate case with glibc's rand().

The parametrizations in shape position are obtained by solving Hankel
systems with a Gohberg-Semencul type formula, which requires the
constant coefficient of the first generator Z1 to be nonzero. For a
random sequence this fails with probability about 1/p, when a sub-block
of size dim - 1 of the Hankel matrix is singular. The code handling
this case borders the Hankel matrix into one of size dim + 1, for which
the formula applies, but it silently returned wrong parametrizations.

Fix the three issues of that code: build the bordered sequence from
the points after undoing their mirroring, clear the polynomial used as
scratch space by nmod_em_gcd_preinstantiated before filling it again,
and recover the solutions of the original system from the bordered
generators. invert_hankel_matrix now returns 2 in the bordered case so
that solve_hankel can apply this correction.

This was the cause of the random failure of diff_cyclic5-16.sh seen in
CI with SEED=1790795968. Add a regression test with that seed; it
exercises the degenerate case with glibc's rand().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wegank
wegank force-pushed the fix-hankel-degenerate-minimal branch from a9241ff to 17a95be Compare September 30, 2026 23:22

@mohabsafey mohabsafey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok for me but maybe @jerebertho you could also have a look since you know this part better than me

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.

reproducible error in test/diff/diff_cyclic5-16.sh A few recent test failures

2 participants