]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix ldbl-128ibm tanhl inaccuracy for small arguments (bug 19349).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 9 Dec 2015 21:20:18 +0000 (21:20 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 9 Dec 2015 21:20:18 +0000 (21:20 +0000)
The ldbl-128ibm implementation of tanhl is inaccurate for small
arguments, because it returns x*(1+x) (maybe in an attempt to raise
"inexact") when x itself would be the accurate return value but
multiplying by 1+x introduces large errors.  This patch fixes it to
return x in that case (when the mathematical result is x plus a
negligible remainder on the order of x^3) to avoid those errors.

Tested for powerpc.

[BZ #19349]
* sysdeps/ieee754/ldbl-128ibm/s_tanhl.c (__tanhl): Return argument
when small.

ChangeLog
sysdeps/ieee754/ldbl-128ibm/s_tanhl.c

index b2eddff236c3f659b0445a7f367cc9170131cd4f..b76c54b9a536672cf9e0439b7a9c5d0873a55249 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2015-12-09  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #19349]
+       * sysdeps/ieee754/ldbl-128ibm/s_tanhl.c (__tanhl): Return argument
+       when small.
+
        * sysdeps/unix/sysv/linux/i386/kernel-features.h
        [__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SOCKET_SYSCALL):
        New macro.
index 292020cabff0f8919458bf20421ef5397f0940cf..e6457a1c1cff01a0f0c1b0d179fe07a4756734ce 100644 (file)
@@ -69,7 +69,7 @@ long double __tanhl(long double x)
            if (ix<0x3c60000000000000LL)        /* |x|<2**-57 */
              {
                math_check_force_underflow (x);
-               return x*(one+x);       /* tanh(small) = small */
+               return x;               /* tanh(small) = small */
              }
            if (ix>=0x3ff0000000000000LL) {     /* |x|>=1  */
                t = __expm1l(two*fabsl(x));