ImageVerifierCode 换一换
格式:DOCX , 页数:16 ,大小:33.07KB ,
资源ID:6997583      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6997583.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(数值分析实验报告2.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

数值分析实验报告2.docx

1、数值分析实验报告2数值分析上机实验报告(2) (注:本实验报告中所有程序均为MATLAB语言程序)班级:姓名:学号:六章2、用比例求根法求在区间(1, /2)内的一个根,直到近似根满足精度| ()|0.00001 if f(a+b)/2)0 a=(a+b)/2; x=a; end if f(a+b)/2)=0 x=(a+b)/2; break endendx运行结果:x = 1.1141531685964554、比较一下两种求+10 -2=0的根到三位有效数字所需的计算量。(1)在区间(0,1)内用二分法;(2)用迭代法=(2-)/10,取初值=0。(1)程序:format longa=0;b

2、=1;R=1;k=0;f=inline(exp(x)+10*x-2);while R1e-5 c=(a+b)/2; if f(a)*f(c)0; a=c; else b=c; end R=b-a;k=k+1;endkx=c运行结果:k = 17x = 0.09052276611328首先初步估计精确值在0.09左右,故取误差限选择为10-5,得到的计算次数为17次。(2)程序:format longf=inline(2-exp(x)/10);disp(x=);x=feval(f,0);disp(x);Eps=1E-5;i=1;while 1 x0=x; i=i+1; x=feval(f,x);

3、 disp(x); if x1E10; break; end; if abs(x-x0)0 x(n+1)=x(n)-2*f(x(n)/(w(n)+sqrt(w(n)2-4*f(x(n)*p(n); end if w(n)-s(n)0 x(n+1)=x(n)-2*f(x(n)/(w(n)-sqrt(w(n)2-4*f(x(n)*p(n); endendx=x(n+1)运行结果:m=10x = 1.87938524157059613应用Newton法于方程,导出求的迭代公式,并求出的值程序:clearm=input(m=);x(1)=11;f=inline(1-115/x2);f1=inline(

4、2*115*x(-3);for n=1:m x(n+1)=x(n)-f(x(n)/f1(x(n);endsqrta=x(n+1)运行结果:m=10sqrta = 10.723805294763608七、八、九章求解下面线性方程的解:A是一个主对角线为4,主对角线上下各三条对角线为1的100阶的方阵,b是一个1到100的一列矩阵。利用不同种方法就解线性方程组。Lu分解程序:clearformat shortn=input(n=);a=ones(n);b=diag(diag(a,-1),-1);c=diag(diag(a,-2),-2);d=diag(diag(a,1),1);e=diag(dia

5、g(a,2),2);g=diag(diag(a,3),3);h=diag(diag(a,-3),-3);f=4*eye(n);A=b+c+d+e+f+g+h;b=1:100;L,U=lu(A);x=U(Lb);x运行结果:n=100ans = Columns 1 through 11 0.0170 0.1855 0.3226 0.4239 0.4945 0.5886 0.6964 0.8050 0.9033 0.9993 1.0978 Columns 12 through 22 1.1996 1.3008 1.4006 1.4998 1.5997 1.6999 1.8001 1.9001 2.

6、0000 2.0999 2.2000 Columns 23 through 33 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000 3.1000 3.2000 3.3000 Columns 34 through 44 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 4.0000 4.1000 4.2000 4.3000 4.4000 Columns 45 through 55 4.5000 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 5.2000 5.300

7、0 5.4000 5.5000 Columns 56 through 66 5.6000 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 6.3000 6.4000 6.5000 6.6000 Columns 67 through 77 6.6999 6.8000 6.9001 7.0002 7.0999 7.1996 7.2998 7.4006 7.5009 7.5995 7.6976 Columns 78 through 88 7.7990 7.9039 8.0054 8.0964 8.1863 8.2949 8.4248 8.5292 8.5780 8

8、.6158 8.7831 Columns 89 through 99 9.0400 9.1815 8.9230 8.7585 9.1537 10.3911 10.2767 8.8545 6.4691 10.2662 14.0251 Column 100 17.3099Cholesky分解:clearformat shortn=input(n=);a=ones(n);b=diag(diag(a,-1),-1);c=diag(diag(a,-2),-2);d=diag(diag(a,1),1);e=diag(diag(a,2),2);g=diag(diag(a,3),3);h=diag(diag(

9、a,-3),-3);f=4*eye(n);A=b+c+d+e+f+g+h;b=1:100;R=chol(A);x=R(Rb);x运行结果:n=100ans = Columns 1 through 11 0.0170 0.1855 0.3226 0.4239 0.4945 0.5886 0.6964 0.8050 0.9033 0.9993 1.0978 Columns 12 through 22 1.1996 1.3008 1.4006 1.4998 1.5997 1.6999 1.8001 1.9001 2.0000 2.0999 2.2000 Columns 23 through 33 2

10、.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000 3.1000 3.2000 3.3000 Columns 34 through 44 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 4.0000 4.1000 4.2000 4.3000 4.4000 Columns 45 through 55 4.5000 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000 Columns 56 through 66 5.60

11、00 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 6.3000 6.4000 6.5000 6.6000 Columns 67 through 77 6.6999 6.8000 6.9001 7.0002 7.0999 7.1996 7.2998 7.4006 7.5009 7.5995 7.6976 Columns 78 through 88 7.7990 7.9039 8.0054 8.0964 8.1863 8.2949 8.4248 8.5292 8.5780 8.6158 8.7831 Columns 89 through 99 9.0400

12、9.1815 8.9230 8.7585 9.1537 10.3911 10.2767 8.8545 6.4691 10.2662 14.0251 Column 100 17.3099Jacobi方法迭代函数M文件:function y,n=jacobi(A,b,x0,eps)if nargin=3 eps=1.0e-6;elseif nargin=eps x0=y; y=B*x0+f; n=n+1;end程序:clearformat shortn=input(n=);a=ones(n);b=diag(diag(a,-1),-1);c=diag(diag(a,-2),-2);d=diag(di

13、ag(a,1),1);e=diag(diag(a,2),2);g=diag(diag(a,3),3);h=diag(diag(a,-3),-3);f=4*eye(n);A=b+c+d+e+f+g+h;b=1:n;m=diag(a);x,n=jacobi(A,b,m,1.0e-3);xn运行结果:因该方程的系数矩阵A不满足相关条件,故Jacobi方法迭代对该方程不适用Gauss-Serdel迭代方法函数M文件:function y,n=gauseidel(A,b,x0,eps)if nargin=3 eps=1.0e-6;elseif nargin=eps x0=y; y=G*x0+f; n=n

14、+1;end命令程序:clearformat longn=input(n=);a=ones(n);b=diag(diag(a,-1),-1);c=diag(diag(a,-2),-2);d=diag(diag(a,1),1);e=diag(diag(a,2),2);g=diag(diag(a,3),3);h=diag(diag(a,-3),-3);f=4*eye(n);A=b+c+d+e+f+g+h;b=1:n;m=diag(a);x,n=gauseidel(A,b,m,1.0e-10);xn运行结果:n=100ans = Columns 1 through 10 0.0170 0.1855

15、0.3226 0.4239 0.4945 0.5886 0.6964 0.8050 0.9033 0.9993 Columns 11 through 20 1.0978 1.1996 1.3008 1.4006 1.4998 1.5997 1.6999 1.8001 1.9001 2.0000 Columns 21 through 30 2.0999 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000 Columns 31 through 40 3.1000 3.2000 3.3000 3.4000 3.5000 3.6

16、000 3.7000 3.8000 3.9000 4.0000 Columns 41 through 50 4.1000 4.2000 4.3000 4.4000 4.5000 4.6000 4.7000 4.8000 4.9000 5.0000 Columns 51 through 60 5.1000 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 5.9000 6.0000 Columns 61 through 70 6.1000 6.2000 6.3000 6.4000 6.5000 6.6000 6.6999 6.8000 6.9001

17、 7.0002 Columns 71 through 80 7.0999 7.1996 7.2998 7.4006 7.5009 7.5995 7.6976 7.7990 7.9039 8.0054 Columns 81 through 90 8.0964 8.1863 8.2949 8.4248 8.5292 8.5780 8.6158 8.7831 9.0400 9.1815 Columns 91 through 100 8.9230 8.7585 9.1537 10.3911 10.2767 8.8545 6.4691 10.2662 14.0251 17.3099n =46幂法:建立m

18、atlab的函数文件eig_power.m如下:function V,D=eig_power(A)Maxtime=100;Eps=1E-5;n=length(A);V=ones(n,1);k=0;m0=0;while k=Maxtime v=A*V; vmax,i=max(abs(v); m=v(i); V=v/m; if abs(m-m0)Eps break; end m0=m; k=k+1;endD=m;在命令窗口中调用函数文件eig_power.m:a=linspace(4,4,100);c=linspace(1,1,99);d=linspace(1,1,98);e=linspace(1

19、,1,97);f=diag(a);g=diag(c,1);h=diag(c,-1);i=diag(d,2);j=diag(d,-2);k=diag(e,3);l=diag(e,-3);A=f+g+h+i+j+k+l;V,D=eig_power(A);VD输出结果:ans = Columns 1 through 9 0.5500 0.6800 0.8100 0.9400 0.9700 0.9900 1.0000 1.0000 1.0000 Columns 10 through 18 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1

20、.0000 Columns 19 through 27 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 Columns 28 through 36 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 Columns 37 through 45 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 Columns 46 through 54 1.0000 1.0000 1.0

21、000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 Columns 55 through 63 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 Columns 64 through 72 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 Columns 73 through 81 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 Columns 82 through 90 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 Columns 91 through 99 1.0000 1.0000 1.0000 1.0000 0.9900 0.9700 0.9400 0.8100 0.6800 Column 100 0.5500D =10其中D是最大特征值,V则是特征向量。

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

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