(define heron-sqrt - PowerPoint PPT Presentation

About This Presentation
Title:

(define heron-sqrt

Description:

(define heron-sqrt (lambda (x) ;try some guess for sqrt(x)--we always pick 1 (try 1 x) ... otherwise, try an improved guess (try (improve guess x) x) ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 2
Provided by: dexter8
Category:
Tags: define | heron | sqrt

less

Transcript and Presenter's Notes

Title: (define heron-sqrt


1
(define heron-sqrt  (lambda (x)    try some
guess for sqrt(x)--we always pick 1    (try 1
x)))(define try  (lambda (guess x)   if the
guess is good enough   (if (good-enough? guess
x)        then stop and return the old
guess       guess       otherwise, try an
improved guess       (try (improve guess x)
x))))(define good-enough?  (lambda (guess
x)    (lt (abs (- (square guess) x))
0.0001)))(define improve  (lambda (guess
x)    (/ ( guess (/ x guess)) 2.0)))(define
square  (lambda (x) ( x x)))
Write a Comment
User Comments (0)
About PowerShow.com