Interpolation and Extrapolation part 2
lượt xem 4
download
Interpolation and Extrapolation part 2
f(x, y, z). Multidimensional interpolation is often accomplished by a sequence of onedimensional interpolations. We discuss this in §3.6.
Bình luận(0) Đăng nhập để gửi bình luận!
Nội dung Text: Interpolation and Extrapolation part 2
 108 Chapter 3. Interpolation and Extrapolation f(x, y, z). Multidimensional interpolation is often accomplished by a sequence of onedimensional interpolations. We discuss this in §3.6. CITED REFERENCES AND FURTHER READING: Abramowitz, M., and Stegun, I.A. 1964, Handbook of Mathematical Functions, Applied Mathe visit website http://www.nr.com or call 18008727423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America). readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMs Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machine Copyright (C) 19881992 by Cambridge University Press.Programs Copyright (C) 19881992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0521431085) matics Series, Volume 55 (Washington: National Bureau of Standards; reprinted 1968 by Dover Publications, New York), §25.2. Stoer, J., and Bulirsch, R. 1980, Introduction to Numerical Analysis (New York: SpringerVerlag), Chapter 2. Acton, F.S. 1970, Numerical Methods That Work; 1990, corrected edition (Washington: Mathe matical Association of America), Chapter 3. Kahaner, D., Moler, C., and Nash, S. 1989, Numerical Methods and Software (Englewood Cliffs, NJ: Prentice Hall), Chapter 4. Johnson, L.W., and Riess, R.D. 1982, Numerical Analysis, 2nd ed. (Reading, MA: Addison Wesley), Chapter 5. Ralston, A., and Rabinowitz, P. 1978, A First Course in Numerical Analysis, 2nd ed. (New York: McGrawHill), Chapter 3. Isaacson, E., and Keller, H.B. 1966, Analysis of Numerical Methods (New York: Wiley), Chapter 6. 3.1 Polynomial Interpolation and Extrapolation Through any two points there is a unique line. Through any three points, a unique quadratic. Et cetera. The interpolating polynomial of degree N − 1 through the N points y1 = f(x1 ), y2 = f(x2 ), . . . , yN = f(xN ) is given explicitly by Lagrange’s classical formula, (x − x2 )(x − x3 )...(x − xN ) (x − x1 )(x − x3 )...(x − xN ) P (x) = y1 + y2 (x1 − x2 )(x1 − x3 )...(x1 − xN ) (x2 − x1 )(x2 − x3 )...(x2 − xN ) (x − x1 )(x − x2 )...(x − xN−1 ) +···+ yN (xN − x1 )(xN − x2 )...(xN − xN−1 ) (3.1.1) There are N terms, each a polynomial of degree N − 1 and each constructed to be zero at all of the xi except one, at which it is constructed to be yi . It is not terribly wrong to implement the Lagrange formula straightforwardly, but it is not terribly right either. The resulting algorithm gives no error estimate, and it is also somewhat awkward to program. A much better algorithm (for constructing the same, unique, interpolating polynomial) is Neville’s algorithm, closely related to and sometimes confused with Aitken’s algorithm, the latter now considered obsolete. Let P1 be the value at x of the unique polynomial of degree zero (i.e., a constant) passing through the point (x1 , y1 ); so P1 = y1 . Likewise deﬁne P2 , P3 , . . . , PN . Now let P12 be the value at x of the unique polynomial of degree one passing through both (x1 , y1 ) and (x2 , y2 ). Likewise P23 , P34, . . . , P(N−1)N . Similarly, for higherorder polynomials, up to P123...N , which is the value of the unique interpolating polynomial through all N points, i.e., the desired answer.
 3.1 Polynomial Interpolation and Extrapolation 109 The various P ’s form a “tableau” with “ancestors” on the left leading to a single “descendant” at the extreme right. For example, with N = 4, x1 : y1 = P1 P12 x2 : y2 = P2 P123 visit website http://www.nr.com or call 18008727423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America). readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMs Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machine Copyright (C) 19881992 by Cambridge University Press.Programs Copyright (C) 19881992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0521431085) P23 P1234 (3.1.2) x3 : y3 = P3 P234 P34 x4 : y4 = P4 Neville’s algorithm is a recursive way of ﬁlling in the numbers in the tableau a column at a time, from left to right. It is based on the relationship between a “daughter” P and its two “parents,” (x − xi+m )Pi(i+1)...(i+m−1) + (xi − x)P(i+1)(i+2)...(i+m) Pi(i+1)...(i+m) = xi − xi+m (3.1.3) This recurrence works because the two parents already agree at points xi+1 . . . xi+m−1 . An improvement on the recurrence (3.1.3) is to keep track of the small differences between parents and daughters, namely to deﬁne (for m = 1, 2, . . . , N − 1), Cm,i ≡ Pi...(i+m) − Pi...(i+m−1) Dm,i ≡ Pi...(i+m) − P(i+1)...(i+m) . (3.1.4) Then one can easily derive from (3.1.3) the relations (xi+m+1 − x)(Cm,i+1 − Dm,i ) Dm+1,i = xi − xi+m+1 (3.1.5) (xi − x)(Cm,i+1 − Dm,i ) Cm+1,i = xi − xi+m+1 At each level m, the C’s and D’s are the corrections that make the interpolation one order higher. The ﬁnal answer P1...N is equal to the sum of any yi plus a set of C’s and/or D’s that form a path through the family tree to the rightmost daughter. Here is a routine for polynomial interpolation or extrapolation from N input points. Note that the input arrays are assumed to be unitoffset. If you have zerooffset arrays, remember to subtract 1 (see §1.2): #include #include "nrutil.h" void polint(float xa[], float ya[], int n, float x, float *y, float *dy) Given arrays xa[1..n] and ya[1..n], and given a value x, this routine returns a value y, and an error estimate dy. If P (x) is the polynomial of degree N − 1 such that P (xai ) = yai , i = 1, . . . , n, then the returned value y = P (x). { int i,m,ns=1; float den,dif,dift,ho,hp,w;
 110 Chapter 3. Interpolation and Extrapolation float *c,*d; dif=fabs(xxa[1]); c=vector(1,n); d=vector(1,n); for (i=1;i
 3.2 Rational Function Interpolation and Extrapolation 111 3.2 Rational Function Interpolation and Extrapolation Some functions are not well approximated by polynomials, but are well approximated by rational functions, that is quotients of polynomials. We de visit website http://www.nr.com or call 18008727423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America). readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMs Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machine Copyright (C) 19881992 by Cambridge University Press.Programs Copyright (C) 19881992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0521431085) note by Ri(i+1)...(i+m) a rational function passing through the m + 1 points (xi , yi ) . . . (xi+m , yi+m ). More explicitly, suppose Pµ (x) p 0 + p1 x + · · · + pµ x µ Ri(i+1)...(i+m) = = (3.2.1) Qν (x) q 0 + q 1 x + · · · + q ν xν Since there are µ + ν + 1 unknown p’s and q’s (q0 being arbitrary), we must have m+1 = µ+ν +1 (3.2.2) In specifying a rational function interpolating function, you must give the desired order of both the numerator and the denominator. Rational functions are sometimes superior to polynomials, roughly speaking, because of their ability to model functions with poles, that is, zeros of the denominator of equation (3.2.1). These poles might occur for real values of x, if the function to be interpolated itself has poles. More often, the function f(x) is ﬁnite for all ﬁnite real x, but has an analytic continuation with poles in the complex xplane. Such poles can themselves ruin a polynomial approximation, even one restricted to real values of x, just as they can ruin the convergence of an inﬁnite power series in x. If you draw a circle in the complex plane around your m tabulated points, then you should not expect polynomial interpolation to be good unless the nearest pole is rather far outside the circle. A rational function approximation, by contrast, will stay “good” as long as it has enough powers of x in its denominator to account for (cancel) any nearby poles. For the interpolation problem, a rational function is constructed so as to go through a chosen set of tabulated functional values. However, we should also mention in passing that rational function approximations can be used in analytic work. One sometimes constructs a rational function approximation by the criterion that the rational function of equation (3.2.1) itself have a power series expansion that agrees with the ﬁrst m + 1 terms of the power series expansion of the desired function f(x). This is called P ad´ approximation, and is discussed in §5.12. e Bulirsch and Stoer found an algorithm of the Neville type which performs rational function extrapolation on tabulated data. A tableau like that of equation (3.1.2) is constructed column by column, leading to a result and an error estimate. The BulirschStoer algorithm produces the socalled diagonal rational function, with the degrees of numerator and denominator equal (if m is even) or with the degree of the denominator larger by one (if m is odd, cf. equation 3.2.2 above). For the derivation of the algorithm, refer to [1]. The algorithm is summarized by a recurrence
CÓ THỂ BẠN MUỐN DOWNLOAD

Questions to .NET and Programming in C# Part 2: 101235
36 p  124  22

Microsoft WSH and VBScript Programming for the Absolute Beginner Part 2
10 p  60  15

Root Finding and Nonlinear Sets of Equations part 2
5 p  64  8

Interpolation and Extrapolation part 3
3 p  38  7

Interpolation and Extrapolation part 4
5 p  46  6

Interpolation and Extrapolation part 5
4 p  31  5

Interpolation and Extrapolation part 6
4 p  26  5

Practical prototype and scipt.aculo.us part 2
6 p  51  4

Interpolation and Extrapolation part 7
6 p  29  4

Faculty of Computer Science and Engineering Department of Computer Science Part 2
10 p  34  3

Interpolation and Extrapolation part 1
4 p  28  3

Ebook Basics of compiler design: Part 2
161 p  9  2

Ebook Data Structures and Algorithms Using C#: Part 2
162 p  13  1

Ebook Fundamentals of computer programming with C#: Part 2
624 p  1  0

Ebook Aircraft design projects for engineering students: Part 2
197 p  1  0

Ebook Objected oriented and classical software engineering (8th edition): Part 2
369 p  0  0

Ebook CMOS VLSI design  A circuits and systems perspective (4th edition): Part 2
514 p  0  0