From 2f38fbfe09e4856c571bf0c80844e5dac9bc77ec Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 24 Apr 2013 18:49:13 +0000 Subject: Fix catan, catanh inaccuracy through use of log (bug 15394). --- math/s_catan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'math/s_catan.c') diff --git a/math/s_catan.c b/math/s_catan.c index 46c18bf..783941a 100644 --- a/math/s_catan.c +++ b/math/s_catan.c @@ -61,7 +61,7 @@ __catan (__complex__ double x) } else { - double r2, num, den; + double r2, num, den, f; r2 = __real__ x * __real__ x; @@ -75,7 +75,14 @@ __catan (__complex__ double x) den = __imag__ x - 1.0; den = r2 + den * den; - __imag__ res = 0.25 * __ieee754_log (num / den); + f = num / den; + if (f < 0.5) + __imag__ res = 0.25 * __ieee754_log (f); + else + { + num = 4.0 * __imag__ x; + __imag__ res = 0.25 * __log1p (num / den); + } } return res; -- cgit v1.1