Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move another function to the library of helpers

  • Loading branch information...
commit a8a82b977a36b47d2ef4392bd2579d4087fd16a7 1 parent d287ea1
@apauley authored
Showing with 5 additions and 5 deletions.
  1. +4 −0 Chapter1/helpers.scm
  2. +1 −5 Chapter1/secant.scm
View
4 Chapter1/helpers.scm
@@ -9,3 +9,7 @@ the value where the line intersects with the x-axis"
(* (f x1)
(/ (- x0 x1)
(- (f x0) (f x1))))))
+
+(define tolerance 0.00001)
+(define (close-enough-to-zero? x)
+ (<= (abs x) tolerance))
View
6 Chapter1/secant.scm
@@ -10,12 +10,8 @@
(define (secant f x0 x1)
(define x2 (linear-interpolate f x0 x1))
- (define (close-enough? x)
- (define tolerance 0.00001)
- (<= (abs x) tolerance))
-
(println x0 " " x1 " " x2 " " (f x2))
- (if (close-enough? (f x2))
+ (if (close-enough-to-zero? (f x2))
x2
(secant f x1 x2)))
Please sign in to comment.
Something went wrong with that request. Please try again.