% TEST_GLOBATTO_LOBATTO Test of generalized Gauss_Lobatto for r=1 against Lobatto
%
f1='%5.0f %10.2e %10.2e %10.2e %10.2e\n';
errxleg=zeros(100,1); errwleg=zeros(100,1);
errxcheb=zeros(100,1); errwcheb=zeros(100,1);
disp('                  maximum errors for r=1')
disp('             Legendre              Chebyshev')
disp('   N      errx       errx       errx       errw')
for N=[3:5 10:5:40 60:20:100]
  r=1;
%
% Legendre measure
%
  endl=-1; endr=1;
  ab=r_jacobi(N+2*r);
  xw=globatto(N,ab,r,endl,endr);
  xw0=lobatto(N,ab,endl,endr);
  errxleg(N)=max(abs(xw(3:N,1)-xw0(2:N-1,1)));
  errwleg(N)=max(abs((xw(3:N,2)-xw0(2:N-1,2))./xw0(2:N-1,2)));
  errx=max([abs(xw(1,1)-xw0(1,1)) abs(xw(2,1)-xw0(N+2,1))]);
  errw=max([abs(xw(1,2)-xw0(1,2)) abs(xw(2,2)-xw0(N+2,2))]);
  errxleg(N)=max([errxleg(N) errx]);
  errwleg(N)=max([errwleg(N) errw]);
%
% Chebyshev measure
%
  ab=r_jacobi(N+2*r,-.5);
  xw=globatto(N,ab,r,endl,endr);
  xw0=lobatto(N,ab,endl,endr);
  errxcheb(N)=max(abs(xw(3:N,1)-xw0(2:N-1,1)));
  errwcheb(N)=max(abs((xw(3:N,2)-xw0(2:N-1,2))./xw0(2:N-1,2)));
  errx=max([abs(xw(1,1)-xw0(1,1)) abs(xw(2,1)-xw0(N+2,1))]);
  errw=max([abs(xw(1,2)-xw0(1,2)) abs(xw(2,2)-xw0(N+2,2))]);
  errxcheb(N)=max([errxcheb(N) errx]);
  errwcheb(N)=max([errwcheb(N) errw]);
end
for N=[3:5 10:5:20 40:20:100]
  fprintf(f1,N,errxleg(N),errwleg(N),errxcheb(N),errwcheb(N))
end
