0001 function p = legendre_r(z,nmax); 0002 p = zeros(nmax,size(z,2)); 0003 p(1,:) = z; 0004 p(2,:) = 0.5*(3*z.^2 - ones(1,size(z,2))); 0005 for n = 3:nmax 0006 p(n,:) = (z.*p(n-1,:)*(2*n-1)-(n-1)*p(n-2,:))/n; 0007 end; 0008 0009