@ Pohon BBS
SICP : Let's Read! (22 replies)

■ 🕑 21. PHATCATTTT
   the tolerance I specified was kinda wide, which made the big number calculation off by a good amount (oops!). After reducing the tolerance to 0.000000000001 (rest of the code kept the same) i get the same result as my calculator (Casio fx-991EX). Dr racket seems to have rounded the small square roots output to 1e-7, im not sure if this is a fault in my code or just computer stuff (can anyone confirm?)
   
    also i noticed that if im just comparing the guesses,i dont need to square them and then divide. I also had redundant (abs ) functions in the code so heres an improvement
   
   (define (good-enough? guess x)
   (<
    (abs
    (-
    (/
    guess
    (improve guess x)) 1)) 0.000000000001))
   
   (sqrt 0.00000000000001) ;very small number test
   (sqrt 1000000000000000) ;very large number test
   
   outputs:
   1e-7
   31622776.601683907
    

Pohon BBS