aboutsummaryrefslogtreecommitdiff
path: root/math/k_casinh.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-03-21 10:27:10 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-03-21 10:27:10 +0000
commit0a1b2ae6f6d511519ab3c0ccbf54982ae65bc444 (patch)
treeffa27d00584d224e4b47a9654e192fb3fb0ed0ba /math/k_casinh.c
parentb33d4ce4a2a05ca8a29798f410657e43722193ff (diff)
downloadglibc-0a1b2ae6f6d511519ab3c0ccbf54982ae65bc444.zip
glibc-0a1b2ae6f6d511519ab3c0ccbf54982ae65bc444.tar.gz
glibc-0a1b2ae6f6d511519ab3c0ccbf54982ae65bc444.tar.bz2
Fix casinh inaccuracy for argument with imaginary part 1 (bug 15287).
Diffstat (limited to 'math/k_casinh.c')
-rw-r--r--math/k_casinh.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/math/k_casinh.c b/math/k_casinh.c
index 41cd5ec..45845e2 100644
--- a/math/k_casinh.c
+++ b/math/k_casinh.c
@@ -77,6 +77,31 @@ __kernel_casinh (__complex__ double x, int adj)
else
__imag__ res = __ieee754_atan2 (s, rx);
}
+ else if (ix == 1.0 && rx < 0.5)
+ {
+ if (rx < DBL_EPSILON / 8.0)
+ {
+ __real__ res = __log1p (2.0 * (rx + __ieee754_sqrt (rx))) / 2.0;
+ if (adj)
+ __imag__ res = __ieee754_atan2 (__ieee754_sqrt (rx),
+ __copysign (1.0, __imag__ x));
+ else
+ __imag__ res = __ieee754_atan2 (1.0, __ieee754_sqrt (rx));
+ }
+ else
+ {
+ double d = rx * __ieee754_sqrt (4.0 + rx * rx);
+ double s1 = __ieee754_sqrt ((d + rx * rx) / 2.0);
+ double s2 = __ieee754_sqrt ((d - rx * rx) / 2.0);
+
+ __real__ res = __log1p (rx * rx + d + 2.0 * (rx * s1 + s2)) / 2.0;
+ if (adj)
+ __imag__ res = __ieee754_atan2 (rx + s1, __copysign (1.0 + s2,
+ __imag__ x));
+ else
+ __imag__ res = __ieee754_atan2 (1.0 + s2, rx + s1);
+ }
+ }
else
{
__real__ y = (rx - ix) * (rx + ix) + 1.0;