% SSTIELTJES Symbolic counterpart of stieltjes.m
%
function ab=sstieltjes(dig,N,xw)
digits(dig);
xw=vpa(xw);
Ncap=size(xw,1);
if(N<=0|N>Ncap), error('N in sstieltjes out of range'), end
s0=vpa(ones(1,Ncap))*xw(:,2);
ab(1,1)=xw(:,1)'*xw(:,2)/s0; ab(1,2)=s0;
if N==1, return, end
p1=vpa(zeros(Ncap,1)); p2=vpa(ones(Ncap,1));
for k=1:N-1
  p0=p1; p1=p2;
  p2=(xw(:,1)-ab(k,1)).*p1-ab(k,2)*p0;
  s1=xw(:,2)'*(p2.^2);
  s2=xw(:,1)'*(xw(:,2).*(p2.^2));
  ab(k+1,1)=s2/s1; ab(k+1,2)=s1/s0;
  s0=s1;
end
