Hi Matthias --<div><br></div><div>David, it is entirely safe to navigate around the mathematics sections in the book</div><div><br></div><div>Yes, but I can't resist the challenge of tackling and hopefully solving an explicitly "mathematical" problem which I always considered beyond my reach :) (which is why I'm up at 5:30 am taking a whack at this thing!). </div>
<div><br></div><div>I looked at the link sent to me by Thomas Chust and came up with this version of integrate-kepler (before reading your comments below, which I will):<br></div><div><br></div><div><div>(define (integrate-kepler f left right)</div>
<div> (local ((define (area-of-trap a b1 b2)</div><div> (* a ( / ( + (f b1) (f b2)) 2)))</div><div> (define midpoint ( / (+ right left) 2))</div><div> (define alt-left (- midpoint left))</div>
<div> (define alt-right (- right midpoint))) </div><div> (+ (area-of-trap alt-left left midpoint)</div><div> (area-of-trap alt-right midpoint right))))</div><div><br></div><div>Am I in the ballpark?</div>
<div><br></div><div>Thanks!</div><div><br></div><div>Dave</div></div><div><br></div><div><br></div><div><br><div><br></div><div><br><br><div class="gmail_quote">On Tue, Feb 10, 2009 at 6:40 AM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
<br>
David, it is entirely safe to navigate around the mathematics sections in the book. As someone pointed out, they exist because it's so easy to use Scheme to bring across rather complex mathematical concepts. Indeed, you won't believe it but by reaching part VI, you have mastered a significant chunk of mathematics that you would have never considered within reach had I told you at the outset of your studies that you'd understand rudimentary concepts from "higher" algebra (advanced college material).<br>
<br>
If you want to figure out some basics, try this.<br>
<br>
Can you draw the curve for (define (f x) x), (define (g x) 10), and (define (h x) (- 10 x)) between 0 and 10?<br>
<br>
Can you determine the area that is enclosed by f, g, and h, the X and Y axis between 0 and 10?<br>
<br>
If so, how did you compute those?<br>
<br>
These are special cases for the exercise that you are tackling. If your solution comes close to your answers, you know it works for special cases. That's good. For somewhat more advanced uses, you would consider more sophisticated cases, such as sin, cos, expt, etc. In all those cases, mathematics tells you how to come up with a close-enough answer through a few calculations.<br>
<br>
And that's the whole point of testing. You hope that it works for the rest of it.<br>
<br>
Give it a try. -- Matthias<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
On Feb 9, 2009, at 9:47 PM, David Yrueta wrote:<br>
<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="Wj3C7c">
Hi Thomas --<br>
<br>
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.<br>
<br>
Here's my best effort at translation:<br>
<br>
For this problem, argument "a" signifies the x-axis coordinate for the "left interval" and argument "b" signifies the x-axis coordinate for "right interval."<br>
<br>
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)].<br>
<br>
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.<br>
<br>
Does that sound about right? If so, I'll translate it to Scheme. Perhaps that would make my thoughts easier to evaluate.<br>
<br>
Thanks for the time!<br>
<br>
Thanks,<br>
Dave<br>
<br>
On Mon, Feb 9, 2009 at 5:33 PM, Thomas Chust <<a href="mailto:chust@web.de" target="_blank">chust@web.de</a>> wrote:<br>
2009/2/10 David Yrueta <<a href="mailto:dyrueta@gmail.com" target="_blank">dyrueta@gmail.com</a>>:<br>
> [...] Still don't really understand how this relates to the question of computing the<br>
> "area of each trapezoid," though. [...]<br>
<br>
Hello,<br>
<br>
<a href="http://en.wikipedia.org/wiki/Trapezoidal_rule" target="_blank">http://en.wikipedia.org/wiki/Trapezoidal_rule</a> has some figures that<br>
may make the idea behind this integration method more clear: The graph<br>
of the function is approximated by a polyline -- in the special case<br>
of Kepler's rule a very coarse one with only two edges; the<br>
approximation of the integral is the area of the polygon bounded by<br>
this polyline, the two integration interval boundaries and the<br>
coordinate axis of the integration variable.<br>
<br>
cu,<br>
Thomas<br>
<br>
<br>
--<br>
When C++ is your hammer, every problem looks like your thumb.<br>
<br></div></div><div class="Ih2E3d">
_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
</div></blockquote>
<br>
</blockquote></div><br></div></div>