From the Numericl to the Theoreticl in Clculus Teching Contemporry Mthemtics NCSSM Ferury 6-7, 003 Doug Kuhlmnn Phillips Acdemy Andover, MA 01810 dkuhlmnn@ndover.edu
How nd Why Numericl Integrtion Should Precede the Fundmentl Theorem The short nswer is: "We mesure re, we don't define it." (Jerry Uhl) HOW TO INTRODUCE NUMERICAL INTEGRATION FIRST. Assumptions: Students know the derivtives of the usul elementry functions, including polynomils, trig functions, exponentil nd logs. In ddition they know the power rule for non-integer exponents, the product, quotient nd chin rules. They hve done few ntiderivtive prolems, minly velocity/distnce types. Introducing re under curve: L n nd R n. On the first dy of integrtion I sk the sic question: Wht is this re? How cn we mesure this re? One pproximtion leds to the left-hnd Riemnn sum in the usul fshion: L n = f (x 0 )h + f (x 1 )h +... + f (x n 1 )h where h =. Note tht I only consider pproximtions using rectngles of equl n width. The first time through clculus is not the time to generlize to things like prtitions, norms of prtions, refinements, etc. We immeditely consider the right-hnd Riemnn sum nd discuss why it is not priori possile to choose which is etter, the Left Hnd Rule or the Right Hnd Rule. At this point the clss writes short TI-83 progrm, clled INTEGRAL or AREA, tht clcultes this sum with, nd n s user inputs. This is good time to tech nd/or review For-End loops. (A listing of the finl version of the INTEGRAL progrm is t the end of these notes.) The first integrl progrm using Left nd Right hnd rules only nd ssumes tht the function is in Y1 is listed here. 1
INTEGRAL Progrm :ClrHome :Input "LOWER LIMIT=",A :Input "UPPER LIMIT=",B :Prompt N :(B-A)/N->H :0->L:0->R :A->X :For(J,1,N) :L+Y1*H->L :X+H->X :R+Y1*H->R :End :Disp "L, R",L,R Trpezoid nd Midpoint Rules At this point the clss usully invents the trpezoid rule themselves: T n = 1 (L n + R n ) This leds to modifiction of the INTEGRAL progrm.. I then suggest to the clss nother wy, the Midpoint rule, which uses the y-coordinte t the middle of the suintervl for the height of the rectngles. One cn compre the Trpezoid nd Midpoint rules in the following wy: nd T n = f (x 0 ) + f (x 1 ) h + f (x ) + f (x ) 1 h +... + f (x ) + f (x ) n 1 n h M n = f x 0 + x 1 h + f x 1 + x h +... + f x n 1 + x n We now mke nother, this time more sutle, chnge in our INTEGRAL progrm to llow us to clculte M n. h
Simpson's Rule without prols. For L n nd R n there ws no priori reson for choosing one or the other. Ech seems to e eqully ccurte nd so when we verge them for the trpezoid rule, we weight ech of them the sme. Cn we do similr thing with the Trpezoid nd Midpoint rules? We cn compre the ccurcy of the Trpezoid nd Midpoint rules y looking t some exmples tht we lredy know. By using our INTEGRAL progrm we see tht s n increses, our estimtes of the re under y = cos(x) etween x = 0 nd x = π pproch 1. Tking it s fct tht this re is indeed 1, let's compre the errors of the Trpezoid nd Midpoint rules, i.e let's exmine T n 1 nd M n 1. Here re three cses using n = 5, 10 nd 0 with the resulting errors or devitions from 1 for the trpezoid nd midpoint pproximtions. N T n 1 M n 1 5 -.00838.00414 10 -.00057.00109 0 -.000514.00057 Note tht the Mid-point pproximtion error is out hlf tht of the Trp pproximtion nd is of opposite sign. In this cse the Trp rule is too smll nd the Mid rule is too ig ut the Mid rule is out twice s close to the ctul re. We cn lso compre the ccurcies of T n nd M n y the following rgument. Consider one rectngle in the midpoint rule: M M 3
Keeping the point mrked M fixed on the curve, rotte the top of the rectngle, extending it t the sme time, until you mke it tngent to the curve t M. Wht is the re under the trpezoid formed with this tngent line s the non-prllel top? With little considertion, one cn show tht this re is the sme s the re of the orginl rectngle. This mens tht the strightforwrd Midpoint rule, s esy to clculte s the Left- nd Right-hnd rules, cn e thought of s the Tngent to the Midpoint Trpezoid Rule. Which is more ccurte, T n or M n? First nswer this question: Which is etter pproximtion to function, tngent line or secnt line. The nswer gives support to the rgument tht M n is etter pproximtion. So does the following heuristic rgument. For functions tht re concve up, the Midpoint rule is too smll nd the Trp rule is too ig. (Other wy round for concve down.) The picture ove lso suggest tht the error for Trp is twice s lrge in mgnitude s the error for Mid nd is of opposite sign, point we discovered numericlly erlier. Since M n is closer to the true vlue thn T n y fctor of two nd M n ndt n re on opposite sides of the true vlue, tht suggests we use weighted verge of the two. Consequently we define Simpson's rule s: S n = M n + T n 3 WARNING: Note the suscript. If we use n sudivisions for the Trp rule nd n sudivisions for the Midpoint rule, we hve effectively used n sudivisions for Simpson's rule this wy. 4
WHY DO NUMERICAL INTEGRATION FIRST? By now I hve lso introduced the integrl nottion f( x) dx to represent the re. By doing severl prolems pproximting this integrl, the students come to know tht f( x) dx is rel numer, not clss of functions. Additionlly, they c cn verify the ovious f (x) dx + f (x)dx = f (x) dx nd f (x)dx = 0. They cn even verify nd think out why c f (x)dx = f (x)dx (h is negtive in one of the sums). Finlly, I hve the clss perform this exercise: Let Y1=cos(X) nd evlute the following for vrious vlues of 0 cos(x)dx A little discusion llows them to see tht we hve creted new function: For every '' there is exctly one numer ssocited with tht, nmely the re from 0 to. I then sk them to ech find the vlue of this integrl for = 0,.,.4,.6,.8, 1.0, 1.,... s mny s there re students, mye twice s mny with every one doing two. When I first did this exercise we plotted the points on the ord: (0,0) (.,.199) (.4,.389) (.6,.565) (.8,.717) etc These questions were sked y students s we plotted them; 1. Why re they going down? (Eventully it does). Why re they negtive? (Ditto) 3. Why is it sin? If students cn sk these questions on their own, I ws convinced tht this method of introducing the integrl ws vlule. At this point we cn prove the Fundmentl Theorem in the usul wy, hving motivted it with the ove nd severl other exmples. However we cn lso explore ntiderivtives y solving differentil equtions grphiclly vi slope fields nd numericlly with Euler's method. 5
Slope Fields nd Euler's Method Suppose we wnted to find solutions to differentil eqution of the form y = g(x, y). Exmples of such differentil equtions include: y = y (1) y = x () y = x y (3) y = cos y (4) y = exp( x ) = e x (5) y = 1 + x 3 x (6) Equtions (1) through (4) re solvle y nlytic techniques ut equtions (5) nd (6) re not. Nevertheless, we cn get some qulittive informtion out the solutions of ll of the ove y looking t the slope fields for ech. SLOPE FIELDS If first-order differentil eqution cn e put in the form y = g(x, y), then we cn determine the slope of the solution y = f (x) through ny point (x, y). Grphiclly, we cn drw short line of the proper slope through ech of severl points (x, y) in the plne. The resulting picture of short slope lines is clled slope field. I think of slope field s series of conditionl sttements: If solution psses through the point (x, y), this is the slope it would hve. Consider simple cse: f (x) = x. On piece of grph pper, here chosen very smll to mke it esier, select grid of points nd t ech point selected drw short segment whose slope is x, the first coordinte of the point. This is the resulting picture: y x We know the solutions to this differentil eqution re f (x) = x + C, nd if we mentlly overly these on the grid ove, we cn see how the solutions follow the slope field. 6
In prctice this cn e very time consuming or t lest tedious, ut computer or progrmmle clcultor cn do the tsk for us. In the following exmples, TI-83 progrm drew the slope fields. The listing for this progrm is given t the end. Before we proceed, let's remind ourselves of the following theorem found in lmost ny text on elementry differentil equtions. Theorem. For first order differentil eqution y = g(x, y) with intil condition y(x 0 ) = y 0, sufficient (though not necessry) condition tht unique solution y = f (x) exist is tht g nd g e rel, finite, single-vlued, nd continuous over y rectngulr region of the plne contining the point (x 0, y 0 ). In simpler terms, if g(x, y) is suitly nice, we cn sfely mke the ssumption tht unique solution exists. In ll of the cses we shll exmine, the ove conditions re stisfied. Wht this mens is tht given specific point in our slope field there is exctly one solution tht psses through this point. Exmple 1. y = y Before we sketch the slope field, notice tht if y = y then y = y = y. Similrly, ny order derivtive of y is equl to y. Below is the slope field for this eqution on the viewing window [-4.7, 4.7] X [-3.1, 3.1] (Unless otherwise stted, ll viewing windows will hve these dimensions.) y = y We esily recognize the exponentil functions f (x) = Ae x s solutions nd cn esily visulize them on top of the slope field. 7
Exmple. y = x (Left to reder to expnd ove slope field.) Exmple 3. y = x y Note tht y = 1 y =1 (x y) = 1 x + y. We then conclude tht y > 0 if y < x y > 0 if y > x 1 y = 0 if y = x y = 0 if y = x 1 y < 0 if y > x y < 0 if y < x 1 The slope field for this eqution shows tht ny solution stisfies the ove conditions. y = x y Note tht nywhere long the line y = x, the slope is zero. It is esy to sketch qulittive solutions to the differentil equtions y following the slope fields, ut here gin the computer cn help using numericl methods to pproximte solutions. 8
EULER'S METHOD The first numericl method is Euler's method, strightforwrd, simple (nd hence prone to inccurcies t times) method for pproximting solutions to y = g(x, y). It is nlogous to using the left hnd rule for pproximting integrls. If we know tht the point (x 0, y 0 ) is on our curve nd we define our new x 1 to e x 1 = x 0 + h where h is the step-size or increment. Then the new y is given y y 1 = y 0 + g(x 0, y 0 )h. We pproximte y y using the tngent line which hs slope given y g(x 0, y 0 ). The new point is connected to the old point nd the process is repeted, generting n pproximte solution to the differentil eqution. Tht is, we find x = x 1 + h nd y = y 1 + g(x 1,y 1 )h. Note tht we reclculted the slope t the point (x 1,y 1 ). We repet this s mny times s needed. Below is the originl slope field nd next to it is slope field with severl solutions sketched on it using Euler's method for y = x y One question tht immeditely rises, is the existence of possile symptote to ll of the solutions. They ll seem to converge to line. In fct, if we you nlytic techniques (using integrting fctors) to solve y = x y we get the generl solution to e y = x 1+ Ce x It is now cler tht the line y = x 1 is n symptote for ll solutions to our eqution. 9
Exmple 4. y = cos y Using nlytic techniques, nmely seprting vriles, we get sec y dy = dx Integrting nd rememering the trick for integrting secnt, we get ln sec y + tn y = x + C But wht do these curves look like? Cn you sketch one? Question: Wht does the solution tht goes through the point (-4, 3) look like? Answer: Huh? Slope fields cn help. Below is the slope field for y = cos y. y = cos y Exmining it crefully, we see tht the lines y = π nd y = π re importnt. Both re fixed points in the sense tht if y = π or y = π, then cos y = 0 nd so there is no chnge in y. However, there is very ig difference etween the two lines. The line y = π is n ttrctive fixed point. If you strt within neighorhood of y = π the solution will converge to the line: It will e "ttrcted" to the line. On the other hnd, the line y = π is repelling fixed point. If you strt even slightly wy from y = π further wy nd eventully converges to nother fixed point. the curve moves 10
Below re Euler solutions with different strting points ll close to ech other. x 0 = 4, y 0 = π, x 0 = 4, y 0 = π, +.01 x 0 = 4, y 0 = π,.01 I leve it to the reder to determine wht the curve through (-4, 3) looks like. Euler's Method nd the Fundmentl Theorem If the derivtive is function of x lone, i.e. dy dx = f (x), then Euler's method cn e used to illuminte the Fundmentl Theorem of Clculus. Suppose we know the derivtive nd strting point for function so tht we re given point (, f ()) nd the derivtive f (x) nd we wish to evlute (estimte) f () where for this rgument < (lthough it doesn't hve to e). If we define h = n following: nd then use Euler's with step size h nd n steps, we get the 11
x 0 = f (x 0 ) = f ()... x 1 = x 0 + h f (x 1 ) f (x 0 ) + f (x 0 )h x = x 1 + h f (x ) f (x 1 ) + f (x 1 )h x n 1 = x n + h f (x n 1 ) f (x n ) + f (x n )h x n = x n 1 + h f (x n ) f (x n 1 ) + f (x n 1 )h Note tht x n = nd f (x n ) = f (). If we sustitute the next to lst eqution for f (x n 1 ) into to the lst one we get f (x n ) f (x n ) + f (x n )h + f (x n 1 )h Sustitute the previous eqution ove nd get f (x n ) f (x n 3 ) + f (x n 3 )h + f (x n )h + f (x n 1 )h. Repeting this we get f (x n ) f (x 0 ) + f (x 0 )h + f (x 1 )h +... + f (x n 1 )h Rememering tht f (x 0 ) = f () nd f (x n ) = f () we see tht the lst eqution just sys tht f () f () f (x 0 )h + f (x 1 )h +... + f (x n 1 )h nd the right hnd side of this eqution is just the Left-hnd Riemnn sum pproximting the integrl of f (x) nd so we re led to f () f () = f (x)dx which is the Fundmentl Theorem. 1
Progrm listings: INTEGRAL Progrm :ClrHome :Input "LOWER LIMIT=",A :Input "UPPER LIMIT=",B :Prompt N :(B-A)/N->H :0->L:0->M:0->R :A->X :For(J,1,N) SLOPEFLD Progrm :Func:FnOff :PlotsOff :ClrDrw :ClrHome :Disp "AXES ON (1) :Disp "OR OFF (0)" :Input A :If A=0 :Then:AxesOff :Else:AxesOn :End :Disp "HOW MANY MARKS?" :Input "ACROSS: ",A :Input "DOWN: ",D :(Xmx-Xmin)/A->H :(Ymx-Ymin)/D->V :For(I,1,D) :For(J,1,A) :Xmin+(J-1)H+H/->X :Ymin+(I-1)V+V/->Y :Y1->M :Y-.30MH->S :Y+.30MH->Z :X-.30H->P :X+.30H->Q :If s (Z-S)>.6V :Then :Y+.30V->Z :Y-.30V->S :(Z-Y)/M+X->Q :(S-Y)/M+X->P :End :Line(P,S,Q,Z) :End:End :L+Y1*H->L :X+H/->X :M+Y1*H->M :X+H/->X :R+Y1*H->R :End :(L+R)/->T :(M+T)/3->S :Disp "L, R, T,M,S",L,R,T,M,S EULER Progrm :Func:FnOff :Input "X START=",A :Input "Y START=",B :Input "STEP SIZE=",H :Input "NO. STEPS=",N :A->X:B->Y :For(I,1,N) :X->U:Y->V :Y+Y H->Y :X+H->X :Line(U,V,X,Y) :End 13
Runge-Kutt techniques re nlogous to Simpson's rule. Below is the code for progrm tht uses fourth order Runge-Kutt technique to numericlly pproximte solution to first order differentil eqution y = g(x,y). RK4GRAPH Progrm :Func:FnOff :Input "X START=",A :Input "Y START=",B :Input "STEP SIZE=",H :Input "NO. STEPS=",N :A->X:B->Y :For(I,1,N) :X->U:Y->V :Y1->K :X+H/->X :V+H*K/->Y :Y1->L :V+H*L/->Y :Y1->S :X+H/->X :V+H*S->Y :Y1->T :V+(H/6)(K+L+S+T)->Y :Line(U,V,X,Y):End Doug Kuhlmnn Phillips Acdemy Andover, MA 01810 dkuhlmnn@ndover.edu 6 Ferury 003 14