;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #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"))))) ;secant-line : (number -> number) number number -> (number -> number) ;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). ;(graph-fun y0 'purple) ;(graph-line (secant-line y0 0.5 3) 'green) ;d/dx : (number -> number) number -> (number -> number) ;Returns f', the slope of f, given epsilon e. (define (d/dx f e) (local ((define (slope x) (/ (- (f (+ x e)) (f (- x e))) (* 2 e))) (define (secant-line f e x) (local ((define a-slope (/ (- (f (+ x e)) (f (- x e))) (* 2 e))) (define a-point (make-posn (- x e) (f (- x e))))) (line-from-point+slope a-point a-slope)))) slope))