19.7 KB · commit a9602da
The general problem of numerical integration may be stated as follows. Given a set of data points (x0,y0), (x1,y1), ..., (xn,yn) of a function y=f(x), where f(x) is not known explicitly, it is required to compute the value of the definite integral I=∫abydx.(6.28)
As in the case of numerical differentiation, one replaces f(x) by an interpolating polynomial ϕ(x) and obtains, on integration, an approximate value of the definite integral. Thus, different integration formulae can be obtained depending upon the type of the interpolation formula used. We derive in this section a general formula for numerical integration using Newton's forward difference formula.
Let the interval [a,b] be divided into n equal subintervals such that a=x0<x1<x2<⋯<xn=b. Clearly, xn=x0+nh. Hence the integral becomes I=∫x0xnydx. Approximating y by Newton's forward difference formula, we obtain I=∫x0xn[y0+pΔy0+2p(p−1)Δ2y0+6p(p−1)(p−2)Δ3y0+⋯]dx. Since x=x0+ph, dx=hdp and hence the above integral becomes I=h∫0n[y0+pΔy0+2p(p−1)Δ2y0+6p(p−1)(p−2)Δ3y0+⋯]dp, which gives on simplification ∫x0xnydx=nh[y0+2nΔy0+12n(2n−3)Δ2y0+24n(n−2)2Δ3y0+⋯].(6.29) From this general formula, we can obtain different integration formulae by putting n=1,2,3,…, etc. We derive here a few of these formulae but it should be remarked that the trapezoidal and Simpson's 1/3-rules are found to give sufficient accuracy for use in practical problems.
Setting n=1 in the general formula (6.29), all differences higher than the first will become zero and we obtain ∫x0x1ydx=h(y0+21Δy0)=h[y0+21(y1−y0)]=2h(y0+y1).(6.30) For the next interval [x1,x2], we deduce similarly ∫x1x2ydx=2h(y1+y2)(6.31)
and so on. For the last interval [xn−1,xn], we have ∫xn−1xnydx=2h(yn−1+yn).(6.32) Combining all these expressions, we obtain the rule ∫x0xnydx=2h[y0+2(y1+y2+⋯+yn−1)+yn],(6.33) which is known as the trapezoidal rule.
The geometrical significance of this rule is that the curve y=f(x) is replaced by n straight lines joining the points (x0,y0) and (x1,y1); (x1,y1) and (x2,y2), ..., (xn−1,yn−1) and (xn,yn). The area bounded by the curve y=f(x), the ordinates x=x0 and x=xn, and the x-axis is then approximately equivalent to the sum of the areas of the n trapeziums obtained.
The error of the trapezoidal formula can be obtained in the following way. Let y=f(x) be continuous, well-behaved, and possess continuous derivatives in [x0,xn]. Expanding y in a Taylor's series around x=x0, we obtain ∫x0x1ydx=∫x0x1[y0+(x−x0)y0′+2(x−x0)2y0′′+⋯]dx =hy0+2h2y0′+6h3y0′′+⋯(6.34) Similarly, 2h(y0+y1)=2h(y0+y0+hy0′+2h2y0′′+6h3y0′′′+⋯) =hy0+2h2y0′+4h3y0′′+⋯(6.35) From Eqs. (6.34) and (6.35), we obtain ∫x0x1ydx−2h(y0+y1)=−121h3y0′′+⋯,(6.36) which is the error in the interval [x0,x1]. Proceeding in a similar manner we obtain the errors in the remaining subintervals, viz., [x1,x2], [x2,x3], ... and [xn−1,xn]. We thus have
E=−121h3(y0′′+y1′′+⋯+yn−1′′),(6.37) where E is the total error. Assuming that y′′(xˉ) is the largest value of the n quantities on the right-hand side of Eq. (6.37), we obtain E=−121h3ny′′(xˉ)=−12b−ah2y′′(xˉ)(6.38) since nh=b−a.
This rule is obtained by putting n=2 in Eq. (6.29), i.e. by replacing the curve by n/2 arcs of second-degree polynomials or parabolas. We have then ∫x0x2ydx=2h(y0+Δy0+61Δ2y0)=3h(y0+4y1+y2). Similarly, ∫x2x4ydx=3h(y2+4y3+y4) ⋮ and finally ∫xn−2xnydx=3h(yn−2+4yn−1+yn). Summing up, we obtain ∫x0xnydx=3h[y0+4(y1+y3+y5+⋯+yn−1)+2(y2+y4+y6+⋯+yn−2)+yn],(6.39) which is known as Simpson's 1/3-rule, or simply Simpson's rule. It should be noted that this rule requires the division of the whole range into an even number of subintervals of width h.
Following the method outlined in Section 6.4.1, it can be shown that the error in Simpson's rule is given by ∫abydx=3h[y0+4(y1+y3+y5+⋯+yn−1)+2(y2+y4+y6+⋯+yn−2)+yn] =−180b−ah4yiv(xˉ),(6.40) where yiv(xˉ) is the largest value of the fourth derivatives.
Setting n=3 in Eq. (6.29), we observe that all the differences higher than the third will become zero and we obtain ∫x0x3ydx=3h(y0+23Δy0+43Δ2y0+81Δ3y0) =3h[y0+23(y1−y0)+43(y2−2y1+y0)+81(y3−3y2+3y1−y0)] =83h(y0+3y1+3y2+y3). Similarly ∫x3x6ydx=83h(y3+3y4+3y5+y6) and so on. Summing up all these, we obtain ∫x0xnydx=83h[(y0+3y1+3y2+y3)+(y3+3y4+3y5+y6)+⋯+(yn−3+3yn−2+3yn−1+yn)] =83h(y0+3y1+3y2+2y3+3y4+3y5+2y6+⋯+2yn−3+3yn−2+3yn−1+yn)(6.41) This rule, called Simpson's (3/8)-rule, is not so accurate as Simpson's rule, the dominant term in the error of this formula being −(3/80)h5yiv(xˉ).
If we wish to retain differences up to those of the fourth order, we should integrate between x0 and x4 and obtain Boole's formula ∫x0x4ydx=452h(7y0+32y1+12y2+32y3+7y4)(6.42) The leading term in the error of this formula can be shown to be −9458h7yvi(xˉ).
If, on the other hand, we integrate between x0 and x6 retaining differences up to those of the sixth order, we obtain Weddle's rule ∫x0x6ydx=103h(y0+5y1+y2+6y3+y4+5y5+y6),(6.43) the error in which is given by −(h7/140)yvi(xˉ).
These two formulae can also be generalized as in the previous cases. It should, however, be noted that the number of strips will have to be a multiple of four in the case of Boole's rule and a multiple of six for Weddle's rule.
If s(x) is the cubic spline in the interval (xi−1,xi), then we have I=∫x0xnydx≈i=1∑n∫xi−1xis(x)dx =i=1∑n∫xi−1xi{6h1[(xi−x)3Mi−1+(x−xi−1)3Mi]+h1(xi−x)(yi−1−6h2Mi−1)+h1(x−xi−1)(yi−6h2Mi)}dx, using Eq. (5.27). On carrying out the integration and simplifying, we obtain I=i=1∑n[2h(yi−1+yi)−24h3(Mi−1+Mi)],(6.44) where Mi, the spline second-derivatives, are calculated from the recurrence relation Mi−1+4Mi+Mi+1=h26(yi−1−2yi+yi+1),i=1,2,…,n−1. The use of the cubic spline method is demonstrated in Example 6.13.
This method can often be used to improve the approximate results obtained by the finite-difference methods. Its application to the numerical evaluation of definite integrals, for example in the use of trapezoidal rule, can be described, as follows. We consider the definite integral
I=∫abydx and evaluate it by the trapezoidal rule (6.33) with two different subintervals of widths h1 and h2 to obtain the approximate values I1 and I2, respectively. Then Eq. (6.38) gives the errors E1 and E2 as E1=−121(b−a)h12y′′(xˉ)(6.45) and E2=−121(b−a)h22y′′(xˉ).(6.46) Since the term y′′(xˉ) in Eq. (6.46) is also the largest value of y′′(x), it is reasonable to assume that the quantities y′′(xˉ) and y′′(xˉ) are very nearly the same. We therefore have E2E1=h22h12 and hence E2−E1E2=h22−h12h22. Since E2−E1=I2−I1, this gives E2=h22−h12h22(I2−I1).(6.47) We therefore obtain a new approximation I3 defined by I3=I2−E2=h22−h12I1h22−I2h12,(6.48) which, in general, would be closer to the actual value—provided that the errors decrease monotonically and are of the same sign.
If we now set h2=21h1=21h Equation (6.48) can be written in the more convenient form I(h,21h)=31[4I(21h)−I(h)],(6.49)
where I(h)=I1, I(21h)=I2andI(h,21h)=I3. With this notation the following table can be formed
| I(h) | |||
|---|---|---|---|
| I(h,21h) | |||
| I(21h) | I(h,21h,41h) | ||
| I(21h,41h) | I(h,21h,41h,81h) | ||
| I(41h) | I(21h,41h,81h) | ||
| I(41h,81h) | |||
| I(81h) |
The computations can be stopped when two successive values are sufficiently close to each other. This method, due to L.F. Richardson, is called the deferred approach to the limit and the systematic tabulation of this is called Romberg Integration.
Let the interpolation points, xi, be equally spaced, i.e. let xi=x0+ih, i=0,1,2,…,n, and let the end points of the interval of integration be placed such that x0=a,xn=b,h=nb−a. Then the definite integral I=∫abydx(6.50) is evaluated by an integration formula of the type In=i=0∑nCiyi,(6.51)
where the coefficients Ci are determined completely by the abscissae xi. Integration formulae of the type (6.51) are called Newton–Cotes closed integration formulae. They are 'closed' since the end points a and b are the extreme abscissae in the formulae. It is easily seen that the integration formulae derived in Eqs. (6.47)–(6.50) are the simplest Newton–Cotes closed formulae.
On the other hand, formulae which do not employ the end points are called Newton–Cotes, open integration formulae. We give below the five simplest Newton–Cotes open integration formulae
(a) \int_{x_0}^{x_2} y \, dx = 2hy_1 + \frac{h^3}{3}y''(\bar{x}), \quad (x_0 < \bar{x} < x_2) \tag{6.52}
(b) \int_{x_0}^{x_3} y \, dx = \frac{3h}{2}(y_1 + y_2) + \frac{3h^3}{4}y''(\bar{x}), \quad (x_0 < \bar{x} < x_3) \tag{6.53}
(c) \int_{x_0}^{x_4} y \, dx = \frac{4h}{3}(2y_1 - y_2 + 2y_3) + \frac{14}{45}h^5 y^{\text{iv}}(\bar{x}), \quad (x_0 < \bar{x} < x_4) \tag{6.54}
(d) \int_{x_0}^{x_5} y \, dx = \frac{5h}{24}(11y_1 + y_2 + y_3 + 11y_4) + \frac{95}{144}h^5 y^{\text{iv}}(\bar{x}), \quad (x_0 < \bar{x} < x_5) \tag{6.55}
(e) \int_{x_0}^{x_6} y \, dx = \frac{6h}{20}(11y_1 - 14y_2 + 26y_3 - 14y_4 + 11y_5) + \frac{41}{140}h^7 y^{\text{vi}}(\bar{x}), \quad (x_0 < \bar{x} < x_6). \tag{6.56}
A convenient method for determining the coefficients in the Newton–Cotes formulae is the method of undetermined coefficients. This is demonstrated in Example 6.14.