18.3 KB · commit a9602da
The general method for deriving the numerical differentiation formulae is to differentiate the interpolating polynomial. Hence, corresponding to each of the formulae derived in Chapter 3, we may derive a formula for the derivative. We illustrate the derivation with Newton's forward difference formula only, the method of derivation being the same with regard to the other formulae.
Consider Newton's forward difference formula: y=y0+uΔy0+2!u(u−1)Δ2y0+3!u(u−1)(u−2)Δ3y0+⋯,(6.1) where x=x0+uh.(6.2) Then dxdy=dudydxdu=h1(Δy0+22u−1Δ2y0+63u2−6u+2Δ3y0+⋯).(6.3) This formula can be used for computing the value of dy/dx for non-tabular values of x. For tabular values of x, the formula takes a simpler form, for by setting x=x0 we obtain u=0 from Eq. (6.2), and hence Eq. (6.3) gives [dxdy]x=x0=h1(Δy0−21Δ2y0+31Δ3y0−41Δ4y0+⋯).(6.4) Differentiating Eq. (6.3) once again, we obtain dx2d2y=h21(Δ2y0+66u−6Δ3y0+2412u2−36u+22Δ4y0+⋯),(6.5) from which we obtain [dx2d2y]x=x0=h21(Δ2y0−Δ3y0+1211Δ4y0+⋯).(6.6) Formulae for computing higher derivatives may be obtained by successive differentiation. In a similar way, different formulae can be derived by starting with other interpolation formulae. Thus,
(a) Newton's backward difference formula gives [dxdy]x=xn=h1(∇yn+21∇2yn+31∇3yn+⋯)(6.7) and [dx2d2y]x=xn=h21(∇2yn+∇3yn+1211∇4yn+65∇5yn+⋯).(6.8)
(b) Stirling's formula gives [dxdy]x=x0=h1(2Δy−1+Δy0−612Δ3y−2+Δ3y−1+3012Δ5y−3+Δ5y−2+⋯)(6.9)
and [dx2d2y]x=x0=h21(Δ2y−1−121Δ4y−2+901Δ6y−3−⋯).(6.10) If a derivative is required near the end of a table, one of the following formulae may be used to obtain better accuracy hy0′=(Δ−21Δ2+31Δ3−41Δ4+51Δ5−61Δ6+⋯)y0(6.11) =(Δ+21Δ2−61Δ3+121Δ4−201Δ5+301Δ6−⋯)y−1(6.12) h2y0′′=(Δ2−Δ3+1211Δ4−65Δ5+180137Δ6−107Δ7+560363Δ8−⋯)y0(6.13) =(Δ2−121Δ4+121Δ5−18013Δ6+18011Δ7−56029Δ8+⋯)y−1(6.14) hyn′=(∇+21∇2+31∇3+41∇4+51∇5+61∇6+71∇7+81∇8+⋯)yn(6.15) =(∇−21∇2−61∇3−121∇4−201∇5−301∇6−421∇7−561∇8−⋯)yn+1(6.16) h2yn′′=(∇2+∇3+1211∇4+65∇5+180137∇6+107∇7+560363∇8+⋯)yn(6.17) =(∇2−121∇4−121∇5−18013∇6−18011∇7−56029∇8−⋯)yn+1.(6.18) For more details, the reader is referred to Interpolation and Allied Tables. The following examples illustrate the use of the formulae stated above.
In the preceding examples, the tabulated function is ex and hence it is easy to see that the error is considerably more in the case of the second derivatives. This is due to the reason that although the tabulated function and its approximating polynomial would agree at the set of data points, their slopes at these points may vary considerably. Numerical differentiation, is, therefore, an unsatisfactory process and should be used only in 'rare cases.' The next section will be devoted to a discussion of errors in the numerical differentiation formulae.
The numerical computation of derivatives involves two types of errors, viz. truncation errors and rounding errors. These are discussed below.
The truncation error is caused by replacing the tabulated function by means of an interpolating polynomial. This error can usually be estimated by formula (3.7). As noted earlier, this formula is of theoretical interest only, since, in practical computations, we usually do not have any information about the derivative y(n+1)(ξ). However, the truncation error in any numerical differentiation formula can easily be estimated in the following manner. Suppose that the tabulated function is such that its differences of a certain order are small and that the tabulated function is well approximated by the polynomial. (This means that the tabulated function does not have any rapidly varying components.) We know that 2ε is the total absolute error in the values of Δyi, 4ε in the values of Δ2yi, etc., where ε is the absolute error in the values of yi. Consider now, for example, Stirling's formula (6.9). This can be written in the form [dxdy]x=x0=2hΔy−1+Δy0+T1=2hy1−y−1+T1,(6.19) where T1, the truncation error, is given by T1=6h12Δ3y−2+Δ3y−1.(6.20) Similarly, formula (6.10) can be written as [dx2d2y]x=x0=h21Δ2y−1+T2,(6.21) where T2=12h21∣Δ4y−2∣.(6.22) The rounding error, on the other hand, is inversely proportional to h in the case of first derivatives, inversely proportional to h2 in the case of second
derivatives, and so on. Thus, rounding error increases as h decreases. Considering again Stirling's formula in the form of Eq. (6.19), the rounding error does not exceed 2ε/2h=ε/h, where ε is the maximum error in the value of yi. On the other hand, the formula [dxdy]x=x0=2hΔy−1+Δy0−12hΔ3y−2+Δ3y−1+⋯ =12hy−2−8y−1+8y1−y2+⋯(6.23) has the maximum rounding error 12h18ε=2h3ε. Finally, the formula [dx2d2y]x=x0=h2Δ2y−1+⋯=h2y−1−2y0+y1+⋯(6.24) has the maximum rounding error 4ε/h2. It is clear that in the case of higher derivatives, the rounding error increases rather rapidly.
The cubic spline derived in Section 5.2 can conveniently be used to compute the first and second derivatives of a function. For a natural cubic spline, the recurrence formulae (5.31) or (5.32) may be used to compute the spline second derivatives depending upon the choice of the subdivisions. Then Eq. (5.29) gives the spline in the interval of interest, from which the first derivatives can be computed. For the first derivatives at the tabular points, it would, of course, be easier to use formulae (5.28) and (5.30) directly. If, on the other hand, end conditions involving the first derivatives are given, then recurrence formulae (5.34) or (5.36) may be used to compute the remaining first derivatives. The following examples illustrate the use of the spline formulae in numerical differentiation.
In Section 6.2, we developed forward, backward and central difference approximations of derivatives in terms of finite differences. From the computational point of view, it would be convenient to express the numerical differentiation formulae in terms of function values. We list below some differentiation formulae for use in numerical computations.
(i) Forward Differences y′(xi)=hyi+1−yi;y′(xi)=2h−yi+2+4yi+1−3yi+O(h2) y′′(xi)=h2yi−2yi+1+yi+2;y′′(xi)=h2−yi+3+4yi+2−5yi+1+2yi;
(ii) Backward Differences y′(xi)=hyi−yi−1;y′(xi)=2h3yi−4yi−1+yi−2; y′′(xi)=h2yi−2yi−1+yi−2;y′′(xi)=h22yi−5yi−1+4yi−2−yi−3;
(iii) Central Differences y′(xi)=2hyi+1−yi−1;y′(xi)=12h−yi+2+8yi+1−8yi−1+yi−2; y′′(xi)=h2yi−1−2yi+yi+1; y′′(xi)=12h2−yi+2+16yi+1−30yi+16yi−1−yi−2 These formulae can be derived by using Taylor series expansion of the functions.