Skip to content

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