[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master cecc91f 21/23: Avoid a unit-test false negati
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master cecc91f 21/23: Avoid a unit-test false negative |
Date: |
Tue, 27 Jul 2021 21:59:54 -0400 (EDT) |
branch: master
commit cecc91fece6a724694c80c3e783b883a69b8ab68
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Avoid a unit-test false negative
There are many binary64 values x for which cos(x) - 0.999 exactly equals
zero due to roundoff error.
---
zero_test.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/zero_test.cpp b/zero_test.cpp
index 29a2333..d1fa18f 100644
--- a/zero_test.cpp
+++ b/zero_test.cpp
@@ -870,8 +870,15 @@ void test_various_functions()
test_a_function (f02, root_02, 0.0, 2.0, 1.0e-15, __LINE__);
auto f03 = [](double x) {return std::cos(x) - 0.999;};
- auto root_03 = 0.044725087168733454;
- test_a_decimal_function(f03, root_03, -0.01, 0.8, 17 , __LINE__, 16);
+// This would seem preferable:
+// auto root_03 = std::acosl(0.999L);
+// but gcc-10.2.0 (x86_64-pc-linux-gnu) rejects it:
+// error: ‘acosl’ is not a member of ‘std’
+// despite C++20 [cmath.syn], so use this instead:
+ auto root_03 = std::acos(0.999);
+// Regardless of that theoretical ζ, the computed ζ′ is not exact
+// to more than about fifteen decimals.
+ test_a_decimal_function(f03, root_03, -0.01, 0.8, 15 , __LINE__, 16);
test_a_function (f03, root_03, -0.01, 0.8, 1.0e-15, __LINE__);
auto f04 = [](double x) {return std::pow((x - 1.0), 3);};
- [lmi-commits] [lmi] master updated (d6bd802 -> 028b454), Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master eea9469 02/23: Ignore an immaterial i686 deviation, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master a041329 08/23: Consider bounds not to bracket a root if value at either is NaN, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master c9c50dc 07/23: Add a specialized midpoint function for root finding, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master f576a4b 11/23: Augment unit test, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master dc63e62 16/23: Cache evaluations for rounded decimal solves, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master cecc91f 21/23: Avoid a unit-test false negative,
Greg Chicares <=
- [lmi-commits] [lmi] master 4b26bf8 01/23: Add a parenthetical comment to a unit test, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 86ae65d 18/23: Revert "Demonstration, for immediate reversion", Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master e59df26 14/23: Refactor, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 8f2f355 19/23: Augment unit tests; record some observations, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master a259cb6 05/23: Calculate maximum possible number of iterations, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master d0a65c2 04/23: Demonstrate that Brent's δ can be almost arbitrarily small, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 548f9ab 06/23: Document known shortcomings of a unit-testing helper, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 19a4a3a 03/23: For now at least, trace solves in regression test, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 04c58eb 09/23: Count iterations and evaluations separately, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master bbf2517 10/23: Use signum() where a signum function is wanted, Greg Chicares, 2021/07/27