[plt-scheme] HtDP 27.3.2 and 27.3.4

Jens Axel Søgaard jensaxel at soegaard.net
Sat Jul 4 07:26:27 EDT 2009


2009/7/4 David Yrueta <dyrueta at gmail.com>

> Hi All --
>
> Questions for both exercises refer to the function "find-root" below:
>
> ;; find-root : (number  ->  number) number number  ->  number
> ;; to determine a number R such that f has a
> ;; root between R and (+ R TOLERANCE)
> ;;
> ;; ASSUMPTION: f is continuous and monotonic
> (define (find-root f left right)
>  (cond
>    [(<= (- right left) TOLERANCE) left]
>    [else
>      (local ((define mid (/ (+ left right) 2)))


You might consider using floating points.
Just change 2 to 2.0.

-- 
Jens Axel Søgaard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20090704/24094b4b/attachment.htm


More information about the plt-scheme mailing list