[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master b14e318 18/22: Adjust tolerance for a particu
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master b14e318 18/22: Adjust tolerance for a particular unit-test function |
Date: |
Sun, 6 Jun 2021 21:38:02 -0400 (EDT) |
branch: master
commit b14e3184483b121121099a3de1f7ee832ee656ce
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Adjust tolerance for a particular unit-test function
decimal_root() sets 't' equal to 0.5 * 10^decimals, so test both
brent_zero() and decimal_root() with a tolerance of 0.5e0.
---
zero_test.cpp | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/zero_test.cpp b/zero_test.cpp
index 90a9e9c..e6fb3bd 100644
--- a/zero_test.cpp
+++ b/zero_test.cpp
@@ -110,8 +110,8 @@ struct e_nineteenth
/// required by Brent's method (counting the endpoint evaluations) is
/// (k+1)^2 - 2 [Brent's eq. 3.4]
///
-/// For this function, k = [log2(200/1)] = 8, so Brent's method should
-/// take no more than 9^2-2 = 79 function evaluations.
+/// For this function, k = [log2(200/0.5)] = 9, so Brent's method
+/// should take no more than 10^2-2 = 98 function evaluations.
///
/// The parameters hardcoded here were chosen to prevent overflow.
/// This is not a dramatic illustration of the superiority to Dekker's
@@ -124,7 +124,7 @@ double eq_2_1(double x)
{
double a = -100.0;
double b = 100.0;
- double t = 1.0; // lowercase delta = Brent's 'tol'
+ double t = 0.5; // lowercase delta = Brent's 'tol'
return
(x == a) ? -((b - a - t) / t) * std::pow(2.0, b / t)
: (x < a + t) ? 1.0
@@ -254,8 +254,13 @@ int test_main(int, char*[])
double d = brent_zero(-1.0, 4.0, 1.0e-20, e_19);
LMI_TEST(std::fabs(d) <= epsilon);
- d = brent_zero(-100.0, 100.0, 1.0e-20, eq_2_1);
- LMI_TEST(-100.0 <= d && d <= -100.0 * (1.0 - 6.0 * epsilon));
+ d = brent_zero(-100.0, 100.0, 0.5, eq_2_1);
+ double eq_2_1_upper = (2.0 * 0.5) + -100.0 * (1.0 - 6.0 * epsilon);
+ LMI_TEST(-100.0 <= d && d <= eq_2_1_upper);
+
+ r = decimal_root(-100.0, 100.0, bias_none, 0, eq_2_1);
+ LMI_TEST(root_is_valid == r.validity);
+ LMI_TEST(-100.0 <= r.root && r.root <= eq_2_1_upper);
r = decimal_root(-100.0, 100.0, bias_none, 20, eq_2_1);
LMI_TEST(root_is_valid == r.validity);
- [lmi-commits] [lmi] master updated (f0526be -> 86661b6), Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 7bd1245 01/22: Add a unit test: root of another unfriendly function, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master c01b9b0 02/22: Improve concinnity, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 012967c 08/22: Diagnose any attempt to find a root in a zero-measure interval, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 83eb025 05/22: Rename a local variable, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master ec0a308 06/22: Refactor, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 99aebcc 07/22: Treat decimal_root return value more flexibly, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 5c31ab3 09/22: Fix latent unit-test errors, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 2391573 11/22: Rename a variable, for terseness, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master b14e318 18/22: Adjust tolerance for a particular unit-test function,
Greg Chicares <=
- [lmi-commits] [lmi] master 1c448d8 20/22: Augment decimal_root()'s return type, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 53c3513 21/22: Reorder unit tests, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 5cf534c 04/22: Constify, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 3865416 10/22: Rearrange certain unit tests, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 1f8316c 16/22: Test actual return value, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 3d4adb3 17/22: Clarify, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 200e756 03/22: Clarify documentation, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 1b0ed06 12/22: Change argument order, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 86661b6 22/22: Validate number of iterations, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 9027fef 13/22: Refactor, Greg Chicares, 2021/06/06