{"id":18847797,"url":"https://github.com/jacobwilliams/polyroots-fortran","last_synced_at":"2026-01-24T06:42:56.842Z","repository":{"id":59342267,"uuid":"535304531","full_name":"jacobwilliams/polyroots-fortran","owner":"jacobwilliams","description":"Modern Fortran library for finding the roots of real and complex polynomial equations","archived":false,"fork":false,"pushed_at":"2024-01-21T22:58:01.000Z","size":2686,"stargazers_count":22,"open_issues_count":6,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-30T13:57:13.686Z","etag":null,"topics":["companion-matrix","eigenvalues","fortran","fortran-package-manager","jenkins-traub","laguerre-method","nonlinear-equations","polynomial-equations","polynomial-roots","polynomials","root-finding"],"latest_commit_sha":null,"homepage":"","language":"Fortran","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/jacobwilliams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-09-11T13:19:31.000Z","updated_at":"2024-07-26T14:23:16.000Z","dependencies_parsed_at":"2024-01-21T06:31:42.567Z","dependency_job_id":"e81c95d3-fce9-461b-ac36-6b40ee0edd49","html_url":"https://github.com/jacobwilliams/polyroots-fortran","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fpolyroots-fortran","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fpolyroots-fortran/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fpolyroots-fortran/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fpolyroots-fortran/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacobwilliams","download_url":"https://codeload.github.com/jacobwilliams/polyroots-fortran/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239783803,"owners_count":19696447,"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","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":["companion-matrix","eigenvalues","fortran","fortran-package-manager","jenkins-traub","laguerre-method","nonlinear-equations","polynomial-equations","polynomial-roots","polynomials","root-finding"],"created_at":"2024-11-08T03:09:42.461Z","updated_at":"2026-01-24T06:42:56.792Z","avatar_url":"https://github.com/jacobwilliams.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"![polyroots-fortran](media/logo.png)\n============\n\n**polyroots-fortran**: Polynomial Roots with Modern Fortran\n\n[![Language](https://img.shields.io/badge/-Fortran-734f96?logo=fortran\u0026logoColor=white)](https://github.com/topics/fortran)\n[![GitHub release](https://img.shields.io/github/release/jacobwilliams/polyroots-fortran.svg)](https://github.com/jacobwilliams/polyroots-fortran/releases/latest)\n[![CI Status](https://github.com/jacobwilliams/polyroots-fortran/actions/workflows/CI.yml/badge.svg)](https://github.com/jacobwilliams/polyroots-fortran/actions)\n[![codecov](https://codecov.io/gh/jacobwilliams/polyroots-fortran/branch/master/graph/badge.svg)](https://codecov.io/gh/jacobwilliams/polyroots-fortran)\n[![last-commit](https://img.shields.io/github/last-commit/jacobwilliams/polyroots-fortran)](https://github.com/jacobwilliams/polyroots-fortran/commits/master)\n\n## Description\n\nA modern Fortran library for finding the roots of polynomials.\n\n## Methods\n\nMany of the methods are from legacy libraries. They have been extensively modified and refactored into Modern Fortran.\n\nMethod name | Polynomial type | Coefficients | Roots | Reference\n--- | --- | --- | --- | ---\n[`cpoly`](https://jacobwilliams.github.io/polyroots-fortran/proc/cpoly.html) | General | complex | complex | [Jenkins \u0026 Traub (1972)](https://dl.acm.org/doi/abs/10.1145/361254.361262)\n[`rpoly`](https://jacobwilliams.github.io/polyroots-fortran/proc/rpoly.html) | General | real | complex | [Jenkins \u0026 Traub (1975)](https://dl.acm.org/doi/10.1145/355637.355643)\n[`rpzero`](https://jacobwilliams.github.io/polyroots-fortran/proc/rpzero.html) | General | real | complex | [SLATEC](https://netlib.org/slatec/src/rpzero.f)\n[`cpzero`](https://jacobwilliams.github.io/polyroots-fortran/proc/cpzero.html) | General | complex | complex | [SLATEC](https://netlib.org/slatec/src/cpzero.f)\n[`rpqr79`](https://jacobwilliams.github.io/polyroots-fortran/proc/rpqr79.html) | General | real | complex | [SLATEC](https://netlib.org/slatec/src/rpqr79.f)\n[`cpqr79`](https://jacobwilliams.github.io/polyroots-fortran/proc/cpqr79.html) | General | complex | complex | [SLATEC](https://netlib.org/slatec/src/cpqr79.f)\n[`dqtcrt`](https://jacobwilliams.github.io/polyroots-fortran/proc/dqtcrt.html) | Quartic | real | complex | [NSWC Library](https://github.com/jacobwilliams/nswc)\n[`dcbcrt`](https://jacobwilliams.github.io/polyroots-fortran/proc/dcbcrt.html) | Cubic | real | complex | [NSWC Library](https://github.com/jacobwilliams/nswc)\n[`dqdcrt`](https://jacobwilliams.github.io/polyroots-fortran/proc/dqdcrt.html) | Quadratic | real | complex | [NSWC Library](https://github.com/jacobwilliams/nswc)\n[`quadpl`](https://jacobwilliams.github.io/polyroots-fortran/proc/quadpl.html) | Quadratic | real | complex | [NSWC Library](https://github.com/jacobwilliams/nswc)\n[`dpolz`](https://jacobwilliams.github.io/polyroots-fortran/proc/dpolz.html) | General | real | complex | [MATH77 Library](https://netlib.org/math/)\n[`cpolz`](https://jacobwilliams.github.io/polyroots-fortran/proc/cpolz.html) | General | complex | complex | [MATH77 Library](https://netlib.org/math/)\n[`polyroots`](https://jacobwilliams.github.io/polyroots-fortran/proc/polyroots.html) | General | real | complex | [LAPACK](https://netlib.org/lapack/explore-html/index.html)\n[`cpolyroots`](https://jacobwilliams.github.io/polyroots-fortran/proc/cpolyroots.html) | General | complex | complex | [LAPACK](https://netlib.org/lapack/explore-html/index.html)\n[`rroots_chebyshev_cubic`](https://jacobwilliams.github.io/polyroots-fortran/proc/rroots_chebyshev_cubic.html) | Cubic | real | complex | [Lebedev (1991)](https://doi.org/10.1515/rnam.1991.6.4.315)\n[`qr_algeq_solver`](https://jacobwilliams.github.io/polyroots-fortran/proc/qr_algeq_solver.html) | General | real | complex | [Edelman \u0026 Murakami (1995)](https://www.ams.org/journals/mcom/1995-64-210/S0025-5718-1995-1262279-2/S0025-5718-1995-1262279-2.pdf)\n[`polzeros`](https://jacobwilliams.github.io/polyroots-fortran/proc/polzeros.html) | General | complex | complex | [Bini (1996)](https://link.springer.com/article/10.1007/BF02207694)\n[`cmplx_roots_gen`](https://jacobwilliams.github.io/polyroots-fortran/proc/cmplx_roots_gen.html) | General | complex | complex | [Skowron \u0026 Gould (2012)](http://www.astrouw.edu.pl/~jskowron/cmplx_roots_sg/)\n[`fpml`](https://jacobwilliams.github.io/polyroots-fortran/proc/fpml.html) | General | complex | complex | [Cameron (2019)](https://link.springer.com/article/10.1007/s11075-018-0641-9)\n\nThe library also includes some utility routines:\n\n* [newton_root_polish](https://jacobwilliams.github.io/polyroots-fortran/interface/newton_root_polish.html)\n* [sort_roots](https://jacobwilliams.github.io/polyroots-fortran/proc/sort_roots.html)\n\n## Example\n\nAn example of using `polyroots` to compute the zeros for a 5th order real polynomial $$P(x) = x^5 + 2x^4 + 3x^3 + 4x^2 + 5x + 6$$\n\n```fortran\nprogram example\n\nuse iso_fortran_env\nuse polyroots_module, wp =\u003e polyroots_module_rk\n\nimplicit none\n\ninteger,parameter :: degree = 5 !! polynomial degree\nreal(wp),dimension(degree+1) :: p = [1,2,3,4,5,6] !! coefficients\n\ninteger :: i !! counter\ninteger :: istatus !! status code\nreal(wp),dimension(degree) :: zr !! real components of roots\nreal(wp),dimension(degree) :: zi !! imaginary components of roots\n\ncall polyroots(degree, p, zr, zi, istatus)\n\nwrite(*,'(A,1x,I3)') 'istatus: ', istatus\nwrite(*, '(*(a22,1x))') 'real part', 'imaginary part'\ndo i = 1, degree\n    write(*,'(*(e22.15,1x))') zr(i), zi(i)\nend do\n\nend program example\n```\n\nThe result is:\n\n```\nistatus:    0\n             real part         imaginary part\n 0.551685463458982E+00  0.125334886027721E+01\n 0.551685463458982E+00 -0.125334886027721E+01\n-0.149179798813990E+01  0.000000000000000E+00\n-0.805786469389031E+00  0.122290471337441E+01\n-0.805786469389031E+00 -0.122290471337441E+01\n```\n\n## Compiling\n\nA `fpm.toml` file is provided for compiling polyroots-fortran with the [Fortran Package Manager](https://github.com/fortran-lang/fpm). For example, to build:\n\n```\nfpm build --profile release\n```\n\nBy default, the library is built with double precision (`real64`) real values. Explicitly specifying the real kind can be done using the following processor flags:\n\nPreprocessor flag | Kind  | Number of bytes\n----------------- | ----- | ---------------\n`REAL32`  | `real(kind=real32)`  | 4\n`REAL64`  | `real(kind=real64)`  | 8\n`REAL128` | `real(kind=real128)` | 16\n\nFor example, to build a single precision version of the library, use:\n\n```\nfpm build --profile release --flag \"-DREAL32\"\n```\n\nAll routines, except for `polyroots` are available for any of the three real kinds. `polyroots` is not available for `real128` kinds since there is no corresponding LAPACK eigenvalue solver.\n\nTo run the unit tests:\n\n```\nfpm test\n```\n\nTo use `polyroots-fortran` within your fpm project, add the following to your `fpm.toml` file:\n```toml\n[dependencies]\npolyroots-fortran = { git=\"https://github.com/jacobwilliams/polyroots-fortran.git\" }\n```\n\nor, to use a specific version:\n```toml\n[dependencies]\npolyroots-fortran = { git=\"https://github.com/jacobwilliams/polyroots-fortran.git\", tag = \"1.2.0\"  }\n```\n\nTo generate the documentation using [ford](https://github.com/Fortran-FOSS-Programmers/ford), run: ```ford ford.md```\n\n## Documentation\n\nThe latest API documentation for the `master` branch can be found [here](https://jacobwilliams.github.io/polyroots-fortran/). This was generated from the source code using [FORD](https://github.com/Fortran-FOSS-Programmers/ford).\n\n## License\n\nThe polyroots-fortran source code and related files and documentation are distributed under a permissive free software [license](https://github.com/jacobwilliams/polyroots-fortran/blob/master/LICENSE.md) (BSD-style).\n\n## See also\n\n* [Roots-Fortran](https://github.com/jacobwilliams/roots-fortran)\n\n## Similar libraries in other programming languages\n\n* R: [polyroot](https://stat.ethz.ch/R-manual/R-devel/library/base/html/polyroot.html)\n* MATLAB: [roots](https://www.mathworks.com/help/matlab/ref/roots.html)\n* C: [GSL - Polynomials](https://www.gnu.org/software/gsl/doc/html/poly.html), [MPSolve](https://numpi.dm.unipi.it/software/mpsolve)\n* Julia: [PolynomialRoots.jl](https://github.com/giordano/PolynomialRoots.jl), [FastPolynomialRoots.jl](https://github.com/andreasnoack/FastPolynomialRoots.jl), [Polynomials.jl](https://github.com/JuliaMath/Polynomials.jl)\n* Python: [numpy.polynomial.polynomial](https://docs.scipy.org/doc//numpy-1.10.4/reference/routines.polynomials.polynomial.html)\n\n## Other references and codes\n\n* [GAMS Class F1a](https://gams.nist.gov/cgi-bin/serve.cgi/Class/F1a).\n* [eiscor - eigensolvers based on unitary core transformations](https://github.com/eiscor/eiscor) containing the AMVW method from the work of [Aurentz et al. (2015), Fast and Backward Stable Computation of Roots of Polynomials](https://doi.org/10.1137/140983434) (an earlier version can be picked up from [the website of Ran Vandebril](https://people2.cs.kuleuven.be/~raf.vandebril/homepage/software/companion_qr.php?menu=5), one of the co-authors of that paper).\n* [PA03](https://www.hsl.rl.ac.uk/archive/specs/pa03.pdf) HSL Archive code for computing all the roots of a cubic polynomial\n* [PA05](https://www.hsl.rl.ac.uk/archive/specs/pa05.pdf) HSL Archive code for computing all the roots of a quartic polynomial\n* [PA16](https://www.hsl.rl.ac.uk/catalogue/pa16.html), [PA17](https://www.hsl.rl.ac.uk/catalogue/pa17.html) HSL codes for computing zeros of polynomials using method of Madsen and Reid\n* Various codes from [Alan Miller](https://jblevins.org/mirror/amiller/)\n* [A solver using the companion matrix and LAPACK](https://fortran-lang.discourse.group/t/cardanos-solution-of-the-cubic-equation/111/5?u=ivanpribec)\n* [Root-finding algorithms: Roots of Polynomials | Wikipedia](https://en.wikipedia.org/wiki/Root-finding_algorithms#Roots_of_polynomials)\n* [Polynomial Roots | Wolfram MathWorld](https://mathworld.wolfram.com/PolynomialRoots.html)\n* [What is a Companion Matrix | Nick Higham](https://nhigham.com/2021/03/23/what-is-a-companion-matrix/)\n* [19 Dubious Ways to Compute the Zeros of a Polynomial | Cleve's Corner](https://blogs.mathworks.com/cleve/2016/06/27/19-dubious-ways-to-compute-the-zeros-of-a-polynomial/)\n* [New Progress in Polynomial Root-finding | Victor Y. Pan](https://arxiv.org/pdf/1805.12042.pdf)\n\n## See also\n\n * [Code coverage statistics](https://app.codecov.io/gh/jacobwilliams/polyroots-fortran) [codecov.io]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobwilliams%2Fpolyroots-fortran","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobwilliams%2Fpolyroots-fortran","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobwilliams%2Fpolyroots-fortran/lists"}