{"id":28477480,"url":"https://github.com/kanition/quadraticequationsolver","last_synced_at":"2025-10-09T13:32:22.467Z","repository":{"id":297791220,"uuid":"994254556","full_name":"kanition/QuadraticEquationSolver","owner":"kanition","description":"Robust High-Precision Quadratic Equation Solver","archived":false,"fork":false,"pushed_at":"2025-06-23T14:36:44.000Z","size":4937,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-23T15:36:33.925Z","etag":null,"topics":["catastrophic-cancellation","floating-point","numerical-calculation","overflow","quadratic-equation","underflow"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kanition.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-01T14:57:07.000Z","updated_at":"2025-06-23T14:36:48.000Z","dependencies_parsed_at":"2025-06-23T15:39:56.617Z","dependency_job_id":null,"html_url":"https://github.com/kanition/QuadraticEquationSolver","commit_stats":null,"previous_names":["kanition/quadraticequationsolver"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kanition/QuadraticEquationSolver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanition%2FQuadraticEquationSolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanition%2FQuadraticEquationSolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanition%2FQuadraticEquationSolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanition%2FQuadraticEquationSolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kanition","download_url":"https://codeload.github.com/kanition/QuadraticEquationSolver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanition%2FQuadraticEquationSolver/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262739145,"owners_count":23356659,"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":["catastrophic-cancellation","floating-point","numerical-calculation","overflow","quadratic-equation","underflow"],"created_at":"2025-06-07T16:36:21.114Z","updated_at":"2025-10-09T13:32:22.456Z","avatar_url":"https://github.com/kanition.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- # Robust High-Precision Quadratic Equation Solver --\u003e\n![https://github.com/kanition/QuadraticEquationSolver](.github/banner.png)\n\n![C++](https://img.shields.io/badge/C++-Solutions-blue.svg?logo=c%2B%2B)\n[![GitHub License](https://img.shields.io/github/license/kanition/QuadraticEquationSolver)](LICENSE)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/kanition/QuadraticEquationSolver/.github%2Fworkflows%2Fcmake-multi-platform.yml)\n\nA *Robust High-Precision* [Quadratic Equation](https://en.wikipedia.org/wiki/Quadratic_equation) Solver in C++20 for\n```math\nax^2+bx+c=0,\n```\nwhere $a,b,c$ and $x$ are all real numbers in the [*Floating-Point*](https://en.wikipedia.org/wiki/Floating-point_arithmetic) format,\nunder [IEEE Standard for Floating-Point Arithmetic (IEEE 754)](https://en.wikipedia.org/wiki/IEEE_754).\n\nBoth single-precision (32-bits) and double-precision (64-bits) are supported.\n\n## Quick Start\nTo use this solver in your project, you can:\n1. Include the header file [QuadraticEquationSolver.h](./QuadraticEquationSolver.h);\n2. Initialize a `QuadraticEquationSolver` with $a,b,c$;\n3. Call the solver method `solve` to get the roots and state!\n```cpp\n#include \"QuadraticEquationSolver.h\"\n\ndouble a = 1.0, b = 4.0, c = -5.0;\nQuadtraticEquationSolver\u003cdouble\u003e solver(a, b, c);\n\ndouble x1, x2;\n// x1 and x2 will be the two roots! And s is their state.\nSolverState s = solver.solve(x1, x2);\n```\n\n4. Print the roots and state;\n```cpp\n#include \u003ciostream\u003e\n\nstd::cout \u003c\u003c \"x1: \" \u003c\u003c x1 \u003c\u003c std::endl;\nstd::cout \u003c\u003c \"x2: \" \u003c\u003c x2 \u003c\u003c std::endl;\n\n// Print the state of the solver itself\nstd::cout \u003c\u003c \"State: \" \u003c\u003c solver.print_solver_state() \u003c\u003c std::endl;\n\n// Or print the specified state `s` by the class static method\nstd::cout \u003c\u003c \"State: \" \u003c\u003c QuadtraticEquationSolver\u003cdouble\u003e::print_solver_state(s) \u003c\u003c std::endl;\n```\n\n5. You can re-use the solver by `reset`:\n```cpp\na = 1.0, b = 4.0, c = 4.0;\nsolver.reset(a, b, c); // Clean the solver state and reset a, b, c\ns = solver.solve(x1, x2); // Solve the new equation\n```\n\n## Compile and Run Demo\nRequirements:\n* [CMake](https://cmake.org/) \u003e= 3.20\n* C++ compiler [supporting C++20 standard](https://en.cppreference.com/w/cpp/compiler_support.html#C.2B.2B20_features).\n```bash\n# Make a directory OUTSIDE this source directory and go into it\nmkdir ../build\ncd ../build\n\n# Use cmake to configure the project with this SOURCE DIRECTORY\ncmake ../QuadtraticEquationSolver\n\n# Compile\nmake\n\n# Run the demo\n./demo\n\n# Optional: run the test\nmake test\n\n# Optional: Compare QuadtraticEquationSolver and a naive non-robust solver\n./float_test  # For 41 single-precision (32-bits) cases\n./double_test # For 41 double-precision (64-bits) cases\n```\n## Robustness \u0026 Precision\nSee [here](./Robustness_Precision.md) for more detailed discussion and surprising cases.\n\n## Acknowledgement\n### About Algorithm\nThank the author for developing and sharing this algorithm in the following [paper](https://cnrs.hal.science/hal-04116310v1).\n```\nFrédéric Goualard. The Ins and Outs of Solving Quadratic Equations with Floating-Point Arithmetic. 2023. ⟨hal-04116310⟩\n```\n### About Banner\nBased on works by [wepik@Freepik](https://www.freepik.com/author/wepik)\n## LICENSE\n\nCopyright 2025 Kanition\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanition%2Fquadraticequationsolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkanition%2Fquadraticequationsolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanition%2Fquadraticequationsolver/lists"}