function varargout=paul(Lmax,x0) % [Itab,Itabo,dels,dems]=paul(Lmax,x0) % % Recursively evaluates a list of integrals of a single Schmidt % semi-normalized real Legendre polynomial P_lm(x)dx from x0 to 1. % The iteration is set up according to Paul (1978) 'Recurrence relations % for integrals of associated Legendre functions'. % % INPUT: % % Lmax Bandwidth (maximum spherical harmonic degree) % x0 Vector of lower bounds for the integrals % % OUTPUT: % % Itab List of integrals of LEGENDRE(l,x,'sch') from x0 to 1 % Itabo Same but without the sqrt(2-dom) factor subsumed by Matlab % % EXAMPLE: % % paul('demo1') Random Lmax, 100 values for x0, PAUL vs GAUSSLEGENDRE % paul('demo2') Complete list comparison PAUL vs GAUSSLEGENDRE % % Last modified by plattner-at-princeton.edu, 05/17/2011 % Last modified by fjsimons-at-alum.mit.edu, 06/01/2011 defval('Lmax',ceil(rand*256)) defval('x0',rand(256,1)*2-1) if ~isstr(Lmax) % Turn the lower bounds into row x0=x0(:)'; % first we test if Lmax is zero or positive if(Lmax<0) error('Lmax must be non-negative'); Itable=[]; end % Initialize Itab [Itab,Ptab]=deal(zeros(Lmax*(Lmax+1)/2+Lmax+1,length(x0))); % Now the starting evaluations for the LEGENDRE(l,x,'sch') Itab(1,:)=legendreint01(0,0,x0); Itab(2,:)=legendreint01(1,0,x0); % Get rid of the sqrt(2) factor Itab(3,:)=legendreint01(1,1,x0)/sqrt(2); % Now the Legendre functions themselves Ptab(2:3,:)=legendre(1,x0,'sch'); % Get rid of the sqrt(2) factor Ptab(3,:)=Ptab(3,:)/sqrt(2); % This is a common argument y2=(1-x0.^2); % Now begin with the iterations for l=2:Lmax % This is the index for m=0 at this l, i.e. addmup(l-1)+1 lind=l*(l+1)/2+1; % This is the index for m=0 at l-1, i.e. addmup(l-2)+1 lond=(l-1)*l/2+1; % This is the index for m=0 at l-2, i.e. addmup(l-3)+1 lund=(l-2)*(l-1)/2+1; % Calculate the associated Legendre functions for this l Ptab(lind:lind+l,:)=legendre(l,x0,'sch'); % Get rid of the sqrt(2) factor Ptab(lind+1:lind+l,:)=Ptab(lind+1:lind+l,:)/sqrt(2); % Some common factors at this l fux=(2*l-1)/(l+1); fex=sqrt((2*l-1)*(2*l-2)*2*l); % These are the cases where m~=l for m=0:l-1 % Some common factors at this m fax=sqrt((l +m)*(l -m)); fox=sqrt((l-1+m)*(l-1-m)); if m