(define (inc n) (+ n 1)) (define (cube x) (* x x x)) (define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) next b)))) (define (simpson f a b n) (define k 0) (define h (/ (- b a) n)) (define (coeff k) (cond ((= k 0) 1) ((= k n) 1) ((= k 1) 4) ((= (% k 2) 0) 2) (else 4))) (* (/ h 3) (sum (* (coeff k) (f (+ a (* k h)))) k inc b)))