Simpson's Rule is a more accurate method of numerical integration than the method illustrated above. Using Simpson's Rule, the integral of a function
is approximated as
h = (b − a)/n
, for some even integer
yₖ = f(a + kh)
increases the accuracy of the approximation.) Define a procedure
that takes as arguments
and returns the value of the integral, computed using Simpson's Rule. Use your procedure to integrate
between 0 and 1 (with
= 100 and
= 1000), and compare the results to those of the
procedure shown above.
There are no comments yet.
You must log in to post a comment.Login
(define (cube x) (* x x x)) (check-equal? (round (* 100 (simpson cube 0 1 100))) 25.0) (check-equal? (round (* 100 (simpson cube 0 1 1000))) 25.0) (check-equal? (floor (* 1000 (simpson cube 0 1 100))) 249.0) (check-equal? (floor (* 1000 (simpson cube 0 1 1000))) 250.0)