This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients mark.dickinson, martin.panter, rhettinger, steven.daprano, tim.peters
Date 2016-08-15.03:44:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
A meta-note:  one iteration of Newton's method generally, roughly speaking, doubles the number of "good bits" in the initial approximation.

For floating n'th root, it would an astonishingly bad libm pow() that didn't get more than half the leading bits in pow(x, 1/n) right.

So a single Newton iteration, if carried out in infinite precision, should be enough to get all the bits "right" (meaning not significantly worse than 0.5 ulp error when converted back to a float).

So if you find yourself doing more than one Newton iteration, you're just fighting floating-point noise.  It's an illusion - nothing is actually getting better, except perhaps by accident.

Which suggests one approach for doubles (in C - same as a Python float):  get the pow() approximation.  Feed it to a `fractions.Fraction()` constructor.  Do one Newton iteration using the Fraction type.  Then use `float()` to convert the result to a float.

I believe that's the best you can possibly do without doing real work ;-)
Date User Action Args
2016-08-15 03:44:41tim.peterssetrecipients: + tim.peters, rhettinger, mark.dickinson, steven.daprano, martin.panter
2016-08-15 03:44:41tim.peterssetmessageid: <>
2016-08-15 03:44:41tim.peterslinkissue27761 messages
2016-08-15 03:44:40tim.peterscreate