lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 9292445 5/8: Fix a unit test


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 9292445 5/8: Fix a unit test
Date: Wed, 2 Jun 2021 15:37:07 -0400 (EDT)

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

    Fix a unit test
    
    Brent's book finds a zero of x^19 to within 1e-20, which means twenty
    decimals, not negative twenty. With iterates rounded to negative twenty
    decimals, both bounds were zero, and a root was found immediately, but
    for (x^19 - 1) no root would have been found in the [0, 0] range that
    results from rounding [-1, 4].
---
 zero_test.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/zero_test.cpp b/zero_test.cpp
index fd21c18..76eb79e 100644
--- a/zero_test.cpp
+++ b/zero_test.cpp
@@ -189,8 +189,9 @@ int test_main(int, char*[])
     // chasing after wind that costs many iterations.
 
     e_nineteenth e_19;
-    r = decimal_root(-1.0, 4.0, bias_none, -20, e_19);
+    r = decimal_root(-1.0, 4.0, bias_none, 20, e_19);
     LMI_TEST(root_is_valid == r.second);
+    LMI_TEST(std::fabs(r.first) <= epsilon);
 
     test_zero(-1.0, 4.0, -100, e_19, std::exp(1.0));
     test_zero(-1.0, 4.0,    0, e_19, std::exp(1.0));



reply via email to

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