Skip to content

Fix incorrect multiplication #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2025

Conversation

Xendergo
Copy link
Contributor

@Xendergo Xendergo commented Aug 9, 2025

Closes #6

The issue is that the early returns in select_root can return early for an incorrect root. The multiplication operation leads to the polynomial 1-4x-64x²-64x³-64x³+256x⁴ which has roots at -0.25 and 0.0954.., the second of which is the correct answer. While shrinking the intervals, the lower bound landed on -0.25, which is a root, triggering the early return.

image

This PR fixes the logic in select_root which should prevent this problem from occurring for all of the operations, not just multiplication.

@Xendergo Xendergo marked this pull request as ready for review August 10, 2025 13:23
@Xendergo Xendergo marked this pull request as draft August 10, 2025 22:30
@programmerjake
Copy link
Owner

thanks for finding the issue, I can merge this if you're ready.

@Xendergo Xendergo marked this pull request as ready for review August 14, 2025 14:27
@Xendergo
Copy link
Contributor Author

Cool, thank you! I had it marked as a draft because I was investigating whether I caused a regression elsewhere but I don't think so.

@Xendergo
Copy link
Contributor Author

I'm planning on submitting a handful more PRs if that's OK...

If you're curious, my usecase is rewriting https://alpha.twizzle.net/explore (a tool that lets people design their own rubik's cube inspired puzzles) in Rust, using algebraics for geometric calculations :)

@programmerjake programmerjake merged commit 2443555 into programmerjake:master Aug 15, 2025
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.

Incorrect result of multiplication
2 participants