This has been really eye-opening, and I just wanted to drop you a note
that I am watching this thread carefully. My first priority is to get
the tests all passing before beta 1 on 2016-09-12, even if (as seems
likely) that means weakening the tests, and then come back and see if we
can tighten it up again later.
I haven't checked it in yet, but I've already managed to simplify the
nth_root code by taking Tim's advice that more than one iteration of
Newton's method is a waste of time. Thanks!
Can somebody comment on my reasoning here?
I start by taking an initial guess for the root by using
r = pow(x, 1.0/n). Then I test if r**n == x, if it does I conclude that
r is either the exact root, or as close as representable as a float, and
just return it without bothering with even one iteration. Sensible?
Or should I just always run one iteration of Newton and trust that it
won't make things worse? |