function p=bisection_table(f,a,b,tol,max_iterations) % Bisection: See section 2.1. % This version prints the iterations in a table. fprintf(' n | a | b | p_n\n'); fprintf('-----------------------------------------------\n'); for i=1:max_iterations p=(a+b)/2; fprintf('%2d | %+12.8f | %+12.8f | %+12.8f\n', i, a, b, p); if p-a0 a=p; else b=p; end end error('Exceeded maximum number of iterations');