Message375442
Per the referenced paper, here's what is involved in further reducing error:
def hypot(*coords):
# Corrected, unfused: https://arxiv.org/pdf/1904.09481.pdf
# Simplified version omits scaling and handling of wide ranges.
# Only handle the 2-dimensional cases.
# Has 1 ulp error 0.88% of the time (0.54% per the paper).
# Can be reduced to 0.00% with a reliable fused multiply-add.
a, b = map(fabs, coords)
h = sqrt(a*a + b*b)
if h <= 2*b:
delta = h - b
x = a*(2*delta - a) + (delta - 2*(a - b))*delta
else:
delta = h - a
x = 2*delta*(a - 2*b) + (4*delta - b)*b + delta*delta
return h - x/(2*h) |
|
Date |
User |
Action |
Args |
2020-08-15 00:51:24 | rhettinger | set | recipients:
+ rhettinger, tim.peters, mark.dickinson, serhiy.storchaka |
2020-08-15 00:51:24 | rhettinger | set | messageid: <1597452684.65.0.425681842586.issue41513@roundup.psfhosted.org> |
2020-08-15 00:51:24 | rhettinger | link | issue41513 messages |
2020-08-15 00:51:24 | rhettinger | create | |
|