% define the function f % define initial iterate x_1 and x_2 as components of a VECTOR % in advance R = zeros(10,5); R(1,1) =1; R(1,2) = x(1); R(1,3) = f(x(1)); for k=2:10 R(k,1) = k; R(k,2) = x(2); R(k,3) = f(x(2)); R(k,4) = (R(k,3)-R(k-1,3))/(x(2)-x(1)); R(k,5) = -R(k,3)/R(k,4); x(1) = x(2); x(2) = x(1) + R(k,5); end