This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Fix ldbl-128ibm tanhl inaccuracy (bug 18790) [committed]
- From: Joseph Myers <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Mon, 10 Aug 2015 20:36:36 +0000
- Subject: Fix ldbl-128ibm tanhl inaccuracy (bug 18790) [committed]
- Authentication-results: sourceware.org; auth=none
ldbl-128ibm tanhl uses a too-small threshold to decide when to return
+/-1, resulting in large errors. This patch changes it to a more
appropriate threshold (the requirement is for 2*exp(-2|x|) to be small
in terms of ulps of 1).
Tested for x86_64, x86 and powerpc. Committed.
(auto-libm-test-out diffs omitted below.)
2015-08-10 Joseph Myers <joseph@codesourcery.com>
[BZ #18790]
* sysdeps/ieee754/ldbl-128ibm/s_tanhl.c (__tanhl): Increase
threshold for returning +/- 1.
* math/auto-libm-test-in: Add more tests of tanh.
* math/auto-libm-test-out: Regenerated.
* sysdeps/i386/fpu/libm-test-ulps: Update.
diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index c33334c..6716cfe 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -2692,6 +2692,42 @@ tanh 0.75
tanh -0.75
tanh 1.0
tanh -1.0
+tanh 2
+tanh -2
+tanh 3
+tanh -3
+tanh 4
+tanh -4
+tanh 5
+tanh -5
+tanh 6
+tanh -6
+tanh 7
+tanh -7
+tanh 8
+tanh -8
+tanh 9
+tanh -9
+tanh 10
+tanh -10
+tanh 15
+tanh -15
+tanh 20
+tanh -20
+tanh 22
+tanh -22
+tanh 25
+tanh -25
+tanh 30
+tanh -30
+tanh 35
+tanh -35
+tanh 40
+tanh -40
+tanh 45
+tanh -45
+tanh 50
+tanh -50
tanh 0x1p-57
tanh 0xe.6c659p-4
tanh 0x8.c259ep-4
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index eddb3dc..dbc8f2f 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -1924,7 +1924,7 @@ double: 1
float: 1
idouble: 1
ifloat: 1
-ildouble: 5
+ildouble: 7
ldouble: 4
Function: "tanh_towardzero":
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c b/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c
index c63e253..fe396e9 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c
@@ -29,9 +29,9 @@ static char rcsid[] = "$NetBSD: s_tanh.c,v 1.7 1995/05/10 20:48:22 jtc Exp $";
* 2**-57 < x <= 1 : tanh(x) := -----; t = expm1(-2x)
* t + 2
* 2
- * 1 <= x <= 22.0 : tanh(x) := 1- ----- ; t=expm1(2x)
+ * 1 <= x <= 40.0 : tanh(x) := 1- ----- ; t=expm1(2x)
* t + 2
- * 22.0 < x <= INF : tanh(x) := 1.
+ * 40.0 < x <= INF : tanh(x) := 1.
*
* Special cases:
* tanh(NaN) is NaN;
@@ -61,8 +61,8 @@ long double __tanhl(long double x)
else return one/x-one; /* tanh(NaN) = NaN */
}
- /* |x| < 22 */
- if (ix < 0x4036000000000000LL) { /* |x|<22 */
+ /* |x| < 40 */
+ if (ix < 0x4044000000000000LL) { /* |x|<40 */
if (ix == 0)
return x; /* x == +-0 */
if (ix<0x3c60000000000000LL) /* |x|<2**-57 */
@@ -74,7 +74,7 @@ long double __tanhl(long double x)
t = __expm1l(-two*fabsl(x));
z= -t/(t+two);
}
- /* |x| > 22, return +-1 */
+ /* |x| > 40, return +-1 */
} else {
z = one - tiny; /* raised inexact flag */
}
--
Joseph S. Myers
joseph@codesourcery.com