《丁丽娟《数值计算方法》五章课后实验题答案(源程序很详细,且运行无误).docx》由会员分享,可在线阅读,更多相关《丁丽娟《数值计算方法》五章课后实验题答案(源程序很详细,且运行无误).docx(42页珍藏版)》请在第壹文秘上搜索。
1、丁丽娟数值计算方法五章课后实验题答案(源程序都是自己写的,很详细,且保证运行无误)我做的五章数值实验作业题目如下:第二章:1、2、3、4题第三章:1、2题第四章:1、2题第六章:2、3题第八章:1、2题第二章(D对A进行列主元素三角分解:function1u=myfun(八)n=size(八);fork=l:nfori=k:nsum=0;m=k;forj=k(k-l)sum=sum+A(i,j)*A(j,k);ends(i)=A(i,k)-sum;ifabs(s(m)A=11111;12345;1361015;14102035;15153570;L,U=myfun(八)结果:L=1.00000
2、0001.00001.00000001.00000.50001.0000001.00000.75000.75001.000001.00000.25000.7500-1.00001.0000O4.000014.000034.000069.000000-2.0000-8.0000-20.5000000-0.5000-2.37500000-0.2500(2)求矩阵的逆矩阵A1:inv(八)结果为:ans=5-1010-51-1030-3519-410-3546-276-519-2717-41-46-41(3)检验结果:E=diag(lIlll)AEans=5-1010-51-519-2717-41-
3、46-41程序:functiond=myfun(a,b,c,d,n)fori=2:nl(i)=a(i)b(i-l);a(i)=l(i);u(i)=b(i)-c(i-l)*a(i);b(i)=u(i);y(i)=d(i)-a(i)*d(i-l);d(i)=y(i);endx(n)=d(n)b(n);d(n)=x(n);fori=(n-l):-l:lx(i)=(d(i)-c(i)*d(i+l)b(i);d(i)=x(i);end求各段电流量程序:a(i)=-2;endb=25555555;c=-2-2-2-2-2-2-2;V=220;R=27;d=VROOOOOOO;n=8;I=myfun(a,b
4、,c,d,n)运行程序得:I=8.14784.07372.03651.01750.50730.25060.11940.0477(1)求矩阵A和向量b的matlab程序:functionAb=myfun(n)fori=l:nX(i)=l0.1*i;endfori=l:nforj=l:nendendfori=l:nb(i)=sum(A(i,:);end求n=5时Al,bl及Al的2.条件数程序运行结果如下:n=5;Al,bl=myfun(n)Al=1.00001.10001.21001.33101.46411.00001.20001.44001.72802.07361.00001.30001.69
5、002.19702.85611.00001.40001.96002.74403.84161.00001.50002.25003.37505.0625bl=6.10517.44169.043110.945613.1875cond2=cond(A1,2)求n=10时A2,b2及A2的2.条件数程序运行结果如下:n=10;A2,b2=myfun(n)A2=1.0000.ooo1.21001.33IO1.46411.61051.77161.94872.14362.35791.00001.2(XX)1.44(X)1.72802.07362.4B832.98603.58324.29985.15981.00
6、001.30001.69002.19702.85613.71294.82686.27498.157310.60451.00001.40001.96002.74403.84165.37827.529510.541414.757920.66101.00001.50002.25003.37505.06257.593811.390617.085925.628938.44341.00001.60002.56004.09606.553610.485816.777226.843542.949768.71951.00001.70002.894.91308.352114.198624.137641.033969
7、.7576118.58791.00001.80003.24005.832010.497618.895734.012261.2220110.1996198.35931.00001.90003.61006.859013.032124.761047.045989.3872169.8356322.68771.00002.00004.00008.0000I6.OO32.000064.00I28.OO256.00512.0000b2=1.0e+003*0.01590.02600.04260.06980.11330.18160.28660.44510.68011.0230cond2=cond(A2,2)co
8、nd2=8.6823e+011求n=20时A3,b3及A3的2-条件数程序运行结果如下:n=20;A3,b3=myfun(n)A3=0.00000.00000.00000.00000.000.0000O.(XX)O0.00000.000.000.000.00000.000.00000.00000.00000.000.00000.00000.000.00000.000.000.00000.000.000.00000.00000.00000.00000.00000.000.00000.00000.000.00000.00000.000.00000.00000.000.00000.000.00000
9、.00000.00000.000.00000.00000.00000.0000O.(XX)O0.00000.0000O.O(XX)0.00O.(XX)O0.00000.00000.000.00000.000.000.00000.000.000.00000.00000.00000.00000.00000.000.00000.00000.000.00000.00000.000.00000.00000.00000.00000.00000.00000.000.0000O.O(XX)O.(XX)O0.00000.00000.000.00000.000.00000.00000.00000.000.0000
10、0.00000.000.00000.000.000.00000.000.00000.000.00000.00000.000.00000.000.00000.00000.000.00000.00000.000.00000.00000.00000.00000.00000.00000.000.0000O.O(XX)O.(XX)O0.00000.00000.00000.000.00000.00000.0000O.(XXX)0.0000O.(XX)O0.00O.O(XX)0.00000.000.000.00000.000.000.00000.00000.00000.00000.000.00000.000
11、.00000.00000.00000.000.00000.00000.00000.00000.00000.00000.00000.000.0000O.O(XX)O.(XX)O0.00000.00000.0000O.(XX)O0.00000.00000.00O.(XXX)0.0000O.(XX)O0.000.00000.00000.000.000.00O.O(XX)0.000.000.000.00000.000.000.00000.000.000.00000.00000.000.00000.00000.0000Columns11through200.00000.00000.000.000.000.00000.00000.00000.000.00000.0000O.(XX)O0.00000.00000.00O.(XXX)0.00000.00000.000.00000.00000.000.000.00000