[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master a7d0900 10/11: Don't assume every function ha

From: Greg Chicares
Subject: [lmi-commits] [lmi] master a7d0900 10/11: Don't assume every function has a root at the origin
Date: Thu, 1 Jul 2021 20:19:05 -0400 (EDT)

branch: master
commit a7d09006058d28306269b86fe14ebdc1d27bb938
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Don't assume every function has a root at the origin
    The error term should be close to zero; the root might not be.
 zero_test.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/zero_test.cpp b/zero_test.cpp
index 412f218..6a59f32 100644
--- a/zero_test.cpp
+++ b/zero_test.cpp
@@ -108,11 +108,13 @@ void test_a_function
     int const max_n_iter = max_n_iter_brent(bound0, bound1, tol, exact_root);
     double d = brent_zero(bound0, bound1, tol, f);
-    INVOKE_LMI_TEST_RELATION(std::fabs(d),<=,maximum_error,file,line);
+    double error = d - exact_root;
+    INVOKE_LMI_TEST_RELATION(std::fabs(error),<=,maximum_error,file,line);
     root_type r = decimal_root(bound0, bound1, bias_none, decimals, f);
     INVOKE_LMI_TEST(root_is_valid == r.validity, file, line);
-    INVOKE_LMI_TEST_RELATION(std::fabs(r.root),<=,maximum_error,file,line);
+    error = r.root - exact_root;
+    INVOKE_LMI_TEST_RELATION(std::fabs(error),<=,maximum_error,file,line);
 #if defined LMI_X86_64 && defined LMI_POSIX

reply via email to

[Prev in Thread] Current Thread [Next in Thread]