正在加载图片...
178 Chapter 5. Evaluation of Functions Then the answer is 0 w=0 d 2 w≠0,c≥0 Vc+id= 4 (5.4.7) iw w≠0,c<0,d≥0 2w d叫 iw w≠0,c<0,d<0 2w Routines implementing these algorithms are listed in Appendix C. nted for CITED REFERENCES AND FURTHER READING: Midy,P,and Yakovlev,Y.1991,Mathematics and Computers in Simulation,vol.33,pp.33-49. Knuth,D.E.1981.Seminumerical Algorithms,2nd ed.,vol.2 of The Art of Computer Programming (Reading,MA:Addison-Wesley)[see solutions to exercises 4.2.1.16 and 4.6.4.41]. (North University RECIPES Press. THE 5.5 Recurrence Relations and Clenshaw's Recurrence Formula Programs Many useful functions satisfy recurrence relations,e.g., SCIENTIFIC (m+1)Pn+1(x)=(2m+1)xPn(x)-nPn-1(x) (5.5.1) 6 +()=2n ()-n-1() (5.5.2) nEn+i(z)=e-x-IEn(I) (5.5.3) cosne =2 cos0 cos(n-1)0-cos(n-2)0 (5.5.4) Numerical sin ne =2cos0 sin(n-1)0-sin(n-2)0 (5.5.5) where the first three functions are Legendre polynomials,Bessel functions of the first (outside kind,and exponential integrals,respectively.(For notation see [1].)These relations are useful for extending computational methods from two successive values of n to North other values,either larger or smaller. Equations(5.5.4)and(5.5.5)motivate us to say a few words about trigonometric functions.If your program's running time is dominated by evaluating trigonometric functions,you are probably doing something wrong.Trig functions whose arguments form a linear sequence 0 =0o+no,n =0,1,2,...,are efficiently calculated by the following recurrence, cos(0+6)=cos0-[a cos0+Bsin] (5.5.6) sin(0+6)=sin0-a sin-3 cos178 Chapter 5. Evaluation of Functions Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). Then the answer is √ c + id =    0 w = 0 w + i  d 2w w = 0, c ≥ 0 |d| 2w + iw w = 0, c < 0, d ≥ 0 |d| 2w − iw w = 0, c < 0, d < 0 (5.4.7) Routines implementing these algorithms are listed in Appendix C. CITED REFERENCES AND FURTHER READING: Midy, P., and Yakovlev, Y. 1991, Mathematics and Computers in Simulation, vol. 33, pp. 33–49. Knuth, D.E. 1981, Seminumerical Algorithms, 2nd ed., vol. 2 of The Art of Computer Programming (Reading, MA: Addison-Wesley) [see solutions to exercises 4.2.1.16 and 4.6.4.41]. 5.5 Recurrence Relations and Clenshaw’s Recurrence Formula Many useful functions satisfy recurrence relations, e.g., (n + 1)Pn+1(x) = (2n + 1)xPn(x) − nPn−1(x) (5.5.1) Jn+1(x) = 2n x Jn(x) − Jn−1(x) (5.5.2) nEn+1(x) = e−x − xEn(x) (5.5.3) cos nθ = 2 cos θ cos(n − 1)θ − cos(n − 2)θ (5.5.4) sin nθ = 2 cos θ sin(n − 1)θ − sin(n − 2)θ (5.5.5) where the first three functions are Legendre polynomials, Bessel functions of the first kind, and exponential integrals, respectively. (For notation see [1].) These relations are useful for extending computational methods from two successive values of n to other values, either larger or smaller. Equations (5.5.4) and (5.5.5) motivate us to say a few words about trigonometric functions. If your program’s running time is dominated by evaluating trigonometric functions, you are probably doing something wrong. Trig functions whose arguments form a linear sequence θ = θ0 + nδ, n = 0, 1, 2,... , are efficiently calculated by the following recurrence, cos(θ + δ) = cos θ − [α cos θ + β sin θ] sin(θ + δ) = sin θ − [α sin θ − β cos θ] (5.5.6)
<<向上翻页
©2008-现在 cucdc.com 高等教育资讯网 版权所有