function noncon(a, b, x0, epsilon); % Study the convergence of interval bisection, Newton, Global Newton for % solving nonlinear equation in 1D. % Input: % [a, b]: initial interval for the interval bisection and Global Newton % x_0: initial guess for Newton % epsilon: convergence tolerence % Matlab fzero function z1 = fzero(inline('exp(2*sin(x)) - x'), -8) sol = z1; % Exact solution % Plot the history of interval bisection mathod. % Give initial interval [a,b], and convergence tolerance [x_bi, f_bi] = bisec('myfunction', a, b, epsilon); error_bi = x_bi - sol*ones(1,length(x_bi)); % Newton method with different initial guesses [x_new, f_new] = Newton('myfunction', x0, epsilon); error_new = x_new - sol*ones(1,length(x_new)); [x_Gnew, f_Gnew] = GlobalNewton('myfunction', a, b, epsilon); error_Gnew = x_Gnew - sol*ones(1,length(x_Gnew)); semilogy(1:length(error_bi), abs(error_bi), '-*', 1:length(error_new), abs(error_new), '-d', 1:length(error_Gnew), abs(error_Gnew), '-o'); legend('Interval Bisection', 'Standard Newton', 'Global Newton', 3);