[issue27761] Private _nth_root function loses accuracy

Tim Peters report at bugs.python.org
Fri Sep 16 15:12:25 EDT 2016


Tim Peters added the comment:

Mark, the code I showed in roots.py is somewhat more accurate and highly significantly faster than the code you just posted.  It's not complicated at all:  it just uses Decimal to do a single Newton correction with extended precision.

Since it doesn't use the Decimal exp() or ln(), it's faster.  It does use the Decimal pow(), but with an integer exponent, so this specific use of pow() doesn't invoke the Decimal exp() or ln() either.  And it's still the case that I haven't found a case where its result isn't correctly rounded.  My testing framework found multiple not-correctly-rounded cases in your new code within seconds.

Presumably you could boost the precision to improve that, but then it would get even slower.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27761>
_______________________________________


More information about the Python-bugs-list mailing list