c5-10 (779494)
Текст из файла
5.10 Polynomial Approximation from Chebyshev Coefficients1975.10 Polynomial Approximation fromChebyshev Coefficientsf(x) ≈m−1Xgk xk(5.10.1)k=0Yes, you can do this (and we will give you the algorithm to do it), but wecaution you against it: Evaluating equation (5.10.1), where the coefficient g’s reflectan underlying Chebyshev approximation, usually requires more significant figuresthan evaluation of the Chebyshev sum directly (as by chebev). This is becausethe Chebyshev polynomials themselves exhibit a rather delicate cancellation: Theleading coefficient of Tn (x), for example, is 2n−1 ; other coefficients of Tn (x) areeven bigger; yet they all manage to combine into a polynomial that lies between ±1.Only when m is no larger than 7 or 8 should you contemplate writing a Chebyshevfit as a direct polynomial, and even in those cases you should be willing to toleratetwo or so significant figures less accuracy than the roundoff limit of your machine.You get the g’s in equation (5.10.1) from the c’s output from chebft (suitablytruncated at a modest value of m) by calling in sequence the following two procedures:#include "nrutil.h"void chebpc(float c[], float d[], int n)Chebyshev polynomial coefficients.
Given a coefficient array c[0..n-1], this routine generatesPPn-1ka coefficient array d[0..n-1] such that n-1k=0 dk y =k=0 ck Tk (y) − c0 /2. The methodis Clenshaw’s recurrence (5.8.11), but now applied algebraically rather than arithmetically.{int k,j;float sv,*dd;dd=vector(0,n-1);for (j=0;j<n;j++) d[j]=dd[j]=0.0;d[0]=c[n-1];for (j=n-2;j>=1;j--) {for (k=n-j;k>=1;k--) {sv=d[k];d[k]=2.0*d[k-1]-dd[k];dd[k]=sv;}sv=d[0];d[0] = -dd[0]+c[j];dd[0]=sv;}for (j=n-1;j>=1;j--)d[j]=d[j-1]-dd[j];d[0] = -dd[0]+0.5*c[0];free_vector(dd,0,n-1);}Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use.
Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).You may well ask after reading the preceding two sections, “Must I store andevaluate my Chebyshev approximation as an array of Chebyshev coefficients for atransformed variable y? Can’t I convert the ck ’s into actual polynomial coefficientsin the original variable x and have an approximation of the following form?”198Chapter 5.Evaluation of Functionscnst=2.0/(b-a);fac=cnst;for (j=1;j<n;j++) {First we rescale by the factor const...d[j] *= fac;fac *= cnst;}cnst=0.5*(a+b);...which is then redefined as the desired shift.for (j=0;j<=n-2;j++)We accomplish the shift by synthetic division.
Syntheticfor (k=n-2;k>=j;k--)division is a miracle of high-school algebra. If youd[k] -= cnst*d[k+1];never learned it, go do so. You won’t be sorry.}CITED REFERENCES AND FURTHER READING:Acton, F.S. 1970, Numerical Methods That Work; 1990, corrected edition (Washington: Mathematical Association of America), pp. 59, 182–183 [synthetic division].5.11 Economization of Power SeriesOne particular application of Chebyshev methods, the economization of power series, isan occasionally useful technique, with a flavor of getting something for nothing.Suppose that you are already computing a function by the use of a convergent powerseries, for examplef (x) ≡ 1 −xx2x3+−+···3!5!7!(5.11.1)√ √(This function is actually sin( x)/ x, but pretend you don’t know that.) You might bedoing a problem that requires evaluating the series many times in some particular interval, say[0, (2π)2 ].
Everything is fine, except that the series requires a large number of terms beforeits error (approximated by the first neglected term, say) is tolerable. In our example, withx = (2π)2 , the first term smaller than 10−7 is x13 /(27!). This then approximates the errorof the finite series whose last term is x12 /(25!).Notice that because of the large exponent in x13 , the error is much smaller than 10−7everywhere in the interval except at the very largest values of x.
This is the feature that allows“economization”: if we are willing to let the error elsewhere in the interval rise to about thesame value that the first neglected term has at the extreme end of the interval, then we canreplace the 13-term series by one that is significantly shorter.Here are the steps for doing so:1.
Change variables from x to y, as in equation (5.8.10), to map the x interval into−1 ≤ y ≤ 1.2. Find the coefficients of the Chebyshev sum (like equation 5.8.8) that exactly equals yourtruncated power series (the one with enough terms for accuracy).3. Truncate this Chebyshev series to a smaller number of terms, using the coefficient of thefirst neglected Chebyshev polynomial as an estimate of the error.Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use.
Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).void pcshft(float a, float b, float d[], int n)Polynomial coefficient shift. Given a coefficient array d[0..n-1], this routine generates aPPn-1kkcoefficient array g [0..n-1] such that n-1k=0 dk y =k=0 gk x , where x and y are relatedby (5.8.10), i.e., the interval −1 < y < 1 is mapped to the interval a < x < b. The arrayg is returned in d.{int k,j;float fac,cnst;.
Характеристики
Тип файла PDF
PDF-формат наиболее широко используется для просмотра любого типа файлов на любом устройстве. В него можно сохранить документ, таблицы, презентацию, текст, чертежи, вычисления, графики и всё остальное, что можно показать на экране любого устройства. Именно его лучше всего использовать для печати.
Например, если Вам нужно распечатать чертёж из автокада, Вы сохраните чертёж на флешку, но будет ли автокад в пункте печати? А если будет, то нужная версия с нужными библиотеками? Именно для этого и нужен формат PDF - в нём точно будет показано верно вне зависимости от того, в какой программе создали PDF-файл и есть ли нужная программа для его просмотра.















