function ds=ledx(s);

% The function ds=ledx(s) computes the first derivative of truncated Legendre series expansion.
%  Input: 
%    s--Legendre coefficients 
%  output: 
%    ds--Legendre coefficients of 1st-order derivative

nn=length(s);
n=nn-1;

ds=[];
ds(nn)=0;ds(nn-1)=(2*n-1)*s(nn);
for k=n-1:-1:1,
 ds(k)=(2*k-1)*(s(k+1)+ds(k+2)/(2*k+3));
end; 
ds=ds';
if size(s,1)<size(s,2), ds=ds'; end;
    
    
    
    
    
    


