Brief summary of Thursday's activity: * Start with the program "integration.txt" * Automates what we did in class on Tuesday and Wednesday: plot some points of a function, and then draw the rectangles below that function (on Tuesday and Wednesday, we also drew rectangles above the function, but here we just draw the rectangles below). Also, the "Output window" (the window in gray that is below the window with the program itself) prints the value of "s", which gives the area of those rectangles, by counting the number of gray pixels drawn. Make sure the "Output window" is big enough to see this value of s. [Hint: When you initially run the program, you should see the output "1000.0" about 8 lines from the bottom. If you don't see it, make that window bigger.] * Although the program includes several functions (f1 through f8), we do this all just for the very simple function f8(x) = x; i.e., we are graphing the function y=f(x)=x, a straight diagonal line with slope 1. * The program is initially set with deltaX = 10. * Changes: * First we changed deltaX to smaller values (5, and then 3 or 2, and then 1). This had several effects: there were more green dots (all on the line y=x); there were more gray rectangles, but each one was narrower (by the time deltaX gets to 2 or 1, the gray area is indistinguishable from a triangle); the estimate of the area changes (gets bigger as the gray rectangles give a better and better estimate of the real area). * By the time deltaX = 1, the graph was taking longer to display, and showing the same thing each time (try it!), so we decided we could skip drawing the graph, and just compute s. So we made the following substitutions: s <- s + d*deltaX //s <- s + rect(x,0.0,deltaX,d) for s <- s + rect(x,0.0,deltaX,d) (so this *doesn't* draw the rectangle, but increases s by the same amount, the area of the rectangle, which is d units tall, and deltaX units wide). We also commented out the command to draw the green graph of the function itself (dot (x, d) green). * We then gathered the data for s while we let deltaX go to 0.1, 0.01, 0.001, 0.0001. We saw that the area got closer and closer to 1250 (with some numerical roundoff error). We were able to verify (using the formula for the area of a triangle) that 1250 is inded the exact area of the triangle. Written homework due Tuesday (April 16): Repeat this activity for the new function f9, which you should add to the program by putting in the appropriate place of the program the lines let f9(x) = 5.+60./(2.**(((x-60.)/25.)**2.)) let f = f9 The only exception is that you won't be able to compute the area of this region exactly (as we did at the end with the triangle). Instead, just pick smaller and smaller deltaX's to give an estimate of the area. Be sure to indicate how precise you think your answer is. Also please draw the graph (including the rectangles) for values of deltaX that are 1 or higher (as we did in our activity).