[issue34376] Improve accuracy of math.hypot() and math.dist()

Raymond Hettinger report at bugs.python.org
Fri Aug 10 18:35:27 EDT 2018


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Retested using Tim's ulp(x) function (see attached script).  The accuracy results are for 1,000 trials using 10,000 arguments to hypot() where the arguments are generated using triangular(0.999, 1.001) and arranged in the least favorable order, largest-to-smallest:

Patched:  
[(-1.0, 129),
 (0.0, 723),
 (1.0, 148)]

Baseline:
[(-33.0, 2),
 (-32.0, 1),
 (-31.0, 1),
 (-28.0, 5),
 (-27.0, 2),
 (-26.0, 4),
 (-25.0, 3),
 (-24.0, 4),
 (-23.0, 1),
 (-21.0, 9),
 (-20.0, 7),
 (-19.0, 6),
 (-18.0, 15),
 (-17.0, 12),
 (-16.0, 6),
 (-15.0, 12),
 (-14.0, 14),
 (-13.0, 15),
 (-12.0, 15),
 (-11.0, 25),
 (-10.0, 21),
 (-9.0, 24),
 (-8.0, 26),
 (-7.0, 29),
 (-6.0, 36),
 (-5.0, 33),
 (-4.0, 37),
 (-3.0, 31),
 (-2.0, 39),
 (-1.0, 43),
 (0.0, 48),
 (1.0, 45),
 (2.0, 32),
 (3.0, 37),
 (4.0, 34),
 (5.0, 25),
 (6.0, 36),
 (7.0, 29),
 (8.0, 35),
 (9.0, 27),
 (10.0, 24),
 (11.0, 17),
 (12.0, 18),
 (13.0, 18),
 (14.0, 18),
 (15.0, 11),
 (16.0, 8),
 (17.0, 6),
 (18.0, 9),
 (19.0, 15),
 (20.0, 8),
 (21.0, 5),
 (22.0, 6),
 (23.0, 4),
 (24.0, 2),
 (25.0, 1),
 (28.0, 2),
 (30.0, 1),
 (33.0, 1)]

----------
Added file: https://bugs.python.org/file47746/hypot_accuracy.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34376>
_______________________________________


More information about the Python-bugs-list mailing list