Created
June 7, 2013 14:33
-
-
Save aoeuidht/5729676 to your computer and use it in GitHub Desktop.
1.30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun cube (x) (* x x x)) | |
| (defun sum-iter (term a next b) | |
| (defun iter (a result) | |
| (if (> a b) | |
| result | |
| (iter (funcall next a) (+ result (funcall term a))))) | |
| (iter a 0)) | |
| (defun simp-integral (f a b n) | |
| (let ((h (/ (- b a) n))) | |
| (defun add-dx (x) (+ x (* 2 h))) | |
| (defun simp-term (a) | |
| (+ (funcall f a) | |
| (* 4 (funcall f (+ a h))) | |
| (funcall f (+ a (* 2 h))))) | |
| (* (/ h 3.0) | |
| (sum-iter #'simp-term a #'add-dx (- b (* 2 h)))) | |
| )) | |
| (simp-integral #'cube 0 1 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment