Exercise 1.1
10
10
(+ 5 3 4)
12
(- 9 1)
8
(/ 6 2)
3
(+ ( 2 4) (- 4 6))
6
(define a 3)
(define b (+ a 1))
(+ a b ( a b))
19
(= a b)
false
(if (and (> b a) ( (cond ((= a 4) 6)
((= b 4) (+ 6 7 a))
(else 25))
16
(+ 2 (if (> b a) b a))
6
(* (cond ((> a b) a)
((< a b) b)
(else -1))
(+ a 1))
16
Exercise 1.4
This procedure adds the absolute value of b to the value of a. If b is positive, it adds a and b. If b is negative it subtracts b from a.
Exercise 1.5
Normal order evaluation will cause the program to return 0, because test will be evaluated before p is expanded. Applicative order evaluation will cause the interpreter to attempt to expand all the functions before evaluating them. Since p calls itself in an infinite loop, this program will never halt if evaluated by an applicative order interpreter.
Exercise 1.6
If the interpreter is using applicative order evaluation the program will never halt. This is because in the original program, if would have forced the interpreter to evaluate good-enough? which would eventually return true and halt the program, but with new-if, sqrt-iter is endlessly expanded and good-enough? is never evaluated.
Exercise 1.7
good-enough? tests the guess to within 0.001 of x, so if x is significantly less than 0.001 good-enough? will return true even if the guess is not close to the true root of x. If the number is large it will be dominated by rounding error, and good-enough? will cause the program to continue to attempt improve guess to within 0.001 of x even if guess is not approaching x because of error.
(code)
The updated program only returns guess when guess is relatively stable from one iteration of the program to the next, it will therefore be at least as accurate for small and large numbers as it is for medium sized ones.