Hi, I'm having a little trouble with my newton's method code.
One of my biggest issues is that I'm not able to create an output, rHist, which is a vector consisting of x0 and the outputs after every iteration of newton's method and my number of iterations is off by 1.
My code (posted below) also doesn't seem to work when the initial guess, x0 satisfies the stopping criterion.
% function [r,N,fRoot] = newtonRaphE7(fHan,dfHan,x0,fTol,iterMax) k=1; while k<=iterMax x=x0-fHan(x0)/dfHan(x0) if abs(x-x0)<fTol*abs(x) return x0=x; r=x0; k=k+1; N=k; fRoot=abs(fHan(r)); end end
No products are associated with this question.