[issue41513] High accuracy math.hypot()

2020-10-01 Thread Raymond Hettinger


Change by Raymond Hettinger :


Added file: https://bugs.python.org/file49484/best_frac.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-10-01 Thread Raymond Hettinger


Change by Raymond Hettinger :


Removed file: https://bugs.python.org/file49435/best_frac.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-22 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 438e9fc66f664eff0526a16a6d900349bfd1f9d2 by Raymond Hettinger in 
branch 'master':
bpo-41513: Improve order of adding fractional values. Improve variable names. 
(GH-22368)
https://github.com/python/cpython/commit/438e9fc66f664eff0526a16a6d900349bfd1f9d2


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-22 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21407
pull_request: https://github.com/python/cpython/pull/22368

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset bc6b7fa6d7fb8957eb4ff809366af40dfb12b8cd by Raymond Hettinger in 
branch 'master':
bpo-41513: Add accuracy tests for math.hypot() (GH-22327)
https://github.com/python/cpython/commit/bc6b7fa6d7fb8957eb4ff809366af40dfb12b8cd


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-19 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21371
pull_request: https://github.com/python/cpython/pull/22327

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-18 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21360
pull_request: https://github.com/python/cpython/pull/22315

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-14 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I saw that the Gentoo bot reacted badly to the new tests, so I reverted them.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-14 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 95a8a0e01d1f4f49ad6b4d4f2ae3bbf93c462013 by Raymond Hettinger in 
branch 'master':
bpo-41513: Remove broken tests that fail on Gentoo (GH-22249)
https://github.com/python/cpython/commit/95a8a0e01d1f4f49ad6b4d4f2ae3bbf93c462013


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-14 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21305
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/22249

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-14 Thread STINNER Victor


STINNER Victor  added the comment:

Multiple tests failed on x86 Gentoo Non-Debug with X 3.x:
https://buildbot.python.org/all/#/builders/58/builds/73

Example of failure:

==
FAIL: testHypotAccuracy (test.test_math.MathTests) (hx='0x1.10106eb4b44a2p+29', 
hy='0x1.ef0596cdc97f8p+29')
--
Traceback (most recent call last):
  File 
"/buildbot/buildarea/cpython/3.x.ware-gentoo-x86.nondebug/build/Lib/test/test_math.py",
 line 855, in testHypotAccuracy
self.assertEqual(hypot(x, y), z)
AssertionError: 1184594898.793983 != 1184594898.7939832

(I didn't investigate the bug, I just report the failure.)

--
nosy: +vstinner
resolution: fixed -> 
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-13 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 457d4e97de0369bc786e363cb53c7ef3276fdfcd by Raymond Hettinger in 
branch 'master':
bpo-41513: Add docs and tests for hypot() (GH-22238)
https://github.com/python/cpython/commit/457d4e97de0369bc786e363cb53c7ef3276fdfcd


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-13 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21293
pull_request: https://github.com/python/cpython/pull/22238

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 67c998de24985b36498b0fdac68d1beceb43aba7 by Raymond Hettinger in 
branch 'master':
bpo-41513: Expand comments and add references for a better understanding 
(GH-22123)
https://github.com/python/cpython/commit/67c998de24985b36498b0fdac68d1beceb43aba7


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21207
pull_request: https://github.com/python/cpython/pull/22123

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


Added file: https://bugs.python.org/file49448/test_hypot_commutativity.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


Removed file: https://bugs.python.org/file49398/test_hypot_commutativity.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-02 Thread Raymond Hettinger


Change by Raymond Hettinger :


Removed file: https://bugs.python.org/file49438/hypot.svg

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-02 Thread Raymond Hettinger


Change by Raymond Hettinger :


Added file: https://bugs.python.org/file49439/hypot.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-09-02 Thread Raymond Hettinger


Change by Raymond Hettinger :


Added file: https://bugs.python.org/file49438/hypot.svg

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-31 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21130
pull_request: https://github.com/python/cpython/pull/22032

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-29 Thread Tim Peters


Tim Peters  added the comment:

About test_frac.py, I changed the main loop like so:

got = [float(expected)] # NEW
for hypot in hypots:
actual = hypot(*coords)
got.append(float(actual)) # NEW
err = (actual - expected) / expected
bits = round(1 / err).bit_length()
errs[hypot][bits] += 1
if len(set(got)) > 1: # NEW
print(got) # NEW

That is, to display every case where the four float results weren't identical.

Result: nothing was displayed (although it's still running the n=1000 chunk, 
there's no sign that will change).  None of these variations made any 
difference to results users actually get.

Even the "worst" of these reliably develops dozens of "good bits" beyond IEEE 
double precision, but invisibly (under the covers, with no visible effect on 
delivered results).

So if there's something else that speeds the code, perhaps it's worth pursuing, 
but we're already long beyond the point of getting any payback for pursuing 
accuracy.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-29 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21113
pull_request: https://github.com/python/cpython/pull/22013

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-29 Thread Raymond Hettinger


Change by Raymond Hettinger :


Added file: https://bugs.python.org/file49435/best_frac.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-29 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 27de28607a248e5ffb8838162fca466a58c2e284 by Raymond Hettinger in 
branch 'master':
bpo-41513: Save unnecessary steps in the hypot() calculation (#21994)
https://github.com/python/cpython/commit/27de28607a248e5ffb8838162fca466a58c2e284


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-28 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21100
pull_request: https://github.com/python/cpython/pull/21994

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-25 Thread Tim Peters


Tim Peters  added the comment:

One more implication: since the quality of the initial square root doesn't 
really much matter, instead of

result = sqrt(to_float(parts))
a, b = split(result)
parts = add_on(-a*a, parts)
parts = add_on(-2.0*a*b, parts)
parts = add_on(-b*b, parts)
x = to_float(parts)
result += x / (2.0 * result)

at the end, it should work just as well (in fact, probably a little better, due 
to getting more beneficial cancellation) to do:

a = parts[0] - 1.0
result = sqrt(a)
x, y = split(result)
result += (a - x*x - 2.0*x*y - y*y + parts[1]) / (2.0 * result)

at the end. Although this crucially relies on the doing the last-line chain of 
subtracts and adds "left to right".

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-24 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Done!

Thank you.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-24 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 8e19c8be87017f6bef8e4c936b1e6ddacb558ad2 by Raymond Hettinger in 
branch 'master':
bpo-41513:  More accurate hypot() (GH-21916)
https://github.com/python/cpython/commit/8e19c8be87017f6bef8e4c936b1e6ddacb558ad2


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-24 Thread Tim Peters


Tim Peters  added the comment:

Do it! It's elegant and practical :-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-24 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

All the review comments have been addressed.  I think it is a good as it can 
get.  Any objections to committing the PR?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-24 Thread Raymond Hettinger


Change by Raymond Hettinger :


Added file: https://bugs.python.org/file49424/hypot_flow.pdf

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41513] High accuracy math.hypot()

2020-08-23 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I'm ready to move forward on this one.  Have improved the assertions, 
explanations, and variable names.  Hve also added references to show that the 
foundations are firm.  After tens of millions of trials, I haven't found a 
single misrounding.  I can't prove "correctly rounded" but am content with 
"high accuracy".  The speed is comparable to what we had in 3.7, so I think it 
is a net win all around.

--
title: Scale by power of two in math.hypot() -> High accuracy math.hypot()

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com