%%FPI.M  fixed point iteration nonlinear root-finding. 
% NH 2019
f = @(t) 8 - 4.5*(t - sin(t)); % Define original function
g = @(t) sin(t) + 8/4.5;       % Define fixed-point function
% g = @(t) t/2 + sin(t)/2 + 4/4.5; % Alternative (good!)
% g = @(t) t - sin(t) - 8/4.5;     % Alternative (bad!)
x = 2.2;                       % Initial guess
for k = 1:15
    x = g(x);                  % Fixed point iteration
    disp([x, f(x)])
end

