Chat (Lingr.com)
Informaiton
Daily
Column
- MySQL日本語の旅(5/1)
- アクセス向上秘伝(5/9)
- 一風変ったHaskellλ門(6/13)
- SICP Answer Book (5/31) 問題3.26追加
Zope Solution
Extra
アーカイブ
OSS案内所
Site Info
関連リンク
##(link2sicp "book-Z-H-12.html#%_thm_1.29" "Exercise 1.29")
解答例
Simpsonの公式
(define (simpson f a b n)
(define h (/ (- b a) n))
(define (y k) (f (+ a (* k h))))
(define (term i)
(+ (y (- (* 2 i) 2))
(* 4 (y (- (* 2 i) 1)))
(y (* 2 i))))
(define (next i) (+ i 1))
(/ (* h (sum term 1 next (/ n 2))) 3))
計算の比較
gosh> (integral cube 0 1 0.01) 0.24998750000000042 gosh> (integral cube 0 1 0.001) 0.249999875000001 gosh> (simpson cube 0 1 100) 0.25000000000000017 gosh> (simpson cube 0 1 1000) 0.25000000000000017
Simpsonの公式で計算するほうが精度がよい。
コード
##(sicp-answer-code "ex-1.29.scm")