diff --git a/README.md b/README.md index 7a93187..10ae44a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Tests](https://github.com/archermarx/quadratic/actions/workflows/test.yml/badge.svg) -Robust C++ quadratic equation solver. +Robust C++ quadratic equation solver. Solves quadratics equations without undue overflow, underflow, or catastrophic floating point cancellation. Vased on [*The Ins and Outs of Solving Quadratic Equations with Floating-Point Arithmetic* (2023)](https://www.authorea.com/users/627556/articles/648473-the-ins-and-outs-of-solving-quadratic-equations-with-floating-point-arithmetic) by Frédéric Goualard. @@ -15,12 +15,13 @@ Download the [header file](https://github.com/archermarx/quadratic/include/heade ## Usage To solve a quadratic equation with parameters `a`, `b`, and `c`, call the `solve_quadratic` function. This function returns a ```std::pair```, where `T` is the input type. -If there are no real solutions, then the pair will contain two NaNs. If there is only one solution, then it will be contained in the first element, while the second element of the pair will be NaN. +If there are no real solutions, then the pair will contain two NaNs. If there is only one solution, then it will be contained in the first element, while the second element of the pair will be NaN. ```cpp double a = 1.0; double b = 1.0; double c = 1.0; - auto [x1, x2] = solve_quadratic(a, b, c); + auto [x1, x2] = quadratic::solve(a, b, c); ``` +When the equation has two solutions, the first solution will be the smaller of the two, i.e. `x1 < x2`. \ No newline at end of file