/************************* Program 5.4 ****************************/ /* */ /************************************************************************/ /* Please Note: */ /* */ /* (1) This computer program is written by Tao Pang in conjunction with */ /* his book, "An Introduction to Computational Physics," published */ /* by Cambridge University Press in 1997. */ /* */ /* (2) No warranties, express or implied, are made for this program. */ /* */ /************************************************************************/ #include #include void lgnd (lmax,x,p) /* Subroutine to generate Legendre polynomials P_L(X) for L = 0,1,...,LMAX with given X. Copyright (c) Tao Pang 1997. */ int lmax; double x; double p[]; { int l; p[0] = 1; p[1] = x; for (l = 1; l < lmax; ++l) { p[l+1] = ((2*l+1)*x*p[l]-l*p[l-1])/(l+1); } }