function [x]=hw2_1_12() % Iteratively solve the equation x^2-x-1=0 (using Newton's method) oldx=2; % initial geuss for x x=1+1/oldx; % iterate while the tolerance condition on x is NOT true while(abs(x-oldx)>0.0005) oldx=x; % remember the previous value of x then ... x=1+1/oldx; % ... update the value end disp('check the answer (should be close to 0)') disp(x^2-x-1)