summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-10-27 14:44:45 -0400
committerTavian Barnes <tavianator@gmail.com>2010-10-27 14:45:10 -0400
commitd9b039984385ca00ef21fb4159e291d70b8e9069 (patch)
tree59fdab640b791944a5aec10b5d83ad0075cd6bfa /libdimension
parent61f7e103a7c432822052164283f8e2f248372875 (diff)
downloaddimension-d9b039984385ca00ef21fb4159e291d70b8e9069.tar.xz
Add polynomial test.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/polynomial.c7
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;
}