c5-8 (779492), страница 2
Текст из файла (страница 2)
It is wasteful to call chebev withall the odd coefficients zero [1]. Instead, using the half-angle identity for the cosinein equation (5.8.1), we get the relation(5.8.12)Thus we can evaluate a series of even Chebyshev polynomials by calling chebevwith the even coefficients stored consecutively in the array c, but with the argumentx replaced by 2x2 − 1.An odd function will have an expansion involving only odd Chebysev polynomials.
It is best to rewrite it as an expansion for the function f(x)/x, whichinvolves only even Chebyshev polynomials. This will give accurate values forf(x)/x near x = 0. The coefficients c0n for f(x)/x can be found from those forf(x) by recurrence:c0N+1 = 0c0n−1 = 2cn − c0n+1 ,n = N, N − 2, . . .(5.8.13)Equation (5.8.13) follows from the recurrence relation in equation (5.8.2).If you insist on evaluating an odd Chebyshev series, the efficient way is to onceagain use chebev with x replaced by y = 2x2 − 1, and with the odd coefficientsstored consecutively in the array c.
Now, however, you must also change the lastformula in equation (5.8.11) to bef(x) = x[(2y − 1)d2 − d3 + c1 ](5.8.14)and change the corresponding line in chebev.CITED REFERENCES AND FURTHER READING:Clenshaw, C.W. 1962, Mathematical Tables, vol. 5, National Physical Laboratory, (London: H.M.Stationery Office). [1]Goodwin, E.T. (ed.) 1961, Modern Computing Methods, 2nd ed. (New York: Philosophical Library), Chapter 8.Dahlquist, G., and Bjorck, A. 1974, Numerical Methods (Englewood Cliffs, NJ: Prentice-Hall),§4.4.1, p.
104.Johnson, L.W., and Riess, R.D. 1982, Numerical Analysis, 2nd ed. (Reading, MA: AddisonWesley), §6.5.2, p. 334.Carnahan, B., Luther, H.A., and Wilkes, J.O. 1969, Applied Numerical Methods (New York:Wiley), §1.10, p. 39.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).T2n (x) = Tn (2x2 − 1)5.9 Derivatives or Integrals of a Chebyshev-approximated Function1955.9 Derivatives or Integrals of aChebyshev-approximated FunctionCi =ci−1 − ci+12(i − 1)c0i−1 = c0i+1 + 2(i − 1)ci(i > 1)(5.9.1)(i = m − 1, m − 2, .
. . , 2)(5.9.2)Equation (5.9.1) is augmented by an arbitrary choice of C0 , corresponding to anarbitrary constant of integration. Equation (5.9.2), which is a recurrence, is startedwith the values c0m = c0m−1 = 0, corresponding to no information about the m + 1stChebyshev coefficient of the original function f.Here are routines for implementing equations (5.9.1) and (5.9.2).void chder(float a, float b, float c[], float cder[], int n)Given a,b,c[0..n-1], as output from routine chebft §5.8, and given n, the desired degreeof approximation (length of c to be used), this routine returns the array cder[0..n-1], theChebyshev coefficients of the derivative of the function whose coefficients are c.{int j;float con;cder[n-1]=0.0;cder[n-2]=2*(n-1)*c[n-1];for (j=n-3;j>=0;j--)cder[j]=cder[j+2]+2*(j+1)*c[j+1];con=2.0/(b-a);for (j=0;j<n;j++)cder[j] *= con;n-1 and n-2 are special cases.Equation (5.9.2).Normalize to the interval b-a.}void chint(float a, float b, float c[], float cint[], int n)Given a,b,c[0..n-1], as output from routine chebft §5.8, and given n, the desired degreeof approximation (length of c to be used), this routine returns the array cint[0..n-1], theChebyshev coefficients of the integral of the function whose coefficients are c.
The constant ofintegration is set so that the integral vanishes at a.{int j;float sum=0.0,fac=1.0,con;con=0.25*(b-a);for (j=1;j<=n-2;j++) {cint[j]=con*(c[j-1]-c[j+1])/j;Factor that normalizes to the interval b-a.Equation (5.9.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).If you have obtained the Chebyshev coefficients that approximate a function ina certain range (e.g., from chebft in §5.8), then it is a simple matter to transformthem to Chebyshev coefficients corresponding to the derivative or integral of thefunction.
Having done this, you can evaluate the derivative or integral just as if itwere a function that you had Chebyshev-fitted ab initio.The relevant formulas are these: If ci , i = 0, . . . , m − 1 are the coefficientsthat approximate a function f in equation (5.8.9), Ci are the coefficients thatapproximate the indefinite integral of f, and c0i are the coefficients that approximatethe derivative of f, then.















