%SHOWADAPT demonstrate the performance of adaptsimp

% initialize function evaluation counter and graphics window
global nfun; nfun = 0; clf; drawnow; hold on;

% give the exact value of the integral if known
% (here we use quad8, Matlab's high order adaptive quadrature routine)
exact = quad8('humps',0,3,1.e-12);

% for animated display fix axes
axis([0 3 -20 100]);

% set function, limits of integration and tolerance
fun = 'humpsp'; a = 0; b = 3; tol = .1;

% call adaptsimp and display the results
approx = adaptsimp(fun,a,b,tol);
err = exact - approx;
fprintf('\n integral= %17.10e\n',approx);
fprintf(' tolerance = %17.2e\n',tol);
fprintf(' error =     %17.2e\n',err);
fprintf(' function evaluations = %d\n\n',nfun);
