% trap_td_report2
f = @(x) x^(1/2);
a = 0; b=1;
exact =2/3;
kmax = 5;
for k=1:kmax
  n=10^k;
  int(k) = trap_td(f,a,b,n);
  error(k) = abs(exact-int(k));
end
% create table - see Driscoll, p.67
fprintf('\n      n=10^k     int(k)            |exact - int(k)|\n');
fprintf('----------------------------------------------\n');
fprintf('%10.0f      %18.16f        %8.3e\n',  [10.^[1:kmax];int;error] )

%  plot
semilogy(1:5,error,'-o')
title('error with trapezoidal rule with n points')
xlabel('k where n = 10^k')
ylabel('error')