I've been working through SICP using mit-scheme to test the exercises. For Exercise 1.8 you are tasked to write a cube-root function analogous to the given square-root function. My solution for that is below; however, I noticed that in the cube-root function, where the first call to cube-iter is made. If the first argument is 1, the function returns some very large integer, where if it is 1.0 it will return the expected result using mit-scheme. Using the scm interpreter there is no difference between the output when using 1 and 1.0. I was under the impression that there should be no difference between the two.
Code:
(define (cube-root x)
(cube-iter 1 x))
(define (cube-iter guess x)
(if (good-enough? guess x)
guess
(cube-iter (improve guess x) x)))
(define (good-enough? guess x)
(< (abs ( - x (cube guess))) .001))
(define (improve guess x)
(/ (+ (/ x (* guess guess)) (* 2 guess))
3)))
(define (cube x) (* x x x))
Output for (cube-iter 1 x)) version in mit-scheme: 1592506......
Output for (cube-iter 1.0 x)) version in mit-scheme: 3.0000005410641766
Output for (cube-iter 1 x)) version in SCM: 3.0000005410641766
Output for (cube-iter 1.0 x)) version in SCM: 3.0000005410641766
The version for mit-scheme is 9.2