‍(1) 估计5到20阶Hilbert矩阵得范数条件数 (2) 设,咨信网zixin.com.cn" /> ‍(1) 估计5到20阶Hi"/>
收藏 分销(赏)

数值线性代数第二版上机习题第二章实验报告.doc

上传人:丰**** 文档编号:4365871 上传时间:2024-09-13 格式:DOC 页数:8 大小:32KB 下载积分:6 金币
下载 相关 举报
数值线性代数第二版上机习题第二章实验报告.doc_第1页
第1页 / 共8页
数值线性代数第二版上机习题第二章实验报告.doc_第2页
第2页 / 共8页


点击查看更多>>
资源描述
<p><span id="_baidu_bookmark_start_0" style="display: none; line-height: 0px;">‍</span>(1) 估计5到20阶Hilbert矩阵得范数条件数 (2) 设,先随机地选取,并计算出;然后再用列主元Gauss消去法求解该方程组,假定计算解为。试对n从5到30估计计算解得精度,并且与真实相对误差作比较。 解(1)分析:利用使从5循环到20,利用函数得到Hilbert矩阵;先将算法2、5、1编制成通用得子程序,利用算法2、5、1编成得子程序,对求解,得到得一个估计值;再利用得到;则条件数。 另,矩阵得范数条件数可由直接算出,两者可进行比较。 程序为 &nbsp; 1 算法2、5、1编成得子程序 function v=opt(B) k=1; n=length(B); x=1、/n*ones(n,1); while k==1 &nbsp; &nbsp;w=B*x; &nbsp; &nbsp;v=sign(w); &nbsp; &nbsp;z=B&#39;*v; &nbsp; &nbsp;if norm(z,inf)&lt;=z 2=&quot;&quot; 67=&quot;&quot; 422=&quot;&quot; 5079=&quot;&quot; 7717=&quot;&quot; 943656=&quot;&quot; x=&quot;zeros(n,1);&quot; v=&quot;opt(B);&quot; k=&quot;1;&quot; else=&quot;&quot; end=&quot;&quot; ex2_1=&quot;&quot; for=&quot;&quot; n=&quot;11&quot; a=&quot;hilb(n);&quot; b=&quot;inv(A、&#39;);&quot; k1=&quot;v*norm(A,inf);&quot; k2=&quot;cond(A,inf);&quot; 0028=&quot;&quot; 1232433965549344=&quot;&quot; warning:=&quot;&quot; matrix=&quot;&quot; is=&quot;&quot; close=&quot;&quot; to=&quot;&quot; singular=&quot;&quot; or=&quot;&quot; badly=&quot;&quot; results=&quot;&quot; may=&quot;&quot; be=&quot;&quot; rcond=&quot;2、547634e-17、&quot;&gt; In ex2_1 at 3 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;2、547634e-17、 &gt; In cond at 47 &nbsp;In ex2_1 at 6 n=12 估计条件数为3、9245e+16 实际条件数为3、9245e+16 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;7、847381e-19、 &gt; In ex2_1 at 3 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;7、847381e-19、 &gt; In cond at 47 &nbsp;In ex2_1 at 6 n=13 估计条件数为1、2727e+18 实际条件数为1、2727e+18 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;2、246123e-18、 &gt; In ex2_1 at 3 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;2、246123e-18、 &gt; In cond at 47 &nbsp;In ex2_1 at 6 n=14 估计条件数为4、8374e+17 实际条件数为4、8374e+17 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;8、491876e-19、 &gt; In ex2_1 at 3 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;8、491876e-19、 &gt; In cond at 47 &nbsp;In ex2_1 at 6 n=15 估计条件数为4、6331e+17 实际条件数为5、234289848563619e+17 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;9、137489e-19、 &gt; In ex2_1 at 3 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;9、137489e-19、 &gt; In cond at 47 &nbsp;In ex2_1 at 6 n=16 估计条件数为8、3166e+17 实际条件数为8、3167e+17 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;6、244518e-19、 &gt; In ex2_1 at 3 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;6、244518e-19、 &gt; In cond at 47 &nbsp;In ex2_1 at 6 n=17 估计条件数为1、43e+18 实际条件数为1、43e+18 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;4、693737e-19、 &gt; In ex2_1 at 3 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;4、693737e-19、 &gt; In cond at 47 &nbsp;In ex2_1 at 6 n=18 估计条件数为2、5551e+18 实际条件数为2、8893e+18 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;4、264685e-19、 &gt; In ex2_1 at 3 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;4、264685e-19、 &gt; In cond at 47 &nbsp;In ex2_1 at 6 n=19 估计条件数为2、411858563109357e+18 实际条件数为2、411858563109357e+18 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;1、351364e-19、 &gt; In ex2_1 at 3 Warning: Matrix is close to singular or badly scaled、 Results may be inaccurate、 RCOND = &nbsp;1、351364e-19、 &gt; In cond at 47 &nbsp;In ex2_1 at 6 n=20 估计条件数为2、31633670586674e+18 实际条件数为6、37335273308473e+18 结果分析 随着矩阵阶数增加,估计值误差开始出现,时估计条件数与实际值存在误差;且条件数很大,Hilbert矩阵为病态得。 解(2)分析:先根据题目要求,利用与使从5循环到30,作出与随机得,并计算出;然后再利用第一章习题中得到得与用列主元Gauss消去法求解该方程组,假定计算解为,得,利用第(1)问所得函数计算得一个估计值,利用计算得无穷范数,则得相对误差估计为,真实相对误差为。 程序为 1 列主元Gauss消去法求解该方程组得程序为 得分解: function [L,U,P]=GaussCol(A) n=length(A); for k=1:n-1 [s,t]=max(abs(A(k:n,k))); p=t+k-1; temp=A(k,1:n); A(k,1:n)=A(p,1:n); A(p,1:n)=temp; u(k)=p; if A(k,k)~=0 &nbsp; &nbsp;A(k+1:n,k)=A(k+1:n,k)/A(k,k); &nbsp; &nbsp;A(k+1:n,k+1:n)=A(k+1:n,k+1:n)-A(k+1:n,k)*A(k,k+1:n); else &nbsp; &nbsp;break; end end L=tril(A); U=triu(A); L=L-diag(diag(L))+diag(ones(1,n)); P=eye(n); for i=1:n-1 &nbsp; &nbsp;temp=P(i,:); &nbsp; &nbsp;P(i,:)=P(u(i),:); &nbsp; &nbsp;P(u(i),:)=temp; end end 高斯消去法解线性方程组 function x=Gauss(A,b,L,U,P) if nargin&lt;5 &nbsp; &nbsp;P=eye(length(A)); end n=length(A); b=P*b; for j=1:n-1 &nbsp; &nbsp;b(j)=b(j)/L(j,j); &nbsp; &nbsp;b(j+1:n)=b(j+1:n)-b(j)*L(j+1:n,j); end b(n)=b(n)/L(n,n); y=b; for j=n:-1:2 &nbsp; &nbsp;y(j)=y(j)/U(j,j); &nbsp; &nbsp;y(1:j-1)=y(1:j-1)-y(j)*U(1:j-1,j); end y(1)=y(1)/U(1,1); x=y; end 2 问题(2)求解ex2_2 for n=5:30 &nbsp; &nbsp;A=2*eye(n)+tril(-1*ones(n)); A(1:n-1,n)=ones(n-1,1); &nbsp; &nbsp;x=100*rand(n,1); &nbsp; &nbsp;b=A*x; &nbsp; &nbsp;[L,U,P]=GaussCol(A); x1=Gauss(A,b,L,U,P); &nbsp; &nbsp;r=b-A*x1; &nbsp; &nbsp;p1=norm(r,inf)*opt(inv(A、&#39;))*norm(A,inf)/norm(b,inf); &nbsp; &nbsp;p2=norm(x-x1,inf)/norm(x,inf); &nbsp; &nbsp;disp([&#39;n=&#39;,num2str(n)]) &nbsp; &nbsp;disp([&#39;估计相对误差为&#39;,num2str(p1)]) disp([&#39;实际相对误差为&#39;,num2str(p2)]) y1(n-4)=p1;y2(n-4)=p2; end plot(5:30,y1,5:30,y2) legend(&#39;估计相对误差&#39;,&#39;实际相对误差&#39;) 计算结果为 n=5 估计相对误差为2、8265e-15 实际相对误差为3、1615e-16 n=6 估计相对误差为3、3434e-15 实际相对误差为2、8523e-16 n=7 估计相对误差为9、882e-16 实际相对误差为1、7941e-16 n=8 估计相对误差为4、8733e-14 实际相对误差为1、0891e-14 n=9 估计相对误差为2、2282e-14 实际相对误差为3、6143e-15 n=10 估计相对误差为1、5622e-14 实际相对误差为3、9702e-15 n=11 估计相对误差为1、9668e-14 实际相对误差为5、1566e-15 n=12 估计相对误差为4、808e-14 实际相对误差为8、5677e-15 n=13 估计相对误差为2、8696e-13 实际相对误差为4、0392e-14 n=14 估计相对误差为1、5109e-12 实际相对误差为3、8759e-13 n=15 估计相对误差为4、3829e-13 实际相对误差为1、67e-13 n=16 估计相对误差为8、7941e-13 实际相对误差为2、6417e-13 n=17 估计相对误差为2、4842e-12 实际相对误差为5、8841e-13 n=18 估计相对误差为7、6311e-12 实际相对误差为2、4718e-12 n=19 估计相对误差为1、9214e-11 实际相对误差为5、9876e-12 n=20 估计相对误差为5、612e-11 实际相对误差为1、5802e-11 n=21 估计相对误差为1、7181e-11 实际相对误差为2、1433e-12 n=22 估计相对误差为1、0565e-11 实际相对误差为2、8952e-12 n=23 估计相对误差为6、9651e-12 实际相对误差为1、2037e-12 n=24 估计相对误差为3、1487e-10 实际相对误差为1、4479e-10 n=25 估计相对误差为9、884e-10 实际相对误差为2、3499e-10 n=26 估计相对误差为4、1606e-09 实际相对误差为6、3158e-10 n=27 估计相对误差为5、8332e-09 实际相对误差为1、7298e-09 n=28 估计相对误差为3、9754e-09 实际相对误差为6、9346e-10 n=29 估计相对误差为7、8248e-09 实际相对误差为1、4376e-09 n=30 估计相对误差为1、1681e-07 实际相对误差为2、0748e-08 结果分析 n较小时估计得较好,随着n得增大估计值误差增大</p><!--=z-->
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 教育专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服