[plt-scheme] HtDP Exercise 23.4.1

From: dave yrueta (dyrueta at gmail.com)
Date: Mon Feb 9 18:03:36 EST 2009

Hi All --

Am sending out a message in a virtual bottle for help with HtDP
exercise 23.4.1, reproduced below:

A general integration function must consume three inputs: a, b, and
the function f. The fourth part, the x axis, is implied. This suggests
the following contract:

;; integrate : (number  ->  number) number number  ->  number
;; to compute the area under the graph of f between a and b
(define (integrate f a b) ...)
Kepler suggested one simple integration method. It consists of three
steps:

divide the interval into two parts: [a,(a + b/2)] and [(a + b/2),b];

compute the area of each trapezoid; and

add the two areas to get an estimate at the integral.

Exercise 23.4.1.   Develop the function integrate-kepler. It computes
the area under some the graph of some function f between left and
right using Kepler's rule.

Specifically, I'm stuck at the "create examples" part of the design
recipe, because I don't understand the "integration method" outlined
by the exercise.

First, what does it mean to "divide the interval into two parts?"
Suppose I substitute values for variables a and b (a=3 and b=6).  I
end up with a pair of values: [3, 6] and [6, 6].  Are these x,y
coordinates for points on a graph?  If so, how do they relate to the
second step of the integration method, which is to determine the area
for "each trapezoid?"

I know the area for a trapezoid = a (b1 + b2 /2) where a is the
altitude, and b1 and b2 are the length of the two bases.  My problem
is deriving values for a, b1 and b2 from the integrate-kepler function
arguments.

Finally, I have no idea how argument f, the line function, fits into
all this.  I don't even know what a function for a line looks like (y
= x + 10?)

HtDP supplies an illustration to help visualize the problem (http://
www.htdp.org/2003-09-26/Book/curriculum-Z-H-29.html#node_sec_23.4).  I
haven't the faintest idea how to interpret it:

I'm sure someone even casually acquainted with basic calculus could
solve this problem easily.  Unfortunately, I'm relatively math-
illiterate, so figuring out how all the parts fit together has eluded
me.  I did manage to solve the other mathematical examples which
appeared earlier in the chapter because the mechanics of determining
the solution appeared clear to me.  Not so here. I'm hoping that if
someone can help me formulate some examples, I'd be on my way.

Thanks!

Dave Yrueta


Posted on the users mailing list.