You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sicp-all-tasks/sicp/5_002e3

21 lines
689 B

Exercise 5.3: Design a machine to compute square
roots using Newton’s method, as described in 1.1.7:
(define (sqrt x)
(define (good-enough? guess)
(< (abs (- (square guess) x)) 0.001))
(define (improve guess)
(average guess (/ x guess)))
(define (sqrt-iter guess)
(if (good-enough? guess)
guess
(sqrt-iter (improve guess))))
(sqrt-iter 1.0))
Begin by assuming that good-enough? and improve operations are
available as primitives. Then show how to expand these in terms of arithmetic
operations. Describe each version of the sqrt machine design by drawing
a data-path diagram and writing a controller definition in the register-machine
language.