数值分析上机报告文档格式.docx
- 文档编号:14272578
- 上传时间:2022-10-21
- 格式:DOCX
- 页数:54
- 大小:658.58KB
数值分析上机报告文档格式.docx
《数值分析上机报告文档格式.docx》由会员分享,可在线阅读,更多相关《数值分析上机报告文档格式.docx(54页珍藏版)》请在冰豆网上搜索。
b.Newtonmethod;
c.Secantmethod;
d.methodofFalsePosition;
e.Mü
ller’smethod
1.1.1迭代公式(简单原理)
1.BisectionMethod
Themethodcallsforarepeatedhalvingofsubintervalsof[a,b]and,ateachstep,locatingthehalfcontainingtherootofequation.
Supposef(x)isacontinuousfunctiondefinedontheinterval[a,b],withf(a)andf(b)ofoppositesign.setal=aandb1=b,andletp1bethemidpointof[a,b];
Thatisp1=(a+b)/2,Iff(p1)=0,thensetp=p1,p1是f(x)=0的实根p.Iff(a1)f(p1)<
0,thenp(a1,p1),seta2=a1,b2=p1;
otherwisep∈(p1,b1),seta2=p1,b2=b1.Wethenrepeattheprocesstotheinterval[a2,b2].Thelengthofinterval[ak,bk]isbk-ak=
2.Fixed-PointIteration
Thebasicidea:
Step1.Constructingthefixed-pointequation:
x=g(x),letf(x)=0x=g(x);
g(x)iscalledIterationfunction
Step2.Settingupiterationscheme:
pk+1=g(pk)
(1)Wechooseaninitialapproximationp0andgeneratethesequenceby
(1),foreachk≥1.
3.Newtonmethod
Supposethatf∈[a,b],letpk∈[a,b]beanapproximationtorootoftheequationf(x)=0.ConsiderthefirstTaylorpolynomialforf(x)aboutpktoapproximatef(x):
Wehave,Letf’(pk)≠0,Solvingforpk+1gives,whichstartswithaninitialapproximationP0andgeneratesthesequence
4.Secantmethod
如所求问题不便求导,用过点xk的割线的斜率来代替切线的f’(xk),即,SubstitutingitintoNewtonMethod,wehave,ThistechniqueiscalledtheSecantmethod.
5.methodofFalsePosition
(1)提供两个初始值:
p0,p1,满足f(p0)·
f(p1)<
0;
(2)利用割线法求出p2,;
(3)检查f(p2)·
f(p1),若f(p2)·
0,过点(p1,f(p1))(p2,f(p2))做割线,求出p3;
否则若f(p2)·
f(p1)>0,过点(p0,f(p0))与(p2,f(p2))做割线,求出p3;
依此类推下去…
试位法保证方程f(x)=0的根p,总在相邻的迭代之中,即p∈(pk,pk+1).
6.Mü
1.1.2程序及实验结果
1.1Newtonmethod
fnewton.m
functionres=fnewton(func,dfunc,x,tol)
x0=x;
d=feval(func,x0)/feval(dfunc,x0);
i=0;
whileabs(d)>
tol
i=i+1;
x1=x0-d;
x0=x1;
d=feval(func,x0)/feval(dfunc,x0);
end
res=[x0,i];
func.m
functionfx1=func(x)
fx1=x-10^x+2;
dfunc.m
functionfx2=dfunc(x)
fx2=1-10^x*(log(10));
实验结果
1.2Fixed-PointIteration
fixedpoint.m
functionres=fixedpoint(func1,x,tol)
d=feval(func1,x0);
x1=d;
whileabs(x1-x0)>
tol
d=feval(func1,x1);
x1=d;
res=[x1,i];
func1.m
functionfx1=func1(x)
fx1=log10(x+2);
将func1做更改
func2.m
functionfx=func2(x)
fx=10^(x)-2;
实验结果:
2.1Bisectionmethod
bisection.m
functionres=bisection(func,xa,xb,tol)
n=0;
xc=0;
fa=0;
fc=0;
while(xb-xa)>
n=n+1;
fa=feval(func,xa);
xc=(xa+xb)/2;
fc=feval(func,xc);
iffc*fa<
xb=xc;
elsexa=xc;
end
res=[nxaxbxcfc];
fx1=600*(x^4)-550*(x^3)+200*(x^2)-20*x-1;
2.2.Newtonmethod
2.3Secantmethod
secant.m
functionres=secant(func,x,y,tol)
x1=y;
d=[feval(func,x1)]*(x1-x0)/(feval(func,x1)-feval(func,x0));
d=feval(func,x1)*(x1-x0)/(feval(func,x1)-feval(func,x0));
x0=x1;
x1=x1-d;
2.4methodofFalsePosition
falseposition.m
functionres=falseposition(func,x,y,tol)
f=0;
x2=0;
f=feval(func,x1);
x2=x1-d;
ifx2*f<
x1=x2;
elsex1=x2;
2.5Mü
muller.m
functionres=muller(func,x,y,z,tol)
%Tofindtheapproximationrootofapolynomials
%bymullermethod
x2=z;
h1=x1-x0;
h2=x2-x1;
m1=(feval(func,x1)-feval(func,x0))/h1;
m2=(feval(func,x2)-feval(func,x1))/h2;
d=(m2-m1)/(h2+h1);
h=100;
b=0;
e=0;
p=0;
q=0;
whileabs(h)>
b=m2+h2*d;
p=(b^2-4*d*feval(func,x2))^(0.5);
ifabs(b-p)<
abs(b+p)
e=b+p;
elsee=b-p;
h=(-2)*feval(func,x2)/e;
q=x2+h;
x2=q;
h1=x1-x0;
h2=x2-x1;
m1=(feval(func,x1)-feval(func,x0))/h1;
m2=(feval(func,x2)-feval(func,x1))/h2;
d=(m2-m1)/(h2+h1);
res=[q,i];
1.1.3结果分析
1.经过实验结果比较我们可以看到,Newton法只需选取不同的初值,便可求出他全部的解,即Newton法对于他全部的解都是收敛的。
而使用不动点法,我们首先要选取合适的g(x),因为对于不同的解,g(x)不一定收敛,而对于不同的g(x)收敛的速度也都不同。
而
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数值 分析 上机 报告
![提示](https://static.bdocx.com/images/bang_tan.gif)