summaryrefslogtreecommitdiff
path: root/math/s_catanl.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_catanl.c
parent45d69176e8b6dc0787dcb8e52e4283b8e7e5e282 (diff)
downloadglibc-2f38fbfe09e4856c571bf0c80844e5dac9bc77ec.tar.gz
Fix catan, catanh inaccuracy through use of log (bug 15394).
Diffstat (limited to 'math/s_catanl.c')
-rw-r--r--math/s_catanl.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/math/s_catanl.c b/math/s_catanl.c
index 57d2e59550..e04dba7387 100644
--- a/math/s_catanl.c
+++ b/math/s_catanl.c
@@ -61,7 +61,7 @@ __catanl (__complex__ long double x)
}
else
{
- long double r2, num, den;
+ long double r2, num, den, f;
r2 = __real__ x * __real__ x;
@@ -75,7 +75,14 @@ __catanl (__complex__ long double x)
den = __imag__ x - 1.0;
den = r2 + den * den;
- __imag__ res = 0.25 * __ieee754_logl (num / den);
+ f = num / den;
+ if (f < 0.5)
+ __imag__ res = 0.25 * __ieee754_logl (f);
+ else
+ {
+ num = 4.0 * __imag__ x;
+ __imag__ res = 0.25 * __log1pl (num / den);
+ }
}
return res;