%
% Adaptive CSR
%
% This is the setup/driver part...
% Play with the tolerance for different results.
%

tol = 10^-6;
a   = 0;
b   = 1;

f = inline('1-((x-pi/2/exp(1)).^2).^(1/3)');

figure(1); xv = 0:0.001:1;
plot(xv,f(xv),'-','linewidth',3)
title('Adaptive CSR --- The Function','fontweight','bold','fontsize',14)
axis([0 1 0 1])
xlabel('x','fontweight','bold','fontsize',14)
ylabel('f(x)','fontweight','bold','fontsize',14)
grid on

h = figure(2); clf;
title('Adaptive CSR --- Refinement Levels','fontweight','bold','fontsize',14)
xlabel('x','fontweight','bold','fontsize',14)
ylabel('Refinement Level','fontweight','bold','fontsize',14)
grid on

[val,err] = ACSR(f,a,b,tol,1,h);

figure(h)
ax = axis;
axis([ax(1:2) 0 ax(4)])
hold off

fprintf('\n\nThe integral: %10.8f,  the error: %e \n\n',val,err);
