Simulator with MadMath Kit: Riema Sums (Teacher s pages) I your kit: 1. GeoGebra file: Ready-to-use projector sized simulator: RiemaSumMM.ggb 2. RiemaSumMM.pdf (this file) ad RiemaSumMMEd.pdf (educator's pages) Goals: Give a fuctio y=f(x) that is positive o the iterval [a,b]. Create a GeoGebra worksheet that (a) shows ad calculates the exact area uder y o [a,b], (b) shows ad calculates the left ad right Riema sums for a variable umber of subitervals ad (c) shows ad calculates the midpoit Riema sum for subitervals. First, let s write dow the formulas for Riema Sums: 1 xi xi 1 Left Sum: h f( xi ) Right Sum: h f( xi ) Midpoit Sum: h f i 1 i 2 i 1 2 Notice that we are usig the otatio that: a x1 ad b x 1 because this works with programmig. (Startig couter umber is 1; edig couter umber is +1.) Sceario: A studet of begiig calculus looks at these formulas. She says to herself - More i s tha a fly. I uderstad the idea of Riema sums so I am ever goig to eed these formulas. Ad this is true she does t eed the formulas if her teacher gives her a small eough umber of subitervals so she ca calculate by had. But her teacher is the evil warlock MadMath who gives her such a large umber for that she decides to use her brai ad write a GeoGebra worksheet to do the calculatios for her. She kows MadMath ca chage the fuctio, chage the iterval ad chage the umber of subitervals so she must be prepared. Let s get started. What must you have to get started solvig a problem with Riema sums? A fuctio y=f(x), a iterval [a,b] ad a umber for or for h. Q1. Why do t we eed values for both ad h? Write a formula that relates ad h. b a b a A1: h=b-a or h or h The umber of subitervals times the legth h of subitervals gives legth of iterval (b-a). Ow the Math with MadMath 1
== Let s say we start with 3 2 y x x x 5 2 15 o [0,5] with =5. == Ope a ew GeoGebra worksheet. Defie a=0 ad defie b=5. By defie we mea type the equatio ito the iput bar at bottom left ad hit eter. Use to make a slider from 0 to 40, icremet 1 ad set the value at =5. o Click o the Slider tool ad the click i the Drawig pad. o Chage ame=, mi=0, max=40 ad icremet=1 ad the click o Apply. o Click o Move tool ad the click ad drag the slider butto to 5. Defie h i terms of a, b ad usig your formula from Q1. Type: h=(b-a)/ Defie f x x x x 3 2 ( ) 5 2 15 o Type: f(x)=x^3-5*x^2+2*x+15 Scale, zoom ad move the Drawig pad for this fuctio i the give iterval. o Chage the scale of the Drawig pad to 1:5 (Right-click i empty space, select xaxis:yaxis ad click o 1:5). o Use mouse scroll butto to zoom ad We wat somethig like Figure 1. Move Drawig pad tool to move. Figure 1: Left Riema Sum for =5 Figure 2: Itegral (Exact Area) Ow the Math with MadMath 2
b Let s fid the exact itegral: f ( x )d x. a We use the GeoGebra commad Itegral[] with sytax: Itegral[Fuctio, Number a, Number b] to get the value of the defiite itegral. Defie c=itegral[f(x),a,b] We get the umber c which is the value of the defiite itegral. c=47.92 You should see somethig like Figure 2 (above). Q2. Why is this itegral equal to the area uder the curve for the give fuctio ad iterval? A2: Because f(x) is positive i the iterval [0,5]. Let s look at the Left Riema Sum = h i 1 f( x) We (should) have the Figure 3 i our head for left sums. That is, we kow that we must sum the areas of the rectagles that look like this. i Q3. What is the y-coordiate of the top left vertex of this rectagle? A3: y-coordiate is f(x i ). Figure 3: Basic Elemet of Left Riema Sum Thikig: What do we eed to get draw the rectagle show i the above image? Aswer: We eed to determie the coordiates of the vertices of the rectagle. Q4. Use x i ad x i+1 ad write dow the coordiates of the gree poits i Figure 4. Hit: Thik carefully about the y-coordiate of the top right vertex! A4: O both the top poits the y-coordiate is f(x i ). Figure 4: Vertices of Left Rectagle Mai Idea: To repeatedly use the commad Sequece[] to geerate lists - the last of which gives us draws ad calculates the area of the summig rectagles. So what do we eed to do? We make a list of the x i ad a list of the f(x i ) ad a list of poits (x i,f(x i )) The, we use these lists to make a list of rectagles. Ow the Math with MadMath 3
The, we sum their areas to get the Riema sum. We kow the left edpoit of the iterval [a,b] is x 1. That is, x 1 =a. Q5. How log is the subiterval from x 1 to x 2? Write a formula for x 2 i terms of x 1 ad h. A5: The subiterval is legth h. x 2 = x 1 +h Q6. How log is the subiterval from x i to x i+1? Write a formula for x i+1 i terms of x i ad h. A5: The subiterval is legth h. x i+1 = x i +h We will make lists by geeratig sequeces usig the commad Sequece[] Sytax: Sequece[ <Expressio>, <Variable>, <Start Value>, <Ed Value>, <Icremet>] Defie ListX=Sequece[ i, i, a, b, h ] Make sure you uderstad that the elemets of this list are x-values. Why? Because the start ad ed values are x-values! 1 st elemet is a=0, 2 d elemet is 0+h=1, 3 rd elemet is 1+h=2, 4 th elemet is 2+h=3, 5 th elemet is 3+h=4, 6 th elemet is 4+h=5 which is b so we stop. Q7. Look at this sequece ad thik about why is it easier for MadMath to give a value for tha a value for h? What are the oly requiremets for? What are the requiremets for h? A7: The oly requiremet for is that it be a atural umber. The h=(b-a)/. O the other had h must be a umber such that there exists a atural umber where a+h=b. Q8. I terms of how may elemets are i this list? A8: +1 Q9. What is the first elemet of ListX? If you aswered with a umber, say what this umber represets. A9: The first elemet of ListX is 0. This umber is a = left edpoit of iterval. Defie ListY=Sequece[ f(i), i, a, b, h ] Q10. What is the last elemet of ListY? If you aswered with a umber, say what this umber represets. I terms of which elemets is this? A10: The last elemet of ListY is 25. This umber is f(b) = the value of the fuctio at the right edpoit of iterval). These are lists of umbers. Now let s make the list of poits (x i,f(x i )). Defie ListPt=Sequece[ ( i, f(i) ), i, a, b, h ] Ow the Math with MadMath 4
Of course we could have just made the last list, but makig 3 lists (a) makes it easier to defie the vertices of the rectagles ad (b) satisfies MadMath s eed for you to show that you uderstad the techique of makig lists. This list of poits should be graphed as poits o the curve! Use that all is as it should be. Look at Figure 1 agai. Q11. I terms of how may rectagles do we eed? A11: Move tool to slide ad check Q12. I terms of a, b ad h what is the x-coordiate of the left vertices of the first rectagle? What is the x-coordiate of the left vertices of the last rectagle? A12: x-coordiate of left vertices of first rectagle is: x 1 = a x-coordiate of left vertices of last rectagle is: x = b-h Q13. I terms of what is the x-coordiate of the left vertices of the first rectagle? What is the x-coordiate of the left vertices of the last rectagle? A13: x-coordiate of left vertices of first rectagle is: x 1 = a x-coordiate of left vertices of last rectagle is: x = b-h We will obtai elemets of our lists by usig the commad Elemet[]. Sytax: Elemet[ <List>, <Positio of Elemet> ] From Q5, we have A=( x i,0). The x-coordiate of A is i the i th positio of ListX. So A is (Elemet[ListX,i],0). Aalogously, C is (Elemet[ListX,i+1], Elemet[ListY,i]). Q14. I this same way, fid the coordiates of B ad D of the i th rectagle. B is (Elemet[ListX,i], Elemet[ListY,i]) D is (Elemet[ListX,i+1], 0) Importat: Do t defie these poits i GeoGebra we must use them iside a sequece! (For fu you ca defie A=(Elemet[ListX,i],0) ad see how GeoGebra complais ad why.) We will make rectagles usig the commads Polygo[] ad Sequece[]. Sytax: Polygo[ <Poit>,..., <Poit> ] Notice that here i is a couter. Create list of left rectagles. Defie LeftR=Sequece[Polygo[A,B,C,D],i,1,,1] substitutig i the above formulas for A, B, C ad D! It will be a very log defiitio. Ow the Math with MadMath 5
It will look like the followig with your aswers to Q14 i place of the LeftR=Sequece[Polygo[(Elemet[ListX,i],0),,(Elemet[ListX,i+1],Elemet[ListY,i]), ], i,1,,1] I the Drawig pad, you should see the rectagles draw as i Figure 1. Now, look over at the Algebra View. Notice that LeftR cotais values. They are the areas of the correspodig rectagles I GeoGebra, we ca easily add these values! Defie LeftSum=Sum[LeftR]. Wow this looks great but actually it is ot quite right. Q15. What is the problem with this formula? Thik about whe f(x) is ot positive o the iterval [a,b]. A15: Sice areas are always positive values, this Sum will oly work whe f(x) is positive. Let s try agai. Remember our formula is: h i 1 f( x). ListY cotais all of these f-values. Defie LeftSum=h*Sum[ListY]. Wow this looks great but eve it is ot quite right. Q16. What is the problem with this formula? Thik about the umber of elemets i ListY. Which elemet should we take out? i A16: There are +1 values i ListY. From the formula ad from Q11 we kow we oly eed sums. We look carefully at the formula ad see that we do t eed h*f(x i+1 )=h*b. So we subtract this from the list sum. Oe last try. Defie LeftSum=h*Sum[ListY]-h*f(b). Now all is okay. If you wat, make Check Boxes to Show Defiite Itegral ad Show Left Riema Sum. o Select Check Box to Show/Hide Objects Tool. Click i the Drawig Pad. o Type Show Defiite Itegral, click o dow arrow ad the o c ad the Apply. o Repeat for Show Left Riema Sum, choosig both LeftR ad ListPt. Save your file. Ow the Math with MadMath 6