math: Use an improved algorithm for hypotl (ldbl-128)
commitc212d6397e05d0ce65405706ea0b427a418ce5ef
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 6 Apr 2021 02:55:55 +0000 (5 23:55 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 13 Dec 2021 12:02:34 +0000 (13 09:02 -0300)
tree0ce65616f2207eca9aad2814f3b079de41d896e5
parentaa9c28cde3966064bf2b05ca8d25c62b3e463688
math: Use an improved algorithm for hypotl (ldbl-128)

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 1e9 input pairs in the range of [LDBL_MIN, LDBL_MAX], glibc
current implementation shows around 0.05% results with an error of
1 ulp (453266 results) while the new implementation only shows
0.0001% of total (1280).

Checked on aarch64-linux-gnu and x86_64-linux-gnu.

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