%% nsectiontest
%
clear
close all
fun=@sin;
 %n=11;
 %n=21;
 %n=50;
initint=[-10 10];
tol=0.01;
n=11:10:51;
for k=1:5
    [br{k},mid{k}]=nsection(fun,initint,n(k),tol);

% Visualization
figure
x=linspace(-10.1,10.1);y=sin(x);
plot(x,y);grid on;shg
hold on
lefts{k}=br{k}(:,1);rights{k}=br{k}(:,2);
plot(lefts{k},-0.1,'rx')
plot(rights{k},0.1,'bo')
plot(mid{k},0*mid{k},'k*')
title(['n= ' num2str(n(k)) ', tol = ' num2str(tol)])

end
