about summary refs log tree commit diff
path: root/math/s_catanh.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-04-24 18:49:13 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-04-24 18:49:13 +0000
commit2f38fbfe09e4856c571bf0c80844e5dac9bc77ec (patch)
tree6fc88a0757c95d123f8e8cd9b14e973c9a654d88 /math/s_catanh.c
parent45d69176e8b6dc0787dcb8e52e4283b8e7e5e282 (diff)
downloadglibc-2f38fbfe09e4856c571bf0c80844e5dac9bc77ec.tar.gz
glibc-2f38fbfe09e4856c571bf0c80844e5dac9bc77ec.tar.xz
glibc-2f38fbfe09e4856c571bf0c80844e5dac9bc77ec.zip
Fix catan, catanh inaccuracy through use of log (bug 15394).
Diffstat (limited to 'math/s_catanh.c')
-rw-r--r--math/s_catanh.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/math/s_catanh.c b/math/s_catanh.c
index 5371f44b67..0ee8c64b6f 100644
--- a/math/s_catanh.c
+++ b/math/s_catanh.c
@@ -64,7 +64,14 @@ __catanh (__complex__ double x)
       double den = 1.0 - __real__ x;
       den = i2 + den * den;
 
-      __real__ res = 0.25 * (__ieee754_log (num) - __ieee754_log (den));
+      double f = num / den;
+      if (f < 0.5)
+	__real__ res = 0.25 * __ieee754_log (f);
+      else
+	{
+	  num = 4.0 * __real__ x;
+	  __real__ res = 0.25 * __log1p (num / den);
+	}
 
       den = 1 - __real__ x * __real__ x - i2;