diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-10-28 18:37:38 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-10-28 18:37:38 -0400 |
commit | ac0d67bce9d487fe8a348a9b069c61e788348f9b (patch) | |
tree | b816f9148c098165cd28f6d4d8a572b047dedc84 | |
parent | 1815e17b4243a3973e1389f73fe1607ec42f5372 (diff) | |
download | dimension-ac0d67bce9d487fe8a348a9b069c61e788348f9b.tar.xz |
Handle narrow ranges in dmnsn_bisect_root().
-rw-r--r-- | libdimension/polynomial.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libdimension/polynomial.c b/libdimension/polynomial.c index 31d8309..6e8ce4e 100644 --- a/libdimension/polynomial.c +++ b/libdimension/polynomial.c @@ -86,6 +86,9 @@ dmnsn_bisect_root(double poly[], size_t degree, double min, double max) double mid = 0.0, evmid; int lastsign = -1; + if (max - min <= dmnsn_epsilon) + return min; + do { mid = (min*evmax - max*evmin)/(evmax - evmin); evmid = dmnsn_evaluate_polynomial(poly, degree, mid); |