]> git.ipfire.org Git - thirdparty/glibc.git/commit
math: Use an improved algorithm for hypotl (ldbl-96)
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 5 Apr 2021 20:28:48 +0000 (17:28 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 13 Dec 2021 12:02:34 +0000 (09:02 -0300)
commitaa9c28cde3966064bf2b05ca8d25c62b3e463688
tree3d875fde6993a527785dc769b0fafacf4421cb1f
parentccfa865a82c648fde56864ea094f70ee1a8a944b
math: Use an improved algorithm for hypotl (ldbl-96)

This implementation is based on 'An Improved Algorithm for hypot(a,b)'
by Carlos F. Borges [1] using the MyHypot3 with the following changes:

 - Handle qNaN and sNaN.
 - Tune the 'widely varying operands' to avoid spurious underflow
   due the multiplication and fix the return value for upwards
   rounding mode.
 - Handle required underflow exception for subnormal results.

The main advantage of the new algorithm is its precision.  With a
random 1e8 input pairs in the range of [LDBL_MIN, LDBL_MAX], glibc
current implementation shows around 0.02% results with an error of
1 ulp (23158 results) while the new implementation only shows
0.0001% of total (111).

[1] https://arxiv.org/pdf/1904.09481.pdf
sysdeps/ieee754/ldbl-96/e_hypotl.c