0% found this document useful (0 votes)
56 views

Fornberg

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Fornberg

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Generation of Finite Difference Formulas on Arbitrarily Spaced Grids

Author(s): Bengt Fornberg


Source: Mathematics of Computation, Vol. 51, No. 184 (Oct., 1988), pp. 699-706
Published by: American Mathematical Society
Stable URL: http://www.jstor.org/stable/2008770
Accessed: 02/09/2008 18:07

Your use of the JSTOR archive indicates your acceptance of JSTOR's Terms and Conditions of Use, available at
http://www.jstor.org/page/info/about/policies/terms.jsp. JSTOR's Terms and Conditions of Use provides, in part, that unless
you have obtained prior permission, you may not download an entire issue of a journal or multiple copies of articles, and you
may use content in the JSTOR archive only for your personal, non-commercial use.

Please contact the publisher regarding any further use of this work. Publisher contact information may be obtained at
http://www.jstor.org/action/showPublisher?publisherCode=ams.

Each copy of any part of a JSTOR transmission must contain the same copyright notice that appears on the screen or printed
page of such transmission.

JSTOR is a not-for-profit organization founded in 1995 to build trusted digital archives for scholarship. We work with the
scholarly community to preserve their work and the materials they rely upon, and to build a common research platform that
promotes the discovery and use of these resources. For more information about JSTOR, please contact [email protected].

http://www.jstor.org
MATHEMATICS OF COMPUTATION
VOLUME 51, NUMBER 184
OCTOBER 1988, PAGES 699-706

Generationof Finite DifferenceFormulas


on ArbitrarilySpacedGrids
By Bengt Fornberg

Abstract. Simple recursions are derived for calculating the weights in compact finite
difference formulas for any order of derivative and to any order of accuracy on one-
dimensional grids with arbitraryspacing. Tables are included for some special cases (of
equispaced grids).

1. Introduction. Previouslypublishedmethods to generate finite difference


weights (e.g., references[1]-[5]) have been of considerablecomplexity and often
been limited to derivativesof low order on equidistantlyspaced grids. The most
ambitiousattempt to tabulate weights for many ordersof derivativesand to high
orders of accuracy appears to be the work by Keller and Pereyra [4]. However,
their algorithms(limitedto equispacedgrids)werevery involved,and the resulting
tables contain both isolated and systematic errors.
In the present study we describetwo simple recursionrelationswhich give the
weights for any order of derivative (including the 0th derivative, corresponding
to interpolation),approximatedto any order of accuracyon an arbitrarygrid in
one dimension. Since, in general, only four arithmetic operationsare needed to
determineeach weight, the main anticipatedapplicationof the presentmethod is
to dynamicallychanginggrids. However,the method is also well suited to generate
tables of weights. Such tables (in the special case of equispacedgrids,up to the 4th
derivativeand up to 9 weights) are includedin the cases of one-sidedand centered
approximationsat a grid point and at a 'half-waypoint' betweengrid points.

2. Notation, Algorithm. GivenM > 0, the orderof the highestderivativewe


wish to approximate,and a set of N + 1 grid points (at x-coordinatesao, . ,N;
N > 0), the problemis to find all the weights such that the approximations

dmft n
dzmf O.
e11
E bnL}f (avz)I m= 1 . .., M; n-m,m +1, . .., N.
dx
=Xo IJ=O

becomeof optimal formalorderof accuracy(in generalof ordern - m + 1, although


it can be higher in special cases). The followingalgorithmachievesthis:

Received May 20, 1987; revised December 28, 1987.


1980 Mathematics Subject Classification (1985 Revision). Primary 65D25.
Key words and phrases.Finite differencecoefficients, high-orderaccuracy.
01988 American Mathematical Society
0025-5718/88 $1.00 + $.25 per page

699
700 BENGT FORNBERG

Enter M, N, Xo, cO,& 1,i 2,.. aN

for n:= 1 to N do
c2 := 1
for v := 0 to n - 1 do
c3 :an- av
c2 c2 c3
if n < M then 6nn-,,v := 0
for m := 0 to min(n, M) do
6nV= ((an - XO)6nm, -
m6n`Lj1v,)/c3
next m
next v
for m := 0 to min(n, M) do
6mn := (M n-i ( an-1 - )6n'1,n-)
nfl c2 "n-l,n-1 k-f- O-n1n1
next m
cl := c2
next n
Notes. 1. If the array 6m initially is zero, the statement "if n < M then
6nn-,o := f0"can be omitted.
2. In the case of m = 0 (corresponding to interpolation formulas), expressions
of the form 'zero*(undefined number)' occur. The result is assumed to be zero.
3. The order in which the a., (all distinct) are given is significant (since the
weights corresponding to all leading subsets of the &a,,'sare calculated). There is
no restriction on xo coinciding with any ao.
3. Derivation of the Algorithm. For simplicity, assume we seek to approx-
imate the derivatives at the point xo = 0. Let {&o, ai... ,
j} be distinct real
numbers and denote
n

(3.1) Jn(X) =1 rX (- ak)


k=O
The polynomial

(3.2) Fnv(x) Wn(c W)(x- &L,)

is the one of minimal degree which takes the value 1 at x = &al and 0 at x = ak,
0 < k < n, k :A v. For an arbitrary function f(x) and nodes x = a,, Lagrange's
interpolation polynomial becomes
n
(3.3) p(x) F
V=0

The desired weights express how the values of [dmp(x)/dxm]x0 vary with changes
in f(av). Since only one term in p(x) is influenced by changes in each f(av), we
find

(3.4) =
GENERATION OF FINITE DIFFERENCE FORMULAS 701

Therefore, the nth degree polynomial Fn,,(x) can also be expressed as

(3.5) Fnv(X) = E
m=0m
,Xm!

From (3.2) follow (noting that w(x) = (x - an)wnl(x) implies w (x) = (x -

an)n- 1 (X)+ Win-1(X))

(3.6) Fn,(x) = - Fan 1,>v(X)


av- afl

and

(3.7) Fnn(X) = 'I(n ) = (2(ani) (X -an-1)Fn-1,n-1(x) (n > 1).

By substituting the expansion (3.5) into (3.6) and (3.7), and by equating powers of
x, the desired recursion relations between the weights are obtained:
(3.8) 3m - 1 g -
m3-1,)

and
n-
(3.9) Wl 2(n n-it) (m6ml-1 A

The relation

(3.10) S { 0,

could be used instead of (3.9) to obtain 6nmn. However, this would increase the
operation count and might also cause a growth of errors in the case of floating-
point arithmetic.
4. Description of the Tables. Special cases which commonly occur are cen-
tered and one-sided approximations on equidistant grids. The particular choices of
a,, used for Tables 1-4 correspond to grid spacings Ax = 1. For other values of
Ax, these coefficients should be divided by (Ax)m (where m, as before, is the order
of the derivative).
702 BENGT FORNBERG

TABLE 1

Some weights for centered approximations at a grid point (generated by setting M =


4, N = 8, xo = 0 and al, = {O,1,-1, 2,-2,3,-3,4,-4}).

d
e
Or 0
d a r a Approximations at x = 0;
e a e c
r v r u x-coordinates at nodes:
ov
f e fy -4 -3 -2 -1 0 1 2 3 4
0 00 1
-
2
4212 00
280
1 -2 2 -1

1 6 6 -1 3 3
0~~~~ 3 -3 1

-4 -4 4 4
48 -1 1
~~~
~~12 43 0 3 --112 ~~ -1

2 1 -2 1
4 -1 4 -5 4 -1
2850 315 5 5 72 5 5 315 280
1 -3 3 -49 3 -3 1
6 903 2 20 90
2401 8 -1 8 -205 8 -1 8 -1
8 560 315 5 5 72 5 5 315 560

2 1 1 6 -1 1

4 4 6 8 2- 13 0 13 -1
~~~8 8 1 8
6 7 -169 61 -61 169 -3 7
240 10 120 15 300 120 10 240

2 1 -4 6 -4 1
4 4 -1
6 2 -13
2
28
3
-13
-2 22 -1
6
7 -2 169 -122 91 -122 169 -2 7
6 240 5 60 15 8 15 60 5 240
GENERATION OF FINITE DIFFERENCE FORMULAS 703

TABLE 2
Some weights for centered approximations at a 'half-way' point (generated by setting
M = 4, N = 7, x0 = 0 and ao, = {1/2, -1/2, 3/2, -3/2, 5/2, -5/2,7/2, -7/2}).

d
e
i a
d d Approximationsat x = 0;
e a e c
r t r u x-coordinates at nodes:
f e f y -7/2 -5/2 -3/2 -1/2 1/2 3/2 5/2 7/2

1 1
2
2 2
-1 9 9 -1
4
16 16 16 16
3 -25 75 75 -25 3
o 6 256 256 128 128 256 256
8 -5 49 -245 1225 1225 -245 49 -5
8 2048 2048 2048 2048 2048 2048 2048 2048

2 -1 1
4 1 -9 9 -1
24 8 8 24
1 6 -3 25 -75 75 -25 3
660 384 64 64 384 640
8 5 -49 245 -1225 1225 -245 49 -5
7168 5120 3072 1024 1024 3072 5120 7168

1 -1 -1 1
2
2 2 2 2
2 4 -5
48
13
16
-17
24
-17
24
13
16 48
5
259 -499 1299 -1891 -1891 1299 -499 259
6 11520 2304 1280 2304 2304 1280 2304 11520

2 -1 3 -3 1
3 4 1 -13 17 -17 13 -1
8 8 4 4 8 8
-37 499 -1299 1891 -1891 1299 -499 37
6 1920 1920 640 384 384 640 1920 1920

1 3 1 1 1
2
2 2 2 2
4 4 -7 59 -45 83 83 -45 59 -7
48 48 16 48 48 16 48 48
704 BENGT FORNBERG

TABLE 3

Some weights for one-sided approximations at a grid point (generated by setting


M = 4, N =8, xo = 0 and a, = {0,1,2,3,4,5,6,7,8}).

d
e
O r 0
a
d a d Approximations at x = 0;
rt r ur x-coordinates at nodes:
ov
f e f y 0 1 2 3 4 5 6 7 8
O oo~~~~1
1 -1 1
2 -3 2 -1

-11 -3 1
3 6 3 2 3
-25 4 -1
4 25
12 4 -3 43 4
-137 10 -5 1
5 5 -5

6 4 6 -15 20 -15 6 -1
20 2 3 4 5 6
7 -363 7 -21 35 -35 21 -7 1
140 2 3 4 5 6 7
8 -760 56 -35 2 565 -14 3 87 -1
280-41 8
8314 - 8

1 1 -2 1
2 2 -5 4 -1
35 -26 19 -14 11
12 3 2 3 12
2 4 15
4
-776 107
6 -
13 612
12
6
6
5 203 -87 117 -254 33 -27 137
45 5 4 9 2 5 180
6 469 -223 879 -949 41 -201 1019 -7
90 10 20 18 10 180 10
29531 -962 621 -4006 691 -282 2143 -206 363
7 5040 35 10 45 8 5 90 35 560

1 -1 3 -3 1
2 5 9 -12 7 3
2 ~~~~~~~~~~2
-17 71 -59 49 -41 7
4 4 2 2 4 4
3 4 49
8 29 -4618 62 -3078 13 -18
-967 638 -3929 389 -2545 268 -1849 29
120 15 40 3 24 5 120 15
-801 349 -18353 2391 -1457 4891 -561 527 -469
6 80 6 120 10 6 30 8 30 240

1 1 -4 6 -4 1
2 3 -14 26 -24 11 -2
4 3 35
6 -31 137
2
-242
~~~~3 107
2 -19 17
6
28 -111 -1219 -185 82 -7
4 142 76 176
3 2 12 6 2 3~ 2
1069 -1316 15289 -2144 10993 -4772 2803 -536 967
15 1 80 15 60 5 24 15 20 15 240
GENERATION OF FINITE DIFFERENCE FORMULAS 705

TABLE 4
Some weights for one-sided approximations at a 'half-way' point (generated by set-
ting M=4, N=8, xo=0 and ao ={-1/2, 1/2, 3/2, 5/2, 7/2, 9/2, 11/2, 13/2, 15/2}).
d
Oe O
r ra x
d va d C Approximations at = 0;
e a e c
r t r u x-coordinates at nodes:
v
e f y -1/2 1/2 3/2 5/2 7/2 9/2 11/2 13/2 15/2
1 1
1 1
2 2 2 2
3 -1
3 8S3 4 8
15 -5 1
4 15
16 16 16 16
n
u 5
~~~~35 35
32
-35 7 -5
128 64 32 128
6 6 63 315 -105 63 .-45 7
256 256 128 128 256 256
231 693 -1155 231 -495 77 -21
1024 512 1024 256 1024 512 1024
429 3003 -3003 3003 -2145 1001 -273 33
8 2048 2048 2048 2048 2048 2048 2048 2048
6435 6435 -15015 9009 -32175 5005 -4095 495 -429
32768 4096 8192 4096 16384 4096 8192 4096 32768
2 -1 1
-23 7 1 -1
3 24 8 8 24
4 -11 17 3 -5 1
12 24 8 24 24
5 -563 67 143 -37 29 -71
640 128 192 64 128 1920
6 6 -1627 211 59 -235 91 -443 31
1920 640 48 192 128 1920 960
-88069 2021 28009 -6803 5227 -12673 3539 -3043
107520 15360 15360 3072 3072 15360 15360 107520
8 -1423 -491 7753 -18509 3535 -2279 953 -1637 2689
1792 7168 3072 5120 1024 1024 1024 7168 107520
1 1 -2 1
2 3 -7 5 -1
2 2 2 2
43 -14 17 -5 7
3-4 3 4 3 24
4 95 -269 49 -85 59 -3
48 48 8 24 48 16
12139 -6119 3091 -1759 1211 -919 739
5 5760 960 384 288 384 960 5760
25333 -80813 2553 -21457 14651 -3687 8863 -211
6 11520 11520 256 2304 2304 1280 11520 2304
81227 -67681 34151 -16747 5669 -76621 1699 -5647 21719
35840 8960 2880 1280 512 11520 640 8960 322560

1 -1 3 -3 1
2 -2 7 -9 5 -1
-23 91 -71 55 -43 7
3 8 8 4 4 8 8
3 3 4 -2929 12
127
-29
115 -133
8 43
8 -3
4
4
-8197 39139 -27219 19699 -15043 12099 -10099 1237
1920 1920 640 384 384 640 1920 1920
-2317 47707 -7443 158471 -30037 32091 -40087 1961 -357
6 480 1920 128 1920 384 640 1920 384 640

1 1 -4 6 -4 1
5 -23 17 -3
2 2 2 21 -19 2t 2
4 ~ 101 -87 373 -319 273 -47 41
24 4 8 6 8 4 24
287 -1639 1341 -5527 4613 -783 677 -85
48 48 16 48 48 16 48 48
14861 -1447 21299 -25651 42119 -2951 30437 -1903 1127
1920 30 160 120 192 20 480 120 640
706 BENGT FORNBERG

Acknowledgment. The comments of the referee have been most helpful in


generalizing and simplifying the present algorithm.

Exxon Researchand EngineeringCompany


Annandale,New Jersey 08801
Mail: [email protected]

1. M. ABRAMOWITZ & I. A. STEGUN, Handbookof MathematicalFunctions,National Bureau


of Standards, Appl. Math. Series, no. 55, Washington,D. C., 1964.
2. S. J. CYNAR, "UsingGaussianelimination for computation of the central difference equation
coeficients,"SIGNUM Newsl. (USA), v. 22, 1987, pp. 12-19.
3. B. FORNBERG, "On a Fourier method for the integration of hyperbolic equations," SIAM
J. Numer. Anal., v. 12, 1975, pp. 509-528.
4. H. B. KELLER & V. PEREYRA, "Symbolic generation of finite difference formulas," Math.
Comp., v. 32, 1978, pp. 955-971.
5. W. D. LAKIN, "Differentiating matrices for arbitrarily spaced grid points," Internat. J.
Numer. Methods Engrg., v. 23, 1986, pp. 209-218.

You might also like