diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-10-27 14:44:45 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-10-27 14:45:10 -0400 |
commit | d9b039984385ca00ef21fb4159e291d70b8e9069 (patch) | |
tree | 59fdab640b791944a5aec10b5d83ad0075cd6bfa /libdimension/polynomial.c | |
parent | 61f7e103a7c432822052164283f8e2f248372875 (diff) | |
download | dimension-d9b039984385ca00ef21fb4159e291d70b8e9069.tar.xz |
Add polynomial test.
Diffstat (limited to 'libdimension/polynomial.c')
-rw-r--r-- | libdimension/polynomial.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/libdimension/polynomial.c b/libdimension/polynomial.c index f361d38..32dd922 100644 --- a/libdimension/polynomial.c +++ b/libdimension/polynomial.c @@ -80,7 +80,7 @@ dmnsn_real_degree(double poly[], size_t degree) static inline double dmnsn_improve_root(double poly[], size_t degree, double x) { - double error; + double dx; do { /* Calculate the value of the polynomial and its derivative at once */ double p = poly[degree], dp = 0.0; @@ -89,10 +89,9 @@ dmnsn_improve_root(double poly[], size_t degree, double x) p = p*x + poly[i]; } - double dx = p/dp; - error = fabs(dx/x); + dx = p/dp; x -= dx; - } while (error > dmnsn_epsilon); + } while (fabs(dx) > dmnsn_epsilon); return x; } |