Open huangzworks opened 11 years ago
(define (simpson a b f n)
(define h (/ (- b a) n))
(define (simpson-step k)
(define (f-wapper x)
(cond ((= k 0) (f x))
((= k n) (f x))
((even? k) (* 2 (f x)))
(else (* 4 (f x)))))
(f-wapper (+ a (* k h))))
(define (next-k x) (+ x 1))
(* (/ h 3) (sum-tem simpson-step 0 next-k n))
)
从0开始是正确的,因为我们其实是计算simpson函数从0到n的积分^_^
http://sicp.readthedocs.org/en/latest/chp1/29.html#comment-775467789