You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function p=LegendreP(nmax,x)% function p=LegendreP(nmax,x)% Computes all Legendre polynomials from n=0 to n=nmax,% arranges them in an array from n=1 to nmax+1.% Uses the recursion relation in Numerical Recipes.% T Ferree at EGI% revised 1/19/00p=zeros(nmax+1,1);if nmax>=0, p0=1.0; p(1)=p0;endif nmax>=1, p1=x; p(2)=p1;endif nmax>=2, for j=2:nmax, % c1=(2.0*j-1.0)/(1.0*j); % c2=(1.0*j-1.0)/(1.0*j); % p(j+1)=c1*x*p(j-1+1)-c2*p(j-2+1); c1=(2.0*j-1.0)/j; c2= (j-1.0)/j; p(j+1) = c1*x*p(j) - c2*p(j-1); endendreturn;