% TABLE2_8 Computation of Table 2.8
%
f1='%7.0f %9.2e %9.2e %9.2e\n';
fprintf('\n')
disp('   Table 2.8 Condition number and error')
disp('   magnification for the half-range')
disp('   Hermite measure using Laguerre moments')
fprintf('\n')
disp('      n  (2.1.64)     maga      magb')
N=10;
load -ascii abhrhermite;
abexact=abhrhermite; abexact(1,2)=sqrt(pi)/2;
abm=r_laguerre(2*N); mom=zeros(1,2*N);
mom(1)=sqrt(pi)/2; mom(2)=.5-mom(1);
fac=1; sgn=-1;
for k=2:2*N-1
  fac=k*fac; sgn=-sgn;
  kh=floor(k/2); km1h=floor((k-1)/2);
  t=2*mom(1); s=t;
  for m=1:kh
    t=(k-2*m+1)*(k-2*m+2)*t/(16*m^2*(m-.5));
    s=s+t;
  end
  t=-k; s=s+t;
  if km1h>=1
    for m=1:km1h
      t=(k-2*m)*(k-2*m+1)*t/(16*(m+.5)^2*m);
      s=s+t;
    end
  end
  mom(k+1)=.5*sgn*fac*s;
end
[abcheb,normsq]=chebyshev(N,mom,abm);
iopt=0;
for n=2:2:N
  rc=rcondG(n,iopt,abexact,abm,mom);
  ea=abs(abcheb(1:n,1)-abexact(1:n,1))./moll(abexact(1:n,1));
  eb=abs(abcheb(1:n,2)-abexact(1:n,2))./moll(abexact(1:n,2));
  maga=max(ea)/eps;
  magb=max(eb)/eps;
  fprintf(f1,n,rc,maga,magb)
end
