summaryrefslogtreecommitdiff
path: root/math/k_casinh.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-03-27 14:38:44 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-03-27 14:38:44 +0000
commit3a7182a14becbf3149419bdbaff4388b636c9f31 (patch)
tree16616a6c0915ec7099fcd318204f8e5741571b29 /math/k_casinh.c
parent28831a9a671b109e49d0a4ddce00a08d734bfc97 (diff)
downloadglibc-3a7182a14becbf3149419bdbaff4388b636c9f31.tar.gz
Fix casinh inaccuracy near i, imaginary part > 1 (bug 15307).
Diffstat (limited to 'math/k_casinh.c')
-rw-r--r--math/k_casinh.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/math/k_casinh.c b/math/k_casinh.c
index 45845e2164..4cb232a17a 100644
--- a/math/k_casinh.c
+++ b/math/k_casinh.c
@@ -77,6 +77,38 @@ __kernel_casinh (__complex__ double x, int adj)
else
__imag__ res = __ieee754_atan2 (s, rx);
}
+ else if (ix > 1.0 && ix < 1.5 && rx < 0.5)
+ {
+ if (rx < DBL_EPSILON * DBL_EPSILON)
+ {
+ double ix2m1 = (ix + 1.0) * (ix - 1.0);
+ double s = __ieee754_sqrt (ix2m1);
+
+ __real__ res = __log1p (2.0 * (ix2m1 + ix * s)) / 2.0;
+ if (adj)
+ __imag__ res = __ieee754_atan2 (rx, __copysign (s, __imag__ x));
+ else
+ __imag__ res = __ieee754_atan2 (s, rx);
+ }
+ else
+ {
+ double ix2m1 = (ix + 1.0) * (ix - 1.0);
+ double rx2 = rx * rx;
+ double f = rx2 * (2.0 + rx2 + 2.0 * ix * ix);
+ double d = __ieee754_sqrt (ix2m1 * ix2m1 + f);
+ double dp = d + ix2m1;
+ double dm = f / dp;
+ double r1 = __ieee754_sqrt ((dm + rx2) / 2.0);
+ double r2 = rx * ix / r1;
+
+ __real__ res = __log1p (rx2 + dp + 2.0 * (rx * r1 + ix * r2)) / 2.0;
+ if (adj)
+ __imag__ res = __ieee754_atan2 (rx + r1, __copysign (ix + r2,
+ __imag__ x));
+ else
+ __imag__ res = __ieee754_atan2 (ix + r2, rx + r1);
+ }
+ }
else if (ix == 1.0 && rx < 0.5)
{
if (rx < DBL_EPSILON / 8.0)