function ShowQuads(f,a,b)
% Applies quad and quadl to the problem of integrating
% f(x) from x = a to x = b. Reports the computed integral
% and the number of required f-evaluations for tol = 1/10^p,
% p = 3,6,9,12.
clc
fprintf(' quad quadl \n')
fprintf(' tol Approximation f-evals Approximation f-evals \n')
fprintf('-------------------------------------------------------------------\n')
for tol = [.001 .000001 .000000001 .000000000001]
[Q,fcount] = quad(f,a,b,tol);
[QL,fcountL] = quadl(f,a,b,tol);
fprintf('%5.1e %15.12f %6d %15.12f %6d \n',tol,Q,fcount,QL,fcountL)
end

fprintf('\n\nUsing quad:\n\n')
fprintf(' Q = quad(f,a,b)\n')
fprintf(' Q = quad(f,a,b,tol)\n')
fprintf(' [Q,fCount] = quad(f,a,b)\n')
fprintf(' [Q,fCount] = quad(f,a,b,tol)\n\n')

fprintf(' Estimates the integral of f from a to b with absolute error <= tol\n')
fprintf(' Recursive adaptive Simpson quadrature\n')
fprintf(' f is a function handle and the referenced function f(x) should accept a vector arguments.\n')
fprintf(' Default tolerance is 10^-6\n')
fprintf(' fCount is the number of f-evaluations\n\n')

fprintf('\n\nUsing quad:\n\n')
fprintf(' Q = quadl(f,a,b)\n')
fprintf(' Q = quadl(f,a,b,tol)\n')
fprintf(' [Q,fCount] = quadl(f,a,b)\n')
fprintf(' [Q,fCount] = quadl(f,a,b,tol)\n\n')

fprintf(' Estimates the integral of f from a to b with absolute error <= tol\n')
fprintf(' Recursive adaptive Lobatto quadrature\n')
fprintf(' f is a function handle and the referenced function f(x) should accept a vector arguments.\n')
fprintf(' Default tolerance is 10^-6\n')
fprintf(' fCount is the number of f-evaluations\n\n')