非线性方程解法Word文档下载推荐.docx
《非线性方程解法Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《非线性方程解法Word文档下载推荐.docx(7页珍藏版)》请在冰豆网上搜索。
end
r=myf(x0);
n=1;
tol=1;
whiletol>
eps
x0=r;
tol=norm(r-x0);
n=n+1;
if(n>
100000)
disp('
迭代步数太多,方程可能不收敛'
);
return;
end
例子:
求下列方程的根:
0.5sin(x1)+0.1cos(x1x2)-x1=0;
0.5cos(x1)-0.1sin(x2)-x
(2)=0
迭代初值取为:
(0,0)。
解:
建立myf.m函数文件如下
functionf=myf(x)
f
(1)=0.2*sin(x
(1))+0.1*cos(x
(1)*x
(2));
f
(2)=0.5*cos(x
(1))-0.1*sin(x
(2));
[x,n]=mulStablePoint(x,eps)
x=
0.1979
0.4470
n=
49
2.
牛顿法
M文件
function[r,n]=mulNewton(x0,eps)
r=x0-myf(x0)*inv(dmyf(x0));
迭代步数太多,方程可能不收'
写出myf.m函数文件如下
f
(1)=0.5*sin(x
(1))+0.1*cos(x
(1)*x
(2))-x
(1);
f
(2)=0.5*cos(x
(1))-0.1*sin(x
(2))-x
(2);
f=[f
(1)f
(2)];
写出微分方程函数如下:
functiondf=dmyf(x)
df=[0.5*cos(x
(1))-0.1*x
(2)*sin(x
(2)*x
(1))-1-0.1*x
(1)*sin(x
(2)*x
(1));
-0.5*sin(x
(1))-0.1*cos(x
(2))-1];
[r,n]=mulNewton([00])
r=
5
dean20080421174338.doc
(2008-04-3010:
59:
54,Size:
89.5KB,Downloads:
0)
最新回复
zhenghuiat2008-4-3011:
02:
03
3.
牛顿下山法
牛顿下山法的M文件
function[r,n]=mulDNewton(x0,eps)
r=x0-myf(x0)/dmyf(x0);
ttol=1;
w=1;
F1=norm(myf(x0));
whilettol>
=0
r=x0-w*myf(x0)/dmyf(x0);
ttol=norm(myf(r))-F1;
w=w/2;
[r,n]=mulDNewton([00])