-
-
Notifications
You must be signed in to change notification settings - Fork 47.7k
Weierstrass Method #12877
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
Weierstrass Method #12877
Conversation
helma436
commented
Aug 4, 2025
Preparing review...
3 similar comments
helma436
commented
Aug 4, 2025
Preparing review...
helma436
commented
Aug 4, 2025
Preparing review...
helma436
commented
Aug 4, 2025
Preparing review...
MrittikaDutta
commented
Aug 21, 2025
Currently, the method always runs max_iter iterations. Adding a tolerance (tol) and stopping early when updates are small would improve efficiency.
MrittikaDutta
commented
Aug 21, 2025
For stability, sometimes using deflation or derivative checks helps avoid stagnation on multiple roots. Could be an optional enhancement.
MrittikaDutta
commented
Aug 21, 2025
Constructing the full denominator matrix (degree x degree) is O(n2).
You might optimize by computing products without building a dense matrix.
Great feedback, @MrittikaDutta !
Your suggestions are really valuable, and I’ll consider implementing them soon.
Thanks a lot!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
Requires some additional tests ideally with higher order, handling floats, does this algorithm handle complex roots, etc
If you add some more tests or commit my tests I'll merge this pr.
- Implements Durand-Kerner (Weierstrass) method for polynomial root finding - Accepts user-defined polynomial function and degree - Uses random perturbation of complex roots of unity for initial guesses - Handles validation, overflow clipping, and includes doctest
* add more tests
for more information, see https://pre-commit.ci
f293e89
to
70c4ea5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more tests wouldn't go amiss but other than that looks good
Uh oh!
There was an error while loading. Please reload this page.
Describe your change:
This pull request adds an implementation of the Weierstrass (Durand–Kerner) method to numerically approximate all complex roots of a given polynomial. The function accepts a user-defined polynomial, its degree, and an optional initial guess for the roots. The implementation includes:
Type annotations and detailed docstring
Doctest to validate correctness
Optional support for custom initial guesses
Numerical safeguards (e.g., overflow clipping)
A Wikipedia reference for further explanation
This method is useful in numerical analysis and computational algebra for finding all roots of a polynomial simultaneously using iterative refinement.
Checklist: