summaryrefslogtreecommitdiff
path: root/math/k_casinhl.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_casinhl.c
parentb33d4ce4a2a05ca8a29798f410657e43722193ff (diff)
Fix casinh inaccuracy for argument with imaginary part 1 (bug 15287).
Diffstat (limited to 'math/k_casinhl.c')
-rw-r--r--math/k_casinhl.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/math/k_casinhl.c b/math/k_casinhl.c
index aec501b079..eb090ec3ce 100644
--- a/math/k_casinhl.c
+++ b/math/k_casinhl.c
@@ -84,6 +84,32 @@ __kernel_casinhl (__complex__ long double x, int adj)
else
__imag__ res = __ieee754_atan2l (s, rx);
}
+ else if (ix == 1.0L && rx < 0.5L)
+ {
+ if (rx < LDBL_EPSILON / 8.0L)
+ {
+ __real__ res = __log1pl (2.0L * (rx + __ieee754_sqrtl (rx))) / 2.0L;
+ if (adj)
+ __imag__ res = __ieee754_atan2l (__ieee754_sqrtl (rx),
+ __copysignl (1.0L, __imag__ x));
+ else
+ __imag__ res = __ieee754_atan2l (1.0L, __ieee754_sqrtl (rx));
+ }
+ else
+ {
+ long double d = rx * __ieee754_sqrtl (4.0L + rx * rx);
+ long double s1 = __ieee754_sqrtl ((d + rx * rx) / 2.0L);
+ long double s2 = __ieee754_sqrtl ((d - rx * rx) / 2.0L);
+
+ __real__ res = __log1pl (rx * rx + d + 2.0L * (rx * s1 + s2)) / 2.0L;
+ if (adj)
+ __imag__ res = __ieee754_atan2l (rx + s1,
+ __copysignl (1.0L + s2,
+ __imag__ x));
+ else
+ __imag__ res = __ieee754_atan2l (1.0L + s2, rx + s1);
+ }
+ }
else
{
__real__ y = (rx - ix) * (rx + ix) + 1.0L;