Blob


1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname |27.4|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp")))))
4 ;secant-line : (number -> number) number number -> (number -> number)
5 ;Given f, e, and x, returns the function that corresponds to the line that passes through (x-e, f(x-e)) and (x+e, f(x+e)) (ie, the secant line).
8 ;(graph-fun y0 'purple)
9 ;(graph-line (secant-line y0 0.5 3) 'green)
11 ;d/dx : (number -> number) number -> (number -> number)
12 ;Returns f', the slope of f, given epsilon e.
14 (define (d/dx f e)
15 (local ((define (slope x) (/ (- (f (+ x e))
16 (f (- x e)))
17 (* 2 e)))
18 (define (secant-line f e x)
19 (local ((define a-slope (/ (- (f (+ x e))
20 (f (- x e)))
21 (* 2 e)))
22 (define a-point (make-posn (- x e)
23 (f (- x e)))))
24 (line-from-point+slope a-point a-slope))))
25 slope))