% MM_LOGSQ Modified moments for an algebraic/square-logarithmic 
%    weight function.
%
%    The call mm=MM_LOGSQ(n,a) computes the first n modified moments of the
%    square-logarithmic weight function w(t)=t^a [log(1/t)]^2 on [0,1] 
%    relative to shifted Legendre polynomials. 
%
%    REFERENCE:  W. Gautschi,`` On certain slowly convergent series
%    occurring in plate contact problems'', Math. Comp. 57 (1991),
%    325-338.
%
function mm=mm_logsq(N,a)
if a<=-1, error('a out of range in mm_log'), end
c=1;
for n=1:N
  if n==1
    mm(1)=2/(a+1)^3;
  else 
    k=1:n-1;
    s1=k./((k+a+1).*(k-a-1)); sig1=sum(s1);
    s2=k./((k+a+1).^2.*(k-a-1).^2); sig2=sum(s2);
    p=prod((a+1-k)./(a+1+k));
    mm(n)=(2/(a+1)^3)*(1+2*(a+1)*sig1+2*(a+1)^2*sig1^2 ...
      -2*(a+1)^3*sig2)*p;
  end
  mm(n)=c*mm(n); c=.5*n*c/(2*n-1);
end
