diff options
author | Joseph Myers <joseph@codesourcery.com> | 2015-09-28 22:11:22 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2015-09-28 22:11:22 +0000 |
commit | a5721ebc68cc8b761b0ffdf6dcae52723369e071 (patch) | |
tree | e49b70539a6b7390f60cac5dc2330dae7dd39a1d /math/auto-libm-test-in | |
parent | 60cf80f09d029257caedc0c8abe7e3e09c64e6c7 (diff) | |
download | glibc-a5721ebc68cc8b761b0ffdf6dcae52723369e071.zip glibc-a5721ebc68cc8b761b0ffdf6dcae52723369e071.tar.gz glibc-a5721ebc68cc8b761b0ffdf6dcae52723369e071.tar.bz2 |
Fix clog, clog10 inaccuracy (bug 19016).
For arguments with X^2 + Y^2 close to 1, clog and clog10 avoid large
errors from log(hypot) by computing X^2 + Y^2 - 1 in a way that avoids
cancellation error and then using log1p.
However, the thresholds for using that approach still result in log
being used on argument as large as sqrt(13/16) > 0.9, leading to
significant errors, in some cases above the 9ulp maximum allowed in
glibc libm. This patch arranges for the approach using log1p to be
used in any cases where |X|, |Y| < 1 and X^2 + Y^2 >= 0.5 (with the
existing allowance for cases where one of X and Y is very small),
adjusting the __x2y2m1 functions to work with the wider range of
inputs. This way, log only gets used on arguments below sqrt(1/2) (or
substantially above 1), where the error involved is much less.
Tested for x86_64, x86, mips64 and powerpc. For the ulps regeneration
I removed the existing clog and clog10 ulps before regenerating to
allow any reduced ulps to appear. Tests added include those found by
random test generation to produce large ulps either before or after
the patch, and some found by trying inputs close to the (0.75, 0.5)
threshold where the potential errors from using log are largest.
[BZ #19016]
* sysdeps/generic/math_private.h (__x2y2m1f): Update comment to
allow more cases with X^2 + Y^2 >= 0.5.
* sysdeps/ieee754/dbl-64/x2y2m1.c (__x2y2m1): Likewise. Add -1 as
normal element in sum instead of special-casing based on values of
arguments.
* sysdeps/ieee754/dbl-64/x2y2m1f.c (__x2y2m1f): Update comment.
* sysdeps/ieee754/ldbl-128/x2y2m1l.c (__x2y2m1l): Likewise. Add
-1 as normal element in sum instead of special-casing based on
values of arguments.
* sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c (__x2y2m1l): Likewise.
* sysdeps/ieee754/ldbl-96/x2y2m1.c [FLT_EVAL_METHOD != 0]
(__x2y2m1): Update comment.
* sysdeps/ieee754/ldbl-96/x2y2m1l.c (__x2y2m1l): Likewise. Add -1
as normal element in sum instead of special-casing based on values
of arguments.
* math/s_clog.c (__clog): Handle more cases using log1p without
hypot.
* math/s_clog10.c (__clog10): Likewise.
* math/s_clog10f.c (__clog10f): Likewise.
* math/s_clog10l.c (__clog10l): Likewise.
* math/s_clogf.c (__clogf): Likewise.
* math/s_clogl.c (__clogl): Likewise.
* math/auto-libm-test-in: Add more tests of clog and clog10.
* math/auto-libm-test-out: Regenerated.
* sysdeps/i386/fpu/libm-test-ulps: Update.
* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Diffstat (limited to 'math/auto-libm-test-in')
-rw-r--r-- | math/auto-libm-test-in | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in index e86be23..5648965 100644 --- a/math/auto-libm-test-in +++ b/math/auto-libm-test-in @@ -660,6 +660,51 @@ clog -0xa.7ac41a0b417cb8fp-4 -0x6.c5a32eaeedd4p-4 clog 0x3.c16p-136 0x8p-152 clog -0x1.0a69de710590dp+0 -0x7.bc7e121e2b0d1088p-4 +clog -0x2.7bdep-4 0x5.ab7a4p-4 +clog -0xb.e1d3d0ff44358p-4 -0x7.54785e1b143f8p-4 +clog 0x3.ba473p+0 0x7.eea9ap-4 +clog 0x9.d02220baee4ep+36 0x2.b9a29cp+0 +clog -0x5.1a5cf8p-4 -0xb.73012p-4 +clog -0xa.ff292a609dbb8p-4 0x6.f73d4cp-4 +clog -0x5.1a5cfc2301114p-4 -0xb.730118p-4 +clog 0xb.ffffcp-4 0x7.ffff1p-4 +clog 0xb.ffffp-4 0x7.ffffap-4 +clog 0xb.ffffp-4 0x7.fffff8p-4 +clog 0xb.ffffp-4 0x7.ffffp-4 +clog 0xb.fffffp-4 0x7.ffff68p-4 +clog 0xb.fffffp-4 0x7.ffffp-4 +clog 0xb.ffff8p-4 0x7.ffffcp-4 +clog 0xb.ffffp-4 0x7.ffffcp-4 +clog 0xb.ffffp-4 0x7.ffffb8p-4 +clog 0xb.ffffp-4 0x7.ffff7p-4 +clog 0xb.ffffp-4 0x7.ffff5p-4 +clog 0xb.fffffffffff7p-4 0x7.fffff8p-4 +clog 0xb.fffffffffff08p-4 0x7.fffffffffffdp-4 +clog 0xb.fffffffffff08p-4 0x7.fffffffffff9p-4 +clog 0xb.fffffffffffp-4 0x7.fffffffffffdcp-4 +clog 0xb.fffffp-4 0x7.ffffffffffff4p-4 +clog 0xb.fffffffffffp-4 0x7.fffffffffffecp-4 +clog 0xb.fffffffffff8p-4 0x7.fffff8p-4 +clog 0x8p-152 -0x1.10233ap+0 +clog 0xa.03634p-4 -0x4.7bb918p-20 +clog -0x5.e23d2p-4 0x8.525df889c21ap-4 +clog 0x9.8ce58p-4 -0x8p-152 +clog 0x8p-152 0x9.2af75p-4 +clog 0x9.97a15de8e59d8p-4 -0 +clog -0x4.74556ec92eb4746p-4 0x1.1e7aa1d936f6efe6p+0 +clog 0x9.97a15de8e59d8p-4 -0 +clog -0x9.7f1d7p-64 0x9.db37dp-4 +clog -0x8.5efc4p-4 -0x5.40310cp-4 +clog -0x9.0b459p-4 0 +clog -0x6.a9419e9b30e68p-4 -0x6.262c7p-4 +clog 0x5.2767cdfdfbf2p-4 0x7.69ee98p-4 +clog -0x9.f5563cb3227d8p-4 0 +clog -0x9.5a284p-4 0x6.899578p-8 +clog 0xa.3e62bp-4 0x1.18c03p-100 +clog 0 -0x9.22a99p-4 +clog 0 0x9.7915bp-4 +clog 0x3.00d1ap-12 0x1.23ff6ap+0 + clog 0x1.fffffep+127 0x1.fffffep+127 clog 0x1.fffffep+127 1.0 clog 0x1p-149 0x1p-149 @@ -808,6 +853,51 @@ clog10 -0xa.7ac41a0b417cb8fp-4 -0x6.c5a32eaeedd4p-4 clog10 0x3.c16p-136 0x8p-152 clog10 -0x1.0a69de710590dp+0 -0x7.bc7e121e2b0d1088p-4 +clog10 -0x2.7bdep-4 0x5.ab7a4p-4 +clog10 -0xb.e1d3d0ff44358p-4 -0x7.54785e1b143f8p-4 +clog10 0x3.ba473p+0 0x7.eea9ap-4 +clog10 0x9.d02220baee4ep+36 0x2.b9a29cp+0 +clog10 -0x5.1a5cf8p-4 -0xb.73012p-4 +clog10 -0xa.ff292a609dbb8p-4 0x6.f73d4cp-4 +clog10 -0x5.1a5cfc2301114p-4 -0xb.730118p-4 +clog10 0xb.ffffcp-4 0x7.ffff1p-4 +clog10 0xb.ffffp-4 0x7.ffffap-4 +clog10 0xb.ffffp-4 0x7.fffff8p-4 +clog10 0xb.ffffp-4 0x7.ffffp-4 +clog10 0xb.fffffp-4 0x7.ffff68p-4 +clog10 0xb.fffffp-4 0x7.ffffp-4 +clog10 0xb.ffff8p-4 0x7.ffffcp-4 +clog10 0xb.ffffp-4 0x7.ffffcp-4 +clog10 0xb.ffffp-4 0x7.ffffb8p-4 +clog10 0xb.ffffp-4 0x7.ffff7p-4 +clog10 0xb.ffffp-4 0x7.ffff5p-4 +clog10 0xb.fffffffffff7p-4 0x7.fffff8p-4 +clog10 0xb.fffffffffff08p-4 0x7.fffffffffffdp-4 +clog10 0xb.fffffffffff08p-4 0x7.fffffffffff9p-4 +clog10 0xb.fffffffffffp-4 0x7.fffffffffffdcp-4 +clog10 0xb.fffffp-4 0x7.ffffffffffff4p-4 +clog10 0xb.fffffffffffp-4 0x7.fffffffffffecp-4 +clog10 0xb.fffffffffff8p-4 0x7.fffff8p-4 +clog10 0x8p-152 -0x1.10233ap+0 +clog10 0xa.03634p-4 -0x4.7bb918p-20 +clog10 -0x5.e23d2p-4 0x8.525df889c21ap-4 +clog10 0x9.8ce58p-4 -0x8p-152 +clog10 0x8p-152 0x9.2af75p-4 +clog10 0x9.97a15de8e59d8p-4 -0 +clog10 -0x4.74556ec92eb4746p-4 0x1.1e7aa1d936f6efe6p+0 +clog10 0x9.97a15de8e59d8p-4 -0 +clog10 -0x9.7f1d7p-64 0x9.db37dp-4 +clog10 -0x8.5efc4p-4 -0x5.40310cp-4 +clog10 -0x9.0b459p-4 0 +clog10 -0x6.a9419e9b30e68p-4 -0x6.262c7p-4 +clog10 0x5.2767cdfdfbf2p-4 0x7.69ee98p-4 +clog10 -0x9.f5563cb3227d8p-4 0 +clog10 -0x9.5a284p-4 0x6.899578p-8 +clog10 0xa.3e62bp-4 0x1.18c03p-100 +clog10 0 -0x9.22a99p-4 +clog10 0 0x9.7915bp-4 +clog10 0x3.00d1ap-12 0x1.23ff6ap+0 + clog10 0x1.fffffep+127 0x1.fffffep+127 clog10 0x1.fffffep+127 1.0 clog10 0x1p-149 0x1p-149 |