In general we have an interval a b and a function f x

This preview shows page 54 - 57 out of 121 pages.

In general, we have an interval [a, b] and a functionf(x). We break theinterval intoNequal pieces. Leth=b-aN= Δxk. Then for the left endpoints,we havex1=a, x2=a+h, . . . , xN=b-hand for the right endpoints, we havex1=a+h, x2=a+ 2h, . . . , xN=band either way our approximation can be written asZbaf(x)dxNXk=1f(xk)h.
3.1.NUMERICAL INTEGRATION TECHNIQUES553.1.2Midpoint RuleQuite a bit can happen between endpoints. Let’s try to improve our approx-imation by picking the midpoints instead. For this method, we have to firstdo a little arithmetic to find our points. In our previous example, we wouldhavex1=0 +142=18, x2=14+122=38, x3=12+342=58, x4=34+ 12=78.Our new approximation would be12πZ10e-x2/2dx12π4Xk=1e-x2k/2Δxk=12π14(e-1128+e-9128+e-25128+e-49128)0.342In general, we have an interval [a, b] and a functionf(x). We break theinterval intoNequal pieces. Leth=b-aN= Δxk. Then our midpoints arex1=a+h2, x2=a+3h2, . . . , xN=b-h2.and our approximation can again be written asZbaf(x)dxNXk=1f(xk)h:=Mn.We will not have time in this class to carefully analyze the pros andcons of these various techniques. It turns out that the midpoint rule offersa substantial improvement over the endpoint rules.However, it should benoted that if you were to take an actual numerical analysis class (which is notas hard as it sounds), then you would learn about far superior techniques thatare still quite simple to implement on a computer. Here is the error estimatefor the midpoint method:Zbaf(x)dx-MnK(b-a)324n2(3.1)whereK= max|f00(x)|forx[a, b].For the example we just did, on the interval [0,1], we have|f00(x)|=12πe-x2/2(1-x2)1.
56CHAPTER 3.APPROXIMATIONS WITH CALCULUSSo, our estimate is at worst off by1(24)(42)0.0026, and since that secondderivative decreases from 1 to 0 over our interval, we can be confident thatthis is a true upper bound. Thus, our first two digits.34 must be right. Thus,the odds of getting between the average and one standard deviation above is34%. If we increased the number of rectangles from 4 to 8, then our accuracybound go from1(24)(42)0.0026 to1(24)(82)0.00065, a huge improvementthanks to thatn2in the denominator. Because of this, the midpoint rule isasecond-orderapproximation. The crappy left- and right-endpoint rules areonly first-order.3.1.3Trapezoidal RuleAnother way to get a decent (second-order) approximation is to use trape-zoids instead of rectangles. Instead of picking a height for the rectangle, wesimply connect the two heights at both endpoints to give them a slanted top,a shape called a trapezoid (only one pair of parallel sides).If you look atthe formula for the area of a trapezoid (or take a few minutes to derive ityourself), you can check that this is equivalent to taking the average of theheights at the end points.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture