非线性方程解法.docx

上传人:b****3 文档编号:3855752 上传时间:2022-11-25 格式:DOCX 页数:7 大小:15.70KB
下载 相关 举报
非线性方程解法.docx_第1页
第1页 / 共7页
非线性方程解法.docx_第2页
第2页 / 共7页
非线性方程解法.docx_第3页
第3页 / 共7页
非线性方程解法.docx_第4页
第4页 / 共7页
非线性方程解法.docx_第5页
第5页 / 共7页
点击查看更多>>
下载资源
资源描述

非线性方程解法.docx

《非线性方程解法.docx》由会员分享,可在线阅读,更多相关《非线性方程解法.docx(7页珍藏版)》请在冰豆网上搜索。

非线性方程解法.docx

非线性方程解法

1.

不动点迭代法

M文件:

CODE:

function[r,n]=mulStablePoint(x0,eps)

ifnargin==1

eps=1.0e-4;

end

r=myf(x0);

n=1;

tol=1;

whiletol>eps

x0=r;

r=myf(x0);

tol=norm(r-x0);

n=n+1;

if(n>100000)

disp('迭代步数太多,方程可能不收敛');

return;

end

end

例子:

求下列方程的根:

0.5sin(x1)+0.1cos(x1x2)-x1=0;

0.5cos(x1)-0.1sin(x2)-x

(2)=0

迭代初值取为:

(0,0)。

解:

建立myf.m函数文件如下

CODE:

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文件

CODE:

function[r,n]=mulNewton(x0,eps)

ifnargin==1

eps=1.0e-4;

end

r=x0-myf(x0)*inv(dmyf(x0));

n=1;

tol=1;

whiletol>eps

x0=r;

r=x0-myf(x0)*inv(dmyf(x0));

tol=norm(r-x0);

n=n+1;

if(n>100000)

disp('迭代步数太多,方程可能不收');

return;

end

end

解:

写出myf.m函数文件如下

CODE:

functionf=myf(x)

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)];

写出微分方程函数如下:

CODE:

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=

0.1979

0.4470

n=

5

dean20080421174338.doc

(2008-04-3010:

59:

54,Size:

89.5KB,Downloads:

0)

最新回复

zhenghuiat2008-4-3011:

02:

03

3.

牛顿下山法

牛顿下山法的M文件

CODE:

function[r,n]=mulDNewton(x0,eps)

ifnargin==1

eps=1.0e-4;

end

r=x0-myf(x0)/dmyf(x0);

n=1;

tol=1;

whiletol>eps

x0=r;

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;

end

tol=norm(r-x0);

n=n+1;

if(n>100000)

disp('迭代步数太多,方程可能不收');

return;

end

end

[r,n]=mulDNewton([00])

r=

0.1979

0.4470

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 小学作文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1