I'm trying to solve root finding problem by using Newton method when I run the code I got this message. How can I avoid this message? Is there a problem with my code?
max_iter=10; err=1; tol=10^-6; n_iter=0;while err>tol n_iter=n_iter+1; delta=-F(r)/dF(r); r=r+delta; err=abs(delta/r); if n_iter>max_iter warning('max iterations exceeded') break endend end %%%%%%%%%%%%%%%%%%%%%
function out=F(r)K=9*10^9; e= 1.6*10^-19; p=0.33*10^-10; Alpha=1.74637*10^-16;out=-K*(e^2./r)+ Alpha*exp(-r./p); end%%%%%%%%%%%%%%
function out=dF(r)K=9*10^9; e= 1.6*10^-19; p=0.33*10^-10; Alpha=1.74637*10^-16;out=K*(e^2./r^2)- (Alpha/p)*exp(-r./p);end
Best Answer