Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
archermarx committed Nov 10, 2023
1 parent 7009797 commit e31fd81
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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<T, T>```, 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`.

0 comments on commit e31fd81

Please sign in to comment.