Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

24 lines (19 sloc) 0.538 kb
(define (cube x) (* x x x))
(define (inc x) (+ x 1))
(define (sum term a next b)
(if (> a b)
(+ (term a)
(sum term (next a) next b))))
(define (integral f a b dx)
(define (add-dx x) (+ x dx))
(* (sum f (+ a (/ dx 2.0)) add-dx b)
(define (integral-simpson f a b n)
(define h (/ (- b a) n))
(define (y k) (f (+ a (* h k))))
(define (mul k) (if (or (= 0 k) (= n k)) 1
(if (even? k) 2 4)))
(define (term k) (* (mul k) (y k)))
(* (/ h 3.0)
(sum term 0 inc n)))
Jump to Line
Something went wrong with that request. Please try again.