[plt-scheme] HtDP Exercise 23.4.1

From: David Yrueta (dyrueta at gmail.com)
Date: Mon Feb 9 21:47:33 EST 2009

Hi Thomas --
Thank you for the link.  I'm not familiar with the mathematical notation
used to represent the trapezoid rule function, but it resembles Scheme
enough to give me some clue on how to go forward.

Here's my best effort at translation:

For this problem, argument "a" signifies the x-axis coordinate for the "left
interval" and argument "b" signifies the x-axis coordinate for "right

The length of each interval is equal to it's y-coordinate value, which can
be derived by applying function f to it's x-coordinate. The length of each
interval also equals the two base lengths of a trapezoid.  The altitude of
the trapezoid is equal to the difference between the x-coordinate values of
a and b.  So, if the area of a trapezoid = altitude * ((base1+ base2) / 2),
then the formula for the area under the curve equals  [(b - a) * ((f a) + (f
b) / 2)].

To calculate the areas for two trapezoids, one needs only to divide the
interval between a and b by 2, apply f to that value, and then use the
result as base2 for the trapezoid with (f a) as base1, and base1 for the
trapezoid with (f b) as base2.

Does that sound about right?  If so, I'll translate it to Scheme.  Perhaps
that would make my thoughts easier to evaluate.

Thanks for the time!


On Mon, Feb 9, 2009 at 5:33 PM, Thomas Chust <chust at web.de> wrote:

> 2009/2/10 David Yrueta <dyrueta at gmail.com>:
> > [...] Still don't really understand how this relates to the question of
> computing the
> > "area of each trapezoid," though. [...]
> Hello,
> http://en.wikipedia.org/wiki/Trapezoidal_rule has some figures that
> may make the idea behind this integration method more clear: The graph
> of the function is approximated by a polyline -- in the special case
> of Kepler's rule a very coarse one with only two edges; the
> approximation of the integral is the area of the polygon bounded by
> this polyline, the two integration interval boundaries and the
> coordinate axis of the integration variable.
> cu,
> Thomas
> --
> When C++ is your hammer, every problem looks like your thumb.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090209/6fe72f0a/attachment.html>

Posted on the users mailing list.