Skip to content

bpo-41513: More accurate hypot() #21916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 25, 2020
Merged

Conversation

rhettinger
Copy link
Contributor

@rhettinger rhettinger commented Aug 18, 2020

Draft PR for discussion.

Algorithm combines:

  • lossless scaling using a power-of-two scaling factor
  • accurate squaring using Veltkamp-Dekker splitting
  • accurate summation using a variant of the Neumaier algorithm
  • differential correction of the square root calculation

Together, these allow the algorithm to simulate 128-bit quad precision throughout.

On my build, the speed slows 50-60%. I've tested with millions of inputs and not yet found a single 1-ulp error. It seems to always be correctly rounded.

https://bugs.python.org/issue41513

@rhettinger rhettinger changed the title bpo-41513: Correctly rounded hypot() bpo-41513: More accurate hypot() Aug 24, 2020
@rhettinger rhettinger merged commit 8e19c8b into python:master Aug 25, 2020
xzy3 pushed a commit to xzy3/cpython that referenced this pull request Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants