Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'thuật toán algorithms (phần 10)', khoa học tự nhiên, toán học phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | INTEGRATION S3 Recall that the area of a trapezoid is one-half the product of the height and the sum of the lengths of the two bases. The error for this method can be derived in a similar way as for the rectangle method. It turns out that f dr-L . Thus the rectangle method is twice as accurate as the trapezoid method. This is borne out by our example. The following procedure implements the trapezoid method in the common case where all the intervals are the same width function inttrapfa b real N integer real var i integer w t real begin t 0 w b a N for i l to N do t t w f a i-l w f a i w 2 inttrap t end This procedure produces the following estimates for 10 0.6937714031754 100 0.6931534304818 1000 0.6931472430599 It may seem surprising at first that the rectangle method is more accurate than the trapezoid method the rectangles tend to fall partly under the curve partly over so that the error can cancel out within an interval while the trapezoids tend to fall either completely under or completely over the curve. Another perfectly reasonable method is spline quadrature spline interpolation is performed using methods we have discussed and then the integral is computed by piecewise application of the trivial symbolic polynomial integration technique described above. Below we ll see how this relates to the other methods. Compound Methods Examination of the formulas given above for the error of the rectangle and trapezoid methods leads to a simple method with much greater accuracy called Simpson s method. The idea is to eliminate the leading term in the error 84 CHAPTER 7 by combining the two methods. Multiplying the formula for the rectangle method by 2 adding the formula for the trapezoid method then dividing by 3 gives the equation b f x dx - 2r 1 2w5 i 3 The w3 term has disappeared so this formula tells us that we can get a method that is accurate to within w5 by combining the quadrature formulas in the same way If an interval size of .01 is used for Simpson s rule .