正在加载图片...
254 Chapter 6. Special Functions #include <math.h> float plgndr(int 1,int m,float x) Computes the associated Legendre polynomial Pm(z).Here m and I are integers satisfying 0≤m≤l,while z lies in the range-1≤x≤l. void nrerror(char error_text[]); float fact,pll,pmm,pmmp1,somx2; int i,ll; if (m <m>1I fabs(x)>1.0) nrerror("Bad arguments in routine plgndr"); http://www.nr read able files pmm=1.0; Compute pm if(m>0)[ somx2=sqrt(1.0-x)*(1.0+x); fact=1.0; .com or call 1-800-872- (including this one) granted for 19881992 for(1=1;1<=m;i++)( pmm *=-fact*somx2; fact+=2.0; 2 1f(1=m) return pmm; else Compute P+1 pmmp1=x*(2*m+1)*pmm; 1f(1==(血+1)) 7423 (North America to any server computer,is strictly prohibited. tusers to make one paper by Cambridge University Press.Programs from NUMERICAL RECIPES IN C: THE return pmmp1; else Compute Pm,m+1. for(11=m+2;11<1;11+)[ p11=(x*(2*11-1)*pmmp1-(11+m-1)*pmm)/(11-m): only),or pmm=pmmp1; pmmp1=pl1; copy for their return pll; 22 ART OF SCIENTIFIC COMPUTING(ISBN 0-521- CITED REFERENCES AND FURTHER READING: Magnus,W.,and Oberhettinger,F.1949,Formulas and Theorems for the Functions of Mathe- v@cambr matical Physics (New York:Chelsea),pp.54ff.[1] Abramowitz,M.,and Stegun,I.A.1964,Handbook of Mathematical Functions,Applied Mathe- 1988-1992 by Numerical Recipes matics Series,Volume 55 (Washington:National Bureau of Standards;reprinted 1968 by -431085 Dover Publications,New York),Chapter 8.[2] (outside North Software. Amer visit website machine254 Chapter 6. Special 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). #include <math.h> float plgndr(int l, int m, float x) Computes the associated Legendre polynomial P m l (x). Here m and l are integers satisfying 0 ≤ m ≤ l, while x lies in the range −1 ≤ x ≤ 1. { void nrerror(char error_text[]); float fact,pll,pmm,pmmp1,somx2; int i,ll; if (m < 0 || m > l || fabs(x) > 1.0) nrerror("Bad arguments in routine plgndr"); pmm=1.0; Compute P mm . if (m > 0) { somx2=sqrt((1.0-x)*(1.0+x)); fact=1.0; for (i=1;i<=m;i++) { pmm *= -fact*somx2; fact += 2.0; } } if (l == m) return pmm; else { Compute P m m+1. pmmp1=x*(2*m+1)*pmm; if (l == (m+1)) return pmmp1; else { Compute P m l , l>m + 1. for (ll=m+2;ll<=l;ll++) { pll=(x*(2*ll-1)*pmmp1-(ll+m-1)*pmm)/(ll-m); pmm=pmmp1; pmmp1=pll; } return pll; } } } CITED REFERENCES AND FURTHER READING: Magnus, W., and Oberhettinger, F. 1949, Formulas and Theorems for the Functions of Mathe￾matical Physics (New York: Chelsea), pp. 54ff. [1] Abramowitz, M., and Stegun, I.A. 1964, Handbook of Mathematical Functions, Applied Mathe￾matics Series, Volume 55 (Washington: National Bureau of Standards; reprinted 1968 by Dover Publications, New York), Chapter 8. [2]
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有