[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master ff833df3 1/9: Verify against independent calc
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master ff833df3 1/9: Verify against independent calculations |
Date: |
Sat, 21 May 2022 20:13:51 -0400 (EDT) |
branch: master
commit ff833df3e700904ee0dbe0275f8f42be27ee0d22
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Verify against independent calculations
---
math_functions_test.cpp | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/math_functions_test.cpp b/math_functions_test.cpp
index 5ad57626..1658856b 100644
--- a/math_functions_test.cpp
+++ b/math_functions_test.cpp
@@ -158,16 +158,34 @@ void test_expm1_log1p()
std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
std::cout.precision(23);
+ // Test several known correctly rounded values. See:
+ // https://lists.nongnu.org/archive/html/lmi/2022-05/msg00030.html
+ // which gives the more precise values
+ // 1.7456010150169164939897763166603876240737508195959622916673980879...
+ // 1.7456010150169166 = 3FFBEDFB5475CB01 correctly rounded binary64
+ // [1.7456010150169163 = 3FFBEDFB5475CB00 lower neighbor--rejected]
+ // for e^1.01 - 1 . Similarly, using
+ // https://www.wolframalpha.com/input?i2d=true&i=ln\(40)1.01\(41)
+ // https://babbage.cs.qc.cuny.edu/IEEE-754.old/Decimal.html
+ // ln(1 + 0.01) is
+ // 0.0099503308531680828482153575442607416886796099400587978646095597...
+ // 0.009950330853168083 = 3F8460D6CCCA3677
+ // and
+ // https://www.wolframalpha.com/input?i=exp(ln(1.04)/12)-1
+ // exp(ln(1 + .04) / 12) - 1 is
+ // 0.0032737397821988638592943204158789680534098426263396651605608434...
+ // 0.0032737397821988637 = 3F6AD187A99AE58B
+
double const x = lmi::expm1(1.01);
double const y = lmi::log1p(0.01);
double const z = lmi::expm1(lmi::log1p(0.04) / 12);
- // digits 1 23456789012345678901234
- LMI_TEST_EQUAL(1.74560101501691655734305, x);
- // digits 123456789012345678901
- LMI_TEST_EQUAL(0.00995033085316808334209, y);
- // digits 123456789012345678901
- LMI_TEST_EQUAL(0.00327373978219886374239, z);
+ // digits 1 2345678901234567
+ LMI_TEST_EQUAL(1.7456010150169166, x);
+ // digits 1234567890123456
+ LMI_TEST_EQUAL(0.009950330853168083, y);
+ // digits 12345678901234567
+ LMI_TEST_EQUAL(0.0032737397821988637, z);
}
/// This function isn't a unit test per se. Its purpose is to show
- [lmi-commits] [lmi] master updated (926d9f91 -> 82468e66), Greg Chicares, 2022/05/21
- [lmi-commits] [lmi] master b52923fa 2/9: Make further use of values known to be correctly rounded, Greg Chicares, 2022/05/21
- [lmi-commits] [lmi] master fdf41a42 4/9: Reorganize unit tests, Greg Chicares, 2022/05/21
- [lmi-commits] [lmi] master 82468e66 9/9: Show architectural context at start of main test function, Greg Chicares, 2022/05/21
- [lmi-commits] [lmi] master e59c42d3 7/9: Rearrange unit-test functions in invocation order, Greg Chicares, 2022/05/21
- [lmi-commits] [lmi] master d393cd47 3/9: Move a block to make an incipient refactoring simpler, Greg Chicares, 2022/05/21
- [lmi-commits] [lmi] master ff833df3 1/9: Verify against independent calculations,
Greg Chicares <=
- [lmi-commits] [lmi] master 0c667ac5 5/9: Move an output line, Greg Chicares, 2022/05/21
- [lmi-commits] [lmi] master 3ebab874 8/9: Test fdlibm against C RTL, Greg Chicares, 2022/05/21
- [lmi-commits] [lmi] master 4e300fbc 6/9: Rearrange a unit test's output, Greg Chicares, 2022/05/21