rho = 10;
%
% Bisection
%
a = 0;
b = rho + 1/rho;
N = 1000;
tol = 1e-14;
[fun_Bisection, x_Bisection, flg_Bisection] = BisectionMethod(@RootFun, a, b, N, tol,rho);
%
% Newton
%
a = 0;
b = rho + 1/rho;
N = 1000;
tol = 1e-14;
[fun_Newton, dfun_Newton, x_Newton, flg_Newton] = NewtonMethod(@RootFun, @RootFunD, b, N, tol,rho);
%
% Secant
%
a = 0;
b = rho + 1/rho;
N = 1000;
tol = 1e-14;
[fun_Secant, x_Secant, flg_Secant] = SecantMethod(@RootFun, a, b, N, tol,rho);

format short g
figure(2)
clf
semilogy(abs(fun_Newton),'b.-.')
hold on
semilogy(abs(fun_Secant),'r-')      
semilogy(abs(fun_Secant),'rd')
semilogy(abs(fun_Bisection),'k*-.')
title('Convergence Rates of Newton,Secant,Bisection');
options = optimset('TolFun',tol);
[x,fval,exitflg,output]=fzero(@(x) RootFun(x,rho),rho+1/rho,options);
junk1 = ['Convergence Rates of Newton,Secant,Bisection, rho = ', num2str(rho)];
junk2 = ['# of fzero function evaluations = ', num2str(output.funcCount)];
title(strvcat(junk1,junk2))
print('-dpsc',['RootDemoRho',num2str(rho),'.ps']);


