function yout=newton1(x,numIters) %Newton's Method (function hardcoded below) using initial point x0 and %numIters iterations. The output is a vector, the orbit of x0. yout=zeros(numIters+1,1); [yout(1), dy]=funcA(x); for j=1:numIters if abs(dy)>2*eps x=x-yout(j)/dy; [yout(j+1) dy]=funcA(x); else fprintf('Derivative is too small. Stop.\n'); end end function [y dy]=funcA(x) % Change this for Newton's Method above. Compute both f(x) and f'(x) y=cos(x)-x; dy=-sin(x)-1;