From ac0d67bce9d487fe8a348a9b069c61e788348f9b Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 28 Oct 2010 18:37:38 -0400 Subject: Handle narrow ranges in dmnsn_bisect_root(). --- libdimension/polynomial.c | 3 +++ 1 file changed, 3 insertions(+) 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); -- cgit v1.2.3