Skip to content

fix(polynomial): normalize Sturm chain entries - #360

Open
KSHITIZ6341 wants to merge 2 commits into
kmolan:mainfrom
KSHITIZ6341:codex/fix-sturm-chain-scaling
Open

KSHITIZ6341 wants to merge 2 commits into
kmolan:mainfrom
KSHITIZ6341:codex/fix-sturm-chain-scaling

Conversation

@KSHITIZ6341

@KSHITIZ6341 KSHITIZ6341 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What & why

Fixes #295. A degree-12 polynomial built from roots ±1 through ±6 has entirely finite coefficients after scaling by 3e32 in f32 or 1.5e302 in f64, but root counting currently returns Ok(0). Normalize the initial polynomial before differentiating, its derivative, and each subsequent negated remainder by their positive maximum coefficient magnitude. This preserves Sturm signs and prevents coefficient scaling from silently discarding roots. Divide coefficients directly to avoid overflowing the reciprocal of a tiny norm; reject non-finite intermediate entries.

The new f32/f64 round-trip tests cover ordinary, tiny, huge, and negative multipliers, root counts, and root isolation. Both regressions were verified to fail on the unchanged implementation. Codex assisted with investigation, implementation, and validation.

Checklist

  • cargo test (38 unit tests, 1477 suite tests, 463 doctests) and cargo clippy --all-targets pass locally
  • No new public APIs
  • No unwrap/expect/panic on library paths
  • cargo fmt --check and git diff --check
  • Unreleased changelog updated

Embedded text-size baseline

The thumbv7em-none-eabihf smoke image needs an updated .text baseline for the checked Sturm-chain normalization. Per ci/README.md, only this target's measured text_bytes row changes, to 201812; the 10% tolerance and all stack budgets remain unchanged.

The pre-change merged PR358 job already failed this row: 201028 bytes on Rust 1.99.0 versus the existing 200046-byte limit. The initial PR360 job measured 201812 bytes on Rust 1.99.1; both measured 3119 bytes of peak stack. These CI builds use different compiler patch versions, so their 784-byte difference is not a controlled comparison.

A controlled local release build with Rust 1.96.1 and thumbv7em-none-eabihf measured 191492 bytes at base a33031d and 192692 bytes with this fix (+1200 bytes). The additional finite checks and positive rescaling prevent finite polynomial inputs from silently losing all real roots. The measured CI value is proposed as a reviewed baseline; no numerical checks or budget tolerance are relaxed.

The updated hardware-FPU budget check now passes. The remaining RISC-V runtime assembly failure (.cfi_startproc/unfinished frame) is also present in merged PR358's baseline job; its runtime/toolchain is unchanged by this PR.

@KSHITIZ6341
KSHITIZ6341 requested a review from kmolan as a code owner October 22, 2026 10:28

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

None yet

Development

Successfully merging this pull request may close these issues.

Normalize the Sturm chain entries so high degrees survive f32

1 participant