Newton iteration method MATLAB program

/*简单牛顿迭代法的MATLAB程序实现*/
function x=newtoniteration(fun,dfun,x0,EPS) %简单牛顿迭代法
%fun即迭代函数,dfun即迭代函数的一阶导数,x0为迭代初值,EPS为精度
f=fcnchk(fun);
df=fcnchk(fun);
x1=x0-f(x0)/df(x0);
d=norm(x1-x0);
k=1;
while d>=EPS
	x0=x1;
	x1=x0-f(x0)/df(x0);
	d=norm(x1-x0);
	k=k+1;
end
x=x1; %切记要给x赋值
/*简单牛顿迭代法的MATLAB程序实现2,增加了迭代次数的限制*/
function x=newtoniteration(fun,dfun,x0,EPS) %简单牛顿迭代法
%fun即迭代函数,dfun即迭代函数的一阶导数,x0为迭代初值,EPS为精度
f=fcnchk(fun);
df=fcnchk(fun);
x1=x0-df(x0)\f(x0); %左除
d=norm(x1-x0);
k=1;
while d>=EPS
	x0=x1;
	x1=x0-df(x0)\f(x0); %左除
	d=norm(x1-x0);
	k=k+1;
end
if k==1000
	x='fasan';
else
	x=x1;
end

Links are:
(1) MATLAB Newton iterative method for solving nonlinear equations
MATLAB program https://blog.csdn.net/mlp750303040/article/details/77479654 Newton iteration method

Root equation (2) Newton iteration method matlab program http://blog.sina.com.cn/s/blog_6faf74c00101cr9d.html

MATLAB program Equation Root (3) Newton iterative method
https://blog.51cto.com/592669550/930491

(4) MATLAB univariate function first and N-th order derivative
https://www.cnblogs.com/shuqingstudy/p/4844952.html

(5) MATLAB program Newton iteration method
https://wenku.baidu.com/view/a606ce9ddd3383c4bb4cd292.html

Guess you like

Origin blog.csdn.net/JxufeCarol/article/details/89389219