f = @(t) 8 - 4.5*(t - sin(t)); % Define function
a = 2; b = 3;                  % Define initial interval
fa = f(a); fb = f(b);          % Function values
tol = 1e-4; k = 0;             % Define tolerance & step counter
fc = inf;                      % initialise fc so we enter the loop
disp('          step                a                    b                   c                  f(c)              (b-a)/2')
while ( abs(fc) > tol )        % Start iteration
    c = (a*fb-b*fa)/(fb-fa); fc = f(c); % New value and evaluation
    disp([k a b c fc (b-a)/2]) % Display values
    if ( fa*fc < 0 )           % Alt:  if (sign(fb) == sign(fc))
        b = c; fb = fc;        % [a,c] becomes new [a,b]
    else
        a = c; fa = fc;        % [c,b] becomes new [a,b]
    end
    k = k + 1;
end
