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 

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 

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


Python tracker <rep...@bugs.python.org>
Python-bugs-list mailing list

Reply via email to