Transcription of Trapezoid Rule and Simpson’s Rule Trapezoid Rule y h h h x b
1 Trapezoid Rule and Simpson s Rulec 2002, 2008, 2010 Donald Kreider and Dwight LahrTrapezoid RuleMany applications of calculus involve definite integrals. If we can find an antiderivative for the integrand,then we can evaluate the integral fairly easily. When we cannot, we turn to numerical methods. Thenumerical method we will discuss here is called theTrapezoid Rule. Although we often can carry out thecalculations by hand, the method is most effective with the use of a computer or programmable at the moment let s not concern ourselves with these details. We will describe the method first, andthen consider ways to implement =x0x1x2x3 = by0y1y3hhhy2fThe general idea is to use trapezoids instead of rectangles to approximate the area under the graphof a function. A Trapezoid looks like a rectangle except that it has a slanted line for a top.
2 Working onthe interval [a,b], we subdivide it intonsubintervals of equal widthh= (b a)/n. This gives rise to thepartitiona=x0 x1 x2 xn=b, where for eachj,xj=a+jh, 0 j n. Moreover, we letyj=f(xj),0 j n. That is, the vertical edges go from thex-axis to the graph off. Consult the sketchabove where we have shown a finite number of we are going to use trapezoids instead of rectangles as our basic area elements, then we have to havea formula for the area of a -yLWith reference to the sketch above, the area of a Trapezoid consists of the area of the rectangle plus thearea of the triangle, orhyL+ (h/2)(yR yL) =h(yL+yR)/2. So, the area ishtimes the average of thelengths of the two vertical , we return to the original problem of finding the definite integral of a functionfdefined on theinterval [a,b].
3 We define theTrapezoid Ruleas :Then-subinterval Trapezoid approximation to baf(x)dxis given byTn=h2(y0+ 2y1+ 2y2+ 2y3+ + 2yn 1+yn)=h2 y0+yn+ 2n 1 j=1yj To see where the formula comes from, let s carry out the process of adding the areas of the to the original sketch, and use the formula we derived for the area of a Trapezoid . Note that when weadd the areas of the trapezoids starting on the left, the area of the first , second, and third are:h2(y0+y1)h2(y1+y2)h2(y2+y3)So,y0andy 3, the first and the last, each appear once; and all the otheryj s appear exactly twice. We cansee from this example that there will be a similar pattern no matter the number of trapezoids: The first andthe last vertical edge appears once, and all other vertical edges appear two times when we sum the areas ofthe trapezoids.
4 This is exactly what the Trapezoid Rule entails in the formula 1:FindT5for 211xdx. We can readily determine that f(x) = 1/x,h= 1/5 (soh/2 = 1/10),andxj= 1 +j/5,0 j ,T5=110(1 +12+ 2(56+57+58+59)) .0696 Example 2:FindT5for 10 1 x2dx. That is, we are going to approximate one-quarter of the areaof a circle of radius 1. The exact answer is /4, or approximately .7853981635. Note thath= 1/5,y0= 1andy5= 0. Thus,T5=110 1 + 24 j=1 1 j225 or about . s RuleAnother technique for approximating the value of a definite integral is calledSimpson s Rule. Whereasthe main advantage of the Trapezoid rule is its rather easy conceptualization and derivation, Simpson s rule2approximations usually achieve a given level of accuracy faster. Moreover, the derivation of Simpson s ruleis only marginally more difficult. Both rules are examples of what we refer to asnumerical the Trapezoid rule method, we start with rectangular area-elements and replace their horizontal-linetops with slanted lines.
5 The area-elements used to approximate, say, the area under the graph of a functionand above a closed interval then become trapezoids. Simpson s method replaces the slanted-line tops two points determine the equation of a line, three are required for a parabola. We also needto develop a formula for the area of a parabolic-top area-element if the sum of such areas is to become theSimpson we consider a parabolay=Ax2+Bx+Cwith its axis parallel to they-axis and passingthrough three equally spaced points ( h,yL), (0,yM), and (h,yR). Then substituting the three points intothe equation gives three equations in the three unknownsA,B, Bh+CyM=CyR=Ah2+Bh+CSolving these three equations by adding the first to the last, and then by subtracting the last from thefirst, yields:2Ah2=yL+yR 2yMB=1hyR yL2C=yMNext, we compute the area under the parabolay=Ax2+Bx+Cand above the interval [ h,h] for thevalues ofA,B, andCwe just found:3 h hAx2+Bx+C dx=(Ax33+Bx22+Cx) h h=132Ah3+ 2Ch=h(132Ah2+ 2C)=h(13(yL+yR 2yM) + 2yM)=h3(yL+yR 2yM+ 6yM)=h3(yL+yR+ 4yM)The above formula holds for the area of a parabolic topped area element with base of length 2handvertical edges of lengthyLon the left andyRon the right.
6 The height at the midpoint , letnbe an even positive integer, and suppose we divide an interval [a,b] intonequal parts eachof lengthh=b an. And supposefis a function defined on [a,b]. As before we label the resulting partitiona=x0 x1 x2 xn=b, where for eachj,xj=a+jh, 0 j n. And again, we letyj=f(xj),0 j n. That is, the vertical edges go from thex-axis to the graph , start at the left endpointaof the interval and erect a parabolic-top area-element on the first twosubintervals. The base of this area-element goes fromx0tox2, and we use as vertical sides the lines thatintersect the graph at (x0,y0) on the left and (x2,y2) on the right. The point (x1,y1) on the graph offat the midpoint of the interval gives the third point we need to determine the parabola that forms thetop of the area-element.
7 From the formula we developed above, the area of this area-element is equal toh3(y0+y2+ 4y1).If we repeat this process using the next two subintervals that go fromx2tox4, then the area of theresulting parabolic-top element will be (from an application of the formula above)h3(y2+y4+ 4y3). Thus,the sum of the areas of the two parabolic-top elements equalsh3(y0+ 4y1+ 2y2+ 4y3+y4). We continue inthis way until we have calculated the areas of then2parabolic-top area elements and added them pattern begins to emerge in the form of the sum of the areas of then2parabolic-top area-elements. Thesum will equalh3multiplied by:y0+yn, the sum of the heights of the leftmost and rightmost verticaledges; plus 4 times the sum of the odd-indexed heights; plus 2 times the sum of the even-indexed heightsbecause these edges belong to two successive area-elements, one on the left and the other on the right.
8 Thisexplains the form of the Simpson s Rule approximation which we now stateDefinition:Letnbe even. Then-subinterval Simpson approximation to baf(x)dxis given bySn=h3(y0+ 4y1+ 2y2+ 4y3+ 2y4+ + 2yn 2+ 4yn 1+yn)=h3(y0+yn+ 4 yodd+ 2 yeven)Example 3:FindS4for 211xdx. The exact answer is ln 2, or approximately In Example1 we found thatT5is equal to about If we are to use Simpson s rule for an approximation, thennhas to be even. Therefore,S4is a legitimate sum to calculate. Note thath= 1/4. The five points of thepartition arex0= 1,x1= 5/4,x2= 3/2,x3= 7/4,x4= 2. And the correspondingy-values arey0= 1,4y1= 4/5,y2= 2/3,y3= 4/7 andy4= 1/2. Thus,S4=112(1 +12+ 4 (y1+y3) + 2 (y2))=112(1 +12+ 4(45+47)+ 2(23)) thatS4with a smallernis a better approximation to the actual value of the integral 4:FindS4for 10 1 x2dx.
9 The exact answer is /4, or approximately , one-quarter of the area of a circle of radius 1. In Example 2 we found thatT5is equal to about we are to use Simpson s rule for an approximation, thennhas to be even, soS4makes sense. Note thath= 1/4. The five points of the partition arex0= 0,x1= 1/4,x2= 1/2,x3= 3/4,x4= 1. And thecorrespondingy-values arey0= 1,y1= 1 1/16,y2= 1 1/4,y3= 1 9/16 andy4= 0. Thus,S4=112(1 + 0 + 4 (y1+y3) + 2 (y2))=112(1 + 0 + 4( 15/16 + 7/16)+ 2 3/4)or about The latter is a better approximation with a smallernthan we got with the Comparisons: As we found to be true in the examples, Simpson s rule is indeed much betterthan the Trapezoid rule. Asn it generally converges much more rapidly to the value of the definiteintegral than does the Trapezoid can get a sense of the differences in the rates of convergence of the two methods from the folowingtwo theorems:Th1: Suppose the second derivative offis continuous and hence necessarily bounded by a positinenumberM2on [a,b].
10 IferrorTn= baf(x)dx Tn, then|errorTn| M2(b a)312n2Th2: Suppose the fourth derivative offis continuous and hence necessarily bounded by a positivenumberM4on [a,b]. IferrorSn= baf(x)dx Sn, then|errorSn| M4(b a)5180n4 These theorems imply that in many situations, asn ,|errorTn| 0 like 1/n2and|errorSn| 0like 1/n4. This explains why in general we are not surprised to find that Simpson s rule converges to thevalue of the integral much faster than the Trapezoid of the Trapezoid and Simpson rules : You might ask,What is the point of the Trapand Simp approximations in this age of computers? The answer is that they are simple to use and giveexcellent results, surprisingly so even for smalln. A little arithmetic can yield a good estimate of a definiteintegral with only modest effort.