{"id":15295210,"url":"https://github.com/nieksand/rootfind","last_synced_at":"2025-07-10T10:35:25.018Z","repository":{"id":57662514,"uuid":"117526856","full_name":"nieksand/rootfind","owner":"nieksand","description":"Root finding in Rust.","archived":false,"fork":false,"pushed_at":"2018-04-22T08:58:32.000Z","size":154,"stargazers_count":7,"open_issues_count":9,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-27T06:51:20.093Z","etag":null,"topics":["mathematics","newton-raphson","numerical-methods","root-finding","rust","rustlang"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nieksand.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-15T09:47:23.000Z","updated_at":"2022-09-15T00:25:01.000Z","dependencies_parsed_at":"2022-09-12T23:22:14.015Z","dependency_job_id":null,"html_url":"https://github.com/nieksand/rootfind","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nieksand%2Frootfind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nieksand%2Frootfind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nieksand%2Frootfind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nieksand%2Frootfind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nieksand","download_url":"https://codeload.github.com/nieksand/rootfind/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537194,"owners_count":21120711,"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":["mathematics","newton-raphson","numerical-methods","root-finding","rust","rustlang"],"created_at":"2024-09-30T17:09:03.999Z","updated_at":"2025-04-13T15:59:13.662Z","avatar_url":"https://github.com/nieksand.png","language":"Rust","readme":"[![Build Status](https://travis-ci.org/nieksand/rootfind.svg?branch=master)](https://travis-ci.org/nieksand/rootfind)\n[![crates.io](https://img.shields.io/crates/v/rootfind.svg)](https://crates.io/crates/rootfind)\n[![Released API docs](https://docs.rs/rootfind/badge.svg)](http://docs.rs/rootfind)\n\n# Root Finding\n***Work in progress.  Not ready for production use!***\n\nRoot finding algorithms implemented in Rust.\n\nThis package aims to provide robust numerical methods suitable for production\nuse.  It includes extensive documentation and test coverage.\n\nCurrently features:\n\n* Bracket generation\n* Bisection\n* False Position, Illinois method\n\nSome additional methods are only available in their \"naive\" form at this time.\nThese are suitable for reproducing results from academic literature but not for\nproduction use:\n\n* Newton-Raphson\n* Halley's Method\n\nWork is in progress on production-suitable variants which hybridize these\nhigher order methods with bisection to ensure convergence.\n\nCustom convergence criteria can be supplied by the IsConverged trait.  Some\nreasonable canned implementations are provided.\n\nAs with most numerical methods, root finding algorithms require that you\nunderstand what you're trying to achieve, the nature of the input function, the\nproperties of the algorithm being used, and more.\n\nFeedback is greatly appreciated.\n\n# Usage\nSee the rustdocs for detailed documentation.\n\nThis quick example is an excerpt from tests/integration.rs.\n\n    extern crate rootfind;\n\n    use rootfind::bracket::{Bounds, BracketGenerator};\n    use rootfind::solver::bisection;\n    use rootfind::wrap::RealFn;\n\n    // roots at 0, pi, 2pi, ...\n    let f_inner = |x: f64| x.sin();\n\n    // rootfind determines via traits what is f(x), df(x), d2f(x), etc.\n    // the RealFn wrapper annotates our closure accordingly.\n    let f = RealFn::new(\u0026f_inner);\n\n    // search for root-holding brackets\n    let window_size = 0.1;\n    let bounds = Bounds::new(-0.1, 6.3);\n\n    for (i, b) in BracketGenerator::new(\u0026f, bounds, window_size)\n        .into_iter()\n        .enumerate()\n    {\n        // find root using bisection method\n        let max_iterations = 100;\n        let computed_root = bisection(\u0026f, \u0026b, max_iterations).expect(\"found root\");\n\n        // demonstrate that we found root\n        let pi = std::f64::consts::PI;\n        let expected_root = (i as f64) * pi;\n\n        assert!(\n            (computed_root - expected_root).abs() \u003c 1e-9,\n            format!(\"got={}, wanted={}\", computed_root, expected_root)\n        );\n    }\n\n# Remaining Work\n\n## Algorithms\n1. \"Safe\" variants of Newton-Raphson and Halley's Method which hybridize with a\n   bracketing method to ensure global convergence.\n\n2. A TOMS-748 implementation for finding roots when no analytic derivatives are\n   available.  (This provides a good default choice with bisection and\n   false-position as fall back options).\n\n3. Specialized routines for finding roots of Polynomials.\n\n## Design\n1. Provide visibility into the solver state as it runs.\n\n2. Allow optimized Newton-Raphson where the fraction f(x)/f'(x) is supplied\n   directly rather than being computed at runtime.  Cancellation of terms\n   provides an opportunity for performance optimization.\n\n3. Convergence criteria for bracketing methods.\n\n4. Check if converged brackets actually closed on a root rather than jump\n   discontinuity.\n\n## Cross Validation\nI want to cross-validate both the design and implementation against the C++\nBoost, SciPy, and GSL root finding implementations.\n\n## Road to 1.0.0\nThis project uses semantic versioning (major.minor.patch).  The remaining work\nmostly falls under 'minor' increments.  When that's all done, I would like some\nexternal review or feedback before cutting the official 1.0.0 release.\n\n# References\nThe Numerical Recipes book covers both implementation and methodology for\nroot-finding in depth:\n\nWilliam H. Press, Saul A. Teukolsky, William T. Vetterling, and Brian P.\nFlannery. 2007. Numerical Recipes 3rd Edition: The Art of Scientific Computing\n(3 ed.). Cambridge University Press, New York, NY, USA.\n\nThis is a top resource for practioners.  However, the code examples are\nencumbered by copyright so the Rust rootfind library steers clear of NR's\nimplementations.\n\nAnother reasonable introduction to root finding can be found in:\n\nRecktenwald, G. W. (2000). Numerical methods with MATLAB: implementations and\napplications. Upper Saddle River, NJ: Prentice Hall.\n\nWikipedia's \"Root-finding algorithm\" page provides a high-level overview of\nroot-finding techniques, but it lacks the guidance and detail for practioners.\nThe algorithm specific pages are worth looking at.\n\nI have also found the Boost, SciPy, and Gnu Scientific Library root-finding\nimplementations and documentation to be helpful.\n\n# Author\nThis was written by Niek Sanders (niek.sanders@gmail.com).\n\n# Unlicense\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or distribute this\nsoftware, either in source code form or as a compiled binary, for any purpose,\ncommercial or non-commercial, and by any means.\n\nIn jurisdictions that recognize copyright laws, the author or authors of this\nsoftware dedicate any and all copyright interest in the software to the public\ndomain. We make this dedication for the benefit of the public at large and to\nthe detriment of our heirs and successors. We intend this dedication to be an\novert act of relinquishment in perpetuity of all present and future rights to\nthis software under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\nCONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to \u003chttp://unlicense.org/\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnieksand%2Frootfind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnieksand%2Frootfind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnieksand%2Frootfind/lists"}