New finite difference formulas for numerical differentiation - CiteSeerX [PDF]

Introduction. Numerical methods are widely used for the numerical differentiation of the functions, which are di cult to

10 downloads 6 Views 83KB Size

Recommend Stories


Numerical Differentiation
Everything in the universe is within you. Ask all from yourself. Rumi

Numerical Differentiation
Kindness, like a boomerang, always returns. Unknown

or Finite difference Thermal
Ask yourself: Am I being calm and centered in challenging situations? What do I need to do to have more

Finite Element and Finite Difference Numerical Simulation Comparison for Air Pollution Emission
Be like the sun for grace and mercy. Be like the night to cover others' faults. Be like running water

Finite Difference Calculus
Sorrow prepares you for joy. It violently sweeps everything out of your house, so that new joy can find

Viscoelastic Finite Difference Modeling
Seek knowledge from cradle to the grave. Prophet Muhammad (Peace be upon him)

Finite Difference Schemes for Long-Time Integration
If you want to go quickly, go alone. If you want to go far, go together. African proverb

The Finite Difference Method for Elliptic Problems
You often feel tired, not because you've done too much, but because you've done too little of what sparks

Finite difference methods for wave equations
You have survived, EVERY SINGLE bad day so far. Anonymous

Adaptive Numerical Differentiation
Every block of stone has a statue inside it and it is the task of the sculptor to discover it. Mich

Idea Transcript


Journal of Computational and Applied Mathematics 126 (2000) 269–276 www.elsevier.nl/locate/cam

New nite di erence formulas for numerical di erentiation Ishtiaq Rasool Khan ∗ , Ryoji Ohba Division of Applied Physics, Graduate School of Engineering, Hokkaido University, Sapporo 060-8628, Japan Received 16 March 1999; received in revised form 23 October 1999

Abstract Conventional numerical di erentiation formulas based on interpolating polynomials, operators and lozenge diagrams can be simpli ed to one of the nite di erence approximations based on Taylor series, and closed-form expressions of these nite di erence formulas have already been presented. In this paper, we present new nite di erence formulas, which are more accurate than the available ones, especially for the oscillating functions having frequency components near the Nyquist frequency. Closed-form expressions of the new formulas are given for arbitrary order. A comparison of the previously available three types of approximations is given with the presented formulas. A computer program written in MATHEMATICA, based on new formulas is given in the appendix for numerical di erentiation of a function at a c 2000 Elsevier Science B.V. All rights reserved. speci ed mesh point. Keywords: Finite di erence formulas; Numerical di erentiation; Taylor series; Closed-form expressions

0. Introduction Numerical methods are widely used for the numerical di erentiation of the functions, which are dicult to di erentiate analytically, and for nding the derivative of the sampled data for which the generating function is not known. Numerical di erentiation formulas are generally obtained from the Taylor series, and are classi ed as forward, backward and central di erence formulas, based on the pattern of the samples used in calculation [1,3–5,7,10]. Forward di erence approximations use the samples at a mesh point and next (forward) equally spaced points of analysis, for calculating the derivative at the mesh point. In contrast, backward di erence approximations use the samples at a mesh point and the previous (backward) equally spaced points, whereas central di erence approximations use both forward and backward samples in calculating the derivative at the speci ed mesh point. Some other numerical di erentiation techniques like exponential tting and minimal phase lag can be found in [12–28]. ∗

Corresponding author. Tel.: +81-11-706-6628; fax: +81-11-706-7883. E-mail address: [email protected] (I.R. Khan) c 2000 Elsevier Science B.V. All rights reserved. 0377-0427/00/$ - see front matter PII: S 0 3 7 7 - 0 4 2 7 ( 9 9 ) 0 0 3 5 8 - 1

270

I.R. Khan, R. Ohba / Journal of Computational and Applied Mathematics 126 (2000) 269–276

A nite di erence approximation using N samples is said to be of order N and gives the derivative at the mesh point with an error of the order of T N =N !, where T is the sampling period. The error reduces generally for higher values of N, and hence the approximations of higher orders are desirable for accurate results. A nite di erence approximation of order N is usually obtained by solving N equations obtained directly from Taylor series or by the method of indeterminate coecients [5,6]. In [8], we presented closed-form expressions of these nite di erence approximations, which can give an approximation of arbitrary order, without any need to solve equations. Therefore with these three (in fact two, because coecients of forward and backward di erence approximations di er only by sign) closed-form formulas, there does not remain any need to remember coecients of long formulas for higher orders. In addition, the equivalent forms, based on interpolating polynomials like Lagrangian, Bessel, Newton–Gregory, Gauss and Sterling interpolating polynomials [1,3–5,7,10], operators [4] and lozenge diagrams [5], which were used due to complexity in deriving higher-order nite di erence formulas are no more needed. Of the nite di erence formulas, central di erence formulas are more accurate, especially for the oscillating functions and periodic functions [8]. In addition, central di erence approximations do not induce any nonlinearity in the phase of the di erentiated data. However, if the maximum frequency of the di erentiated function is close to the Nyquist frequency (half of the sampling frequency), the error for the central di erence approximation is also quite high. In this paper, we present new nite di erence approximations, which are as accurate as the available formulas for polynomials and are much accurate for oscillating functions, especially for high frequencies near the Nyquist frequency. Like central di erence approximations, these do not introduce any nonlinearity in the phase of the di erentiated signal. We present the closed-form expressions of these approximations for arbitrary order, and therefore they can be generated for very high order (and consequently of very high accuracy) very easily even by the use of a simple calculator. 1. Derivation based on Taylor series Taylor formula gives the expansion of a function f(t) analytic at t = t0 in the form of following power series: f(t) =

∞ X (t − t0 )i i=0

i!

f(i) (t0 );

(1)

where f(i) (t0 ) denotes the ith derivative of f(t) at t = t0 . Using this formula, we can de ne the value of the function at any point, in terms of the value of the function and its derivatives at a mesh point. Let us take t0 = 0 as the mesh point, and sample the function f(t) at equally spaced points t = kT; where k = ± 12 ; ± 32 ; ± 52 ; : : : ; ±(2n − 1)=2; n is an integer and T is the sampling period. The values of the function at t = kT , denoted by fk can be expressed as fk =f0 +kTf0(1) +

(kT )2 (2) (kT )2n (2n) f0 + · · · + f +O(T 2n+1 ); 2! (2n)! 0

k= ± 12 ; ± 32 ; : : : ; ±(2n − 1)=2:

(2)

The error term O(T 2n+1 ) is of the order of T 2n+1 =(2n + 1)! and contains the derivative terms of the order above 2n. This term is neglected while deriving all the nite di erence formulas and its value

I.R. Khan, R. Ohba / Journal of Computational and Applied Mathematics 126 (2000) 269–276

271

gets smaller as the value of T is reduced or n is increased. Eq. (2) can be written in matrix form as F = A · D + O(T 2n+1 );

(3)

where F and D are the vectors of length 2n, A is a 2n × 2n square matrix, and these are de ned as F = [f1=2 − f0 D = [f0(1) 

f0(2)

f−1=2 − f0 : : : f(2n−1)=2 − f0

f−(2n−1)=2 − f0 ]T ;

f0(3) : : : f0(2n) ]T ;

T=2 −T=2 .. .

   A=    (2n − 1)T=2

(T=2)2 =2! (−T=2)2 =2!

((2n − 1)T=2)2 =2! −(2n − 1)T=2 (−(2n − 1)T=2)2 =2!

···



(T=2)2n =(2n)! (−T=2)2n =(2n)!

   :   ((2n − 1)T=2)2n =(2n)! 

(−(2n − 1)T=2)2n =(2n)!

From the set of equations described by Eq. (3), the rst derivative at the mesh point, f0(1) can be written as

f0(1)

f −f (T=2)2 =2! ··· (T=2)2n =(2n)! 1=2 0 f 2 2n (−T=2) =2! (−T=2) =(2n)! −1=2 − f0 .. . 2n f(2n−1)=2 − f0 ((2n − 1)T=2)2 =2! ((2n − 1)T=2) =(2n)! f−(2n−1)=2 − f0 (−(2n − 1)T=2)2 =2! (−(2n − 1)T=2)2n =(2n)! ≈ T=2 (T=2)2 =2! ··· (T=2)2n =(2n)! 2 2n −T=2 (T=2) =2! (−T=2) =(2n)! .. . 2 2n (2n − 1)T=2 ((2n − 1)T=2) =2! ((2n − 1)T=2) =(2n)! −(2n − 1)T=2 (−(2n − 1)T=2)2 =2! (−(2n − 1)T=2)2n =(2n)!

(4)

The ≈ sign appears as we have neglected O(T 2n+1 ) in Eq. (3). We calculated the denominator in Eq. (4) for di erent values of n, and found that its value for T = 1 can be expressed as |A|T =1 =

(2n − 1)!!2 : 22n (2n)!

It can also be noted that only rst columns in numerator and denominator di er in the powers of T. Therefore, Eq. (4) can be simpli ed as

f0(1)

f −f (1=2)2 =2! 1=2 0 f (−1=2)2 =2! −1=2 − f0 2 (2n − 1)!! .. ≈ 2n . 2 (2n)!T f(2n−1)=2 − f0 ((2n − 1)=2)2 =2! f−(2n−1)=2 − f0 (−(2n − 1)=2)2 =2!

···

: 2n ((2n − 1)=2) =(2n)! (−(2n − 1)=2)2n =(2n)!

(1=2)2n =(2n)! (−1=2)2n =(2n)!

(5)

272

I.R. Khan, R. Ohba / Journal of Computational and Applied Mathematics 126 (2000) 269–276

Eq. (5) gives a nite di erence approximation of order 2n of derivative of the function at t = 0 and has an error of the order of T 2n=(2n)! . The approximations for di erent values of n are listed below. 1 (f1=2 − f1=2 ) + O(T 2 ); T   1 9(f12 − f−1=2 ) (f3=2 − f−3=2 ) f0(1) = − + O(T 4 ); T 8 24 f0(1) =

f0(1) =

1 T

f0(1) =

1 T

 

75(f1=2 − f−1=2 ) 25(f3=2 − f−3=2 ) 3(f5=2 − f−5=2 ) − + 64 384 640



+ O(T 6 );

1225(f1=2 − f−1=2 ) 245(f3=2 − f−3=2 ) 49(f5=2 − f−5=2 ) 5(f7=2 − f−7=2 ) − + − 1024 3072 5120 7168



+O(T 8 ); It can be noted that as the order of the approximation increases, the coecients of the terms become complicated. Observing the approximations of di erent orders, we found, almost accidentally, that the coecients follow a certain pattern, and Eq. (5) can be written in a closed form as f0(1) =

n 1X g(2k−1)=2 (f(2k−1)=2 − f−(2k−1)=2 ) T k=0

(6)

and at an arbitrary point t = iT , we may write fi(1) =

n 1X g(2k−1)=2 (f(2k−1)=2+i − f−(2k−1)=2−i ): T k=0

(7)

The coecients g in Eqs. (6) and (7) are de ned as g(2k−1)=2 =

(−1)k+1 (2n − 1)!!2 ; 22n−2 (n + k − 1)!(n − k)!(2k − 1)2

k = 1; 2; 3; : : : ; n;

(8)

where double factorial of an integer m is given as m!! = m(m − 2)(m − 4) : : : (¿ 0). In order to increase the computation eciency, the coecients in Eq. (8) can be calculated in the following iterative way: g1=2 =

(2n − 1)!!2 ; 22n−2 n!(n − 1)!

(n − k + 1)(2k − 3)2 g(2k−3)=2 ; g(2k−1)=2 = − (n + k − 1)(2k − 1)2

(9) k = 2; 3 : : : ; n:

It must be noted that coecient of f0 is zero and coecients gi of forward terms di er from those g−i of corresponding backward terms only by sign, therefore the sum of all the coecients is zero. This satis es the basic condition of a di erentiation operation, that the derivative of a constant is zero.

I.R. Khan, R. Ohba / Journal of Computational and Applied Mathematics 126 (2000) 269–276

273

Table 1 Errors in di erentiation of example functions with new and central di erence formulas for di erent orders using di erent sampling periods Function

Order = 6 T = 10

t − t6 t7 e−t e−100t sin(t) sin(100t) sin(400t) sin(500t) Sin(1000t)

Order = 10

−3

T = 10

−6

T = 10−3

T = 10−6

N

C

N

C

N

C

N

C

0 3:5E − 18 7E − 20 6:8E − 5 6:7E − 17 6:6E − 5 0.23 0.78 21

0 3:6E − 17 7:1E − 19 0.0007 6:9E − 16 0.0007 2.1 6.6 100

0 3:5E − 36 7E − 38 6:7E − 23 6:7E − 35 6:7E − 23 2:7E − 19 1E − 18 6:7E − 17

0 3:6E − 35 7:1E − 37 6:9E − 22 6:9E − 34 6:9E − 22 2:8E − 18 1:1E − 17 6:8E − 16

0 0 2:2E − 33 2:1E − 8 2E − 28 2E − 8 0.01 0.1 16.2

0 0 3:6E − 32 3:5E − 7 3:4E − 27 3:3E − 7 0.2 1.4 100

0 0 2:2E − 63 2E − 38 2E − 58 2E − 38 2:1E − 32 8:3E − 28 2E − 28

0 0 3:6E − 62 3:4E − 37 3:4E − 57 3:4E − 37 3:5E − 31 3:3E − 30 3:4E − 27

2. Comparison with other ÿnite di erence approximations A comparison of forward, backward and central di erence formulas was presented in [8]. It was observed that all the formulas were almost equally accurate (central di erence ones have a little higher accuracy) for the polynomial functions. However, for oscillating functions, which have the frequency components closer to the Nyquist frequency, central di erence approximations were observed to be more accurate. Moreover, the accuracy of central di erence approximations increases in general with order, however for oscillating or periodic functions having frequency beyond a certain limit, the accuracy of forward and backward di erence approximations decreases sharply for higher orders [8]. Therefore, central di erence approximations are the best choice among the available nite di erence formulas, if all of them can be applied in a certain situation. However, the new di erence formulas presented in the previous section are proved even more accurate than central di erence formulas. In this section, we give a comparison of the two by di erentiating some example functions and plotting their frequency responses. Table 1 shows the errors in di erentiation of di erent functions for two di erent sampling periods and orders, using central di erence and the new formulas. The columns headed by N and C show the errors by using new formulas and central di erence approximations, respectively. To minimize the round o error, calculations are carried out with 100 digits. Except in the rst two rows for polynomials, all the entries in the table give % errors. From rst two rows of the table, it can be noted that although both the new and the central di erence formulas are highly accurate for polynomial functions, the former has an edge over the latter. Both are very accurate for periodic and oscillating functions as well, when the maximum frequency of the function is well below the Nyquist frequency. The last four rows show however, that when the frequency of the function gets closer to the Nyquist frequency, central di erence approximations show large errors that increase to 100% in the worst case. In such case, the new formulas also have higher errors, but compared to central di erence formulas, they are still accurate. Both of the formulas are written in digital lter form, and their behavior can be more clearly understood by comparing their magnitude responses, i.e., absolute value of the discrete Fourier

274

I.R. Khan, R. Ohba / Journal of Computational and Applied Mathematics 126 (2000) 269–276

Fig. 1. Comparison of the magnitude responses of digital di erentiators based on central and new di erence approximations with ideal di erentiator for an order of 10.

transforms of the coecients, which are plotted in Fig. 1 for n = 10. Ideal magnitude response is also shown which increases linearly from 0 to 1, as the frequency changes from 0 to the Nyquist frequency fs =2, where fs is the sampling frequency [8]. Magnitude response of a central di erence approximation of any order becomes zero at the Nyquist frequency, having 100% deviation from the ideal value of one. New formulas also have a sharp increase in the deviation near the Nyquist frequency, however it is lower by many folds compared to that of central di erence formulas. This deviation is further reduced for the higher orders of the approximations, as it can be observed from Table 1. Coecients of both new and central di erence formulas are symmetric, therefore their phase responses are linear, and they do not induce any nonlinearity in the phase of the di erentiated function. Therefore, both of them can be used as nite impulse response (FIR) non-recursive linear phase digital di erentiators [11]. It was observed in [8], that central di erence formulas are in fact the same as the maximally linear type III di erentiators [2]. Implementation of new formulas as digital di erentiators and their comparison with other types of di erentiators is presented in [9]. It must be noted that forward and backward di erence approximations presented in [8] have non-symmetric coecients, whereas central di erence approximations and the new approximations presented in this paper have symmetric coecients. Therefore, for approximation of derivative at a mesh point, forward and backward di erence approximations need more function evaluations compared to central di erence and new approximations. For an order 2n, forward and backward di erence approximations require 2n + 1 multiplications and 2n − 1 additions, whereas central di erence and new approximations require n+1 multiplications and 2n−1 additions. Therefore, the time of computation of derivative at a speci ed mesh point using new approximations is the same as that for central di erence approximations, and less than that for forward and backward di erence approximations. A di erence between the implementation of central di erence and new formulas can be noted. Central di erence formulas use odd number of equally spaced samples and give the derivative at the central sampling point, whereas new formulas use even number of equally spaced samples and give the derivative at center of two central sampling points. Therefore, to obtain derivative at a certain mesh point with central di erence and new formulas, samples of the functions will have to be collected at di erent sets of points.

I.R. Khan, R. Ohba / Journal of Computational and Applied Mathematics 126 (2000) 269–276

275

3. Conclusions In this paper new nite di erence formulas are presented, which give more accurate numerical di erentiation of all types of functions than any other type of formulas. Especially, if the function to be di erentiated has components near the Nyquist frequency, new formulas are much more accurate than others. Closed-form expressions of these new di erence formulas are presented, which can give approximations of arbitrary order. A computer program, which executes the presented results, is also given. Appendix The computer program given here is written in MATHEMATICA. The commands in MATHEMATICA are very easy to understand because they are written just like the formulas and equations commonly used in mathematics. Therefore, anyone can transform it very easily in his/her preferred language. ( ∗ Input ∗ ) order=6; f = Sin[1000Pi t]; dt = 10∧ − 6; mp = 0;

( ∗ the function to be di erentiated ∗ ) ( ∗ sampling period ∗ ) ( ∗ mesh point ∗ )

( ∗ sampling ∗ ) n = Ceiling[order=2]; a=Table[f ; {t; mp − (2n − 1)=2∗ dt; mp + (2n − 1)=2∗ dt; dt}]; ( ∗ calculation of coecients ∗ ) g = Table[0; {n}]; g[[1]] = (2n − 1)!!∧ 2=2∧ (2n − 2)=n=(n − 1)!∧ 2; ( ∗ equation 9∗ ) For[k = 2; k ¡ = n; k + +; g[[k]] = −(n − k + 1)=(n + k − 1)(2k − 3) ∧ 2=(2k − 1) ∧ 2g[[k − 1]]]; g = Join[ − Reverse[g]; g]; ( ∗ output ∗ ) d = g:a=dt; Print[N[d]];

( ∗ equation 7∗ ) ( ∗ print numerical value ∗ )

References [1] [2] [3] [4] [5]

R.L. Burden, J.D. Faires, Numerical Analysis, 5th Edition, PWS-Kent Pub. Co., Boston, 1993. B. Carlsson, Maximum at digital di erentiators, Electron. Lett. 27 (8) (1991) 675–677. L. Collatz, The Numerical Treatment of Di erential Equations, 3rd Edition, Springer, Berlin, 1996. G. Dahlquist, A. Bjorck, Numerical Methods, Prentice-Hall, Englewood Cli s, NJ, 1974. C. Gerald, P.O. Wheatley, Applied Numerical Analysis, Addison-Wesley, Reading MA, 4th Edition, 1989.

276

I.R. Khan, R. Ohba / Journal of Computational and Applied Mathematics 126 (2000) 269–276

[6] R.W. Hamming, Numerical Methods for Scientists and Engineers, McGraw-Hill, New York, 1962. [7] F.B. Hildebrand, Introduction to Numerical Analysis, 2nd Edition, McGraw-Hill, New York 1974. [8] I.R. Khan, R. Ohba, Closed form expressions for the nite di erence approximations of rst and higher derivatives based on Taylor series, J. Comput. Appl. Math. 107 (1999) 179–193. [9] I.R. Khan, R. Ohba, A new design of full band di erentiators based on Taylor series, IEE Proceedings on Image, Vision and Signal Processing 146 (1999) 185–189. [10] E. Kreyzig, Advanced Engineering Mathematics, 7th Edition, Wiley, New York, 1994. [11] A.V. Oppenheim, R.W. Schafer, Discrete-Time Signal Processing, Prentice-Hall, Englewood Cli s, NJ, Inc., 1989. [12] T.E. Simos, A four-step method for the numerical solution of the Schrodinger equation, J. Comput. Appl. Math. 30 (1990) 251–255. [13] T.E. Simos, A two-step method with phase-lag of order in nity for the numerical integration of second order periodic initial-value problems, Internat. J. Comput. Math. 39 (1991) 135–140. [14] T.E. Simos, some new four-step step exponential tting methods for the numerical solution of the radial Schrodinger equation, IMA J. Numer. Anal. 11 (1991) 347–356. [15] T.E. Simos, Exponentially tted methods for the numerical integration of the Schrodinger equation, Comput. Phys. Commun. 71 (1992) 32–38. [16] T.E. Simos, Two-step almost P-stable complete in phase methods for the numerical integration of second order periodic initial-value problems, Internat J. Comput. Math. 46 (1992) 77–85. [17] T.E. Simos, An explicit four-step phase- tted method for the numerical integration of second order initial-value problems, J. Comput. Appl. Math. 55 (1994) 125–133. [18] T.E. Simos, An eighth order method with minimal phase-lag for accurate computations for the elastic scattering phase shift problem, Internat. J. Mod. Phys. C 7 (1996) 825–835. [19] T.E. Simos, New P-stable high-order methods with minimal phase-lag for the numerical integration of the radial Schrodinger equation, Phys. Scripta 55 (1997) 644–650. [20] T.E. Simos, An exponentially tted method for the numerical solution of the Schrodinger equation, J. Chem. Inform. Comput. Sci. 37 (1997) 343–348. [21] T.E. Simos, Eighth order methods with minimal phase-lag for accurate computations for the elastic scattering phase-shift problem, J. Math. Chem. 21 (1997) 359–372. [22] T.E. Simos, High-algebraic, high phase-lag methods for accurate computations for the elastic-scattering phase shift problem, Canad. J. Phys. 76 (1998) 473–493. [23] T.E. Simos, An eighth order exponentially- tted method for the numerical integration of the Schrodinger equation, Comput. Chem. 22 (1998) 467–489. [24] T.E. Simos, An exponentially tted Runge–Kutta method for the numerical integration of initial value problems with periodic or oscillating solutions, Comput. Phys. Commun. 115 (1998) 1–8. [25] T.E. Simos, P-stable exponentially- tted methods for the numerical integration of the Schrodinger equation, J. Comput. Phys. 148 (1999) 305–321. [26] T.E. Simos, P.S. Williams, A family of Numerov-type exponentially tted methods for the numerical integration of the Schrodinger equation, Comput. Chem. 21 (1997) 403–417. [27] R.M. Thomas, T.E. Simos, G.V. Mitsou, A family of Numerov-type exponentially tted predictoe-corrector methods for the numerical integration of radial Schrodinger equation, J. Comput. Appl. Math. 67 (1996) 255–270. [28] R.M. Thomas, T.E. Simos, A family of hybrid exponentially tted predictor–corrector methods for the numerical integration of the radial Schrodinger equation, J. Comput. Appl. Math. 87 (1997) 215–226.

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.