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_catanhl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'math/s_catanhl.c') diff --git a/math/s_catanhl.c b/math/s_catanhl.c index 6844f03dea..4897c0c871 100644 --- a/math/s_catanhl.c +++ b/math/s_catanhl.c @@ -64,7 +64,14 @@ __catanhl (__complex__ long double x) long double den = 1.0 - __real__ x; den = i2 + den * den; - __real__ res = 0.25 * (__ieee754_logl (num) - __ieee754_logl (den)); + long double f = num / den; + if (f < 0.5) + __real__ res = 0.25 * __ieee754_logl (f); + else + { + num = 4.0 * __real__ x; + __real__ res = 0.25 * __log1pl (num / den); + } den = 1 - __real__ x * __real__ x - i2; -- cgit 1.4.1