{"id":19541433,"url":"https://github.com/ickk/aberth","last_synced_at":"2025-08-31T20:10:31.044Z","repository":{"id":152328674,"uuid":"625767211","full_name":"ickk/aberth","owner":"ickk","description":"Aberth's method for finding the zeros of a polynomial","archived":false,"fork":false,"pushed_at":"2025-01-11T03:31:21.000Z","size":33,"stargazers_count":4,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-07-25T23:42:45.101Z","etag":null,"topics":["mathematics","root-finding"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/aberth","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ickk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-04-10T03:52:11.000Z","updated_at":"2025-01-09T14:28:25.000Z","dependencies_parsed_at":"2025-04-26T17:42:07.018Z","dependency_job_id":null,"html_url":"https://github.com/ickk/aberth","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ickk/aberth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickk%2Faberth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickk%2Faberth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickk%2Faberth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickk%2Faberth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ickk","download_url":"https://codeload.github.com/ickk/aberth/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickk%2Faberth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273032934,"owners_count":25034067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mathematics","root-finding"],"created_at":"2024-11-11T03:10:28.581Z","updated_at":"2025-08-31T20:10:31.006Z","avatar_url":"https://github.com/ickk.png","language":"Rust","readme":"aberth\n======\n[crates.io](https://crates.io/crates/aberth) |\n[docs.rs](https://docs.rs/aberth) |\n[github](https://github.com/ickk/aberth)\n\nAn implementation of the\n[Aberth-Ehrlich method](https://en.wikipedia.org/wiki/Aberth_method)\nfor finding the zeros of a polynomial.\n\nAberth's method uses an electrostatics analogy to model the approximations as\nnegative charges and the true zeros as positive charges. This enables finding\nall complex roots simultaneously, converging cubically (worst-case it converges\nlinearly for zeros of multiplicity).\n\nThis crate is `#![no_std]` and tries to have minimal dependencies. It uses\n[arrayvec](https://crates.io/crates/arrayvec)\nto avoid allocations, which will be removed when rust stabilises support for\nconst-generics.\n\n\nUsage\n-----\n\nAdd it to your project:\n```sh\ncargo add aberth\n```\n\nSpecify the coefficients of your polynomial in an array in ascending order and\nthen call the `aberth` method on your polynomial.\n```rust\nuse aberth::aberth;\nconst EPSILON: f32 = 0.001;\nconst MAX_ITERATIONS: u32 = 10;\n\n// 0 = -1 + 2x + 4x^4 + 11x^9\nlet polynomial = [-1., 2., 0., 0., 4., 0., 0., 0., 0., 11.];\n\nlet roots = aberth(\u0026polynomial, MAX_ITERATIONS, EPSILON);\n// [\n//   Complex { re:  0.4293261, im:  1.084202e-19 },\n//   Complex { re:  0.7263235, im:  0.4555030 },\n//   Complex { re:  0.2067199, im:  0.6750696 },\n//   Complex { re: -0.3448952, im:  0.8425941 },\n//   Complex { re: -0.8028113, im:  0.2296336 },\n//   Complex { re: -0.8028113, im: -0.2296334 },\n//   Complex { re: -0.3448952, im: -0.8425941 },\n//   Complex { re:  0.2067200, im: -0.6750695 },\n//   Complex { re:  0.7263235, im: -0.4555030 },\n// ]\n```\n\nThe above method does not require any allocation, instead doing all the\ncomputation on the stack. It is generic over any size of polynomial, but the\nsize of the polynomial must be known at compile time.\n\nThe coefficients of the polynomial may be `f32`, `f64`, or even complex numbers\n`Complex\u003cf32\u003e`, `Complex\u003cf64\u003e`:\n```rust\n# use aberth::{aberth, Complex};\n#\n# let p1 = [1_f32, 2_f32];\n# let r1 = aberth(\u0026p1, 10, 0.001);\n#\n# let p2 = [1_f64, 2_f64];\n# let r2 = aberth(\u0026p2, 10, 0.001);\n#\n# let p3 = [Complex::new(1_f32, 2_f32), Complex::new(3_f32, 4_f32)];\n# let r3 = aberth(\u0026p3, 10, 0.001);\n#\n# const MAX_ITERATIONS: u32 = 10;\n# const EPSILON: f64 = 0.001;\nlet polynomial = [Complex::new(1_f64, 2_f64), Complex::new(3_f64, 4_f64)];\nlet roots = aberth(\u0026polynomial, MAX_ITERATIONS, EPSILON);\n```\n\nIf `std` is available then there is also an `AberthSolver` struct which\nallocates some memory to support dynamically sized polynomials at run time.\nThis may also be good to use when you are dealing with polynomials with many\nterms, as it uses the heap instead of blowing up the stack.\n\n```rust\nuse aberth::AberthSolver;\n\nlet mut solver = AberthSolver::new();\nsolver.epsilon = 0.001;\nsolver.max_iterations = 10;\n\n// 0 = -1 + 2x + 4x^3 + 11x^4\nlet a = [-1., 2., 0., 4., 11.];\n// 0 = -28 + 39x^2 - 12x^3 + x^4\nlet b = [-28., 0., 39., -12., 1.];\n\nfor polynomial in [a, b] {\n  let roots = solver.find_roots(\u0026polynomial);\n  // ...\n}\n```\n\nNote that the returned values are not sorted in any particular order.\n\nThe coefficient of the highest degree term should not be zero.\n\n\n`#![no_std]`\n------------\n\nTo use in a `no_std` environment you must disable `default-features` and enable\nthe `libm` feature:\n```toml\n[dependencies]\naberth = { version = \"0.4.1\", default-features = false, features = [\"libm\"] }\n```\n\nStability Guarantees\n--------------------\n\n**`mod internal` may experience breaking changes even in minor and patch\nreleases**:\n\nWe expose the `internal` module, for those interested in supplying their own\ninitial guesses to `internal::aberth_raw`. However this `internal` module is\nconsidered an implementation detail and does not follow the semantic versioning\nscheme of the rest of the project.\n\n\nLicense\n-------\n\nThis crate is licensed under any of the\n[Apache license, Version 2.0](./LICENSE-APACHE),\nor the\n[MIT license](./LICENSE-MIT),\nor the\n[Zlib license](./LICENSE-ZLIB)\nat your option.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fickk%2Faberth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fickk%2Faberth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fickk%2Faberth/lists"}