From the same web page source, this one converges faster than Halley's looks like.
... except if1() seems to spiral out of control for P > 100 or so. Hmmmmm... Halley's more stable. Maybe I'm doing something wrong. I think it's SmallTalk that does integer fractions, i.e. allows calcs with numerators and denominators staying separate. Does Scheme do this too? I forget just now (I practiced with it for awhile, but am still focussed on a math curriculum with Python the main computer language). Anyway, I wrote a Fraction class that sort of does this (computes with fractions) -- maybe I'm reinventing a wheel or two here. Fraction in action:
from roots import Fraction a = Fraction(1,6) # i.e. 1/6 b = Fraction(2,3) # i.e. 2/3 c = a+b # add fractions c.str() '5L/6L' c = a-b # subtract fractions c.str() '-3L/6L' c.simplify() c.str() '-1L/2L' c=(a*b).str() # multiply factions (divide OK too) c.str() '2L/18L' c.simplify() c.str() '1L/9L'
I used my primes.py module for its gcd and lcm functions (greatest common divisor, lowest common multiple). One could make 'simplify' more "built-in" upon initialization (making a separate call unnecessary), but I'm still working through Domingo Gómez Morín's web page and didn't want to simplify automatically. Using my Fraction class and one of Domingo's algorithms, I was able to get some impressive long integer fractions for 3rd root of 2, 3rd root of 10: 3rd root of 2 is approx = 65379522 --------- 51891761 3rd root of 10 is approx = 91969780593702397138462508494860 --------------------------------- 42688590663356403236303435376201 Kirby