大连理工大学线性代数实验上机报告.docx
- 文档编号:9001759
- 上传时间:2023-02-02
- 格式:DOCX
- 页数:26
- 大小:39.71KB
大连理工大学线性代数实验上机报告.docx
《大连理工大学线性代数实验上机报告.docx》由会员分享,可在线阅读,更多相关《大连理工大学线性代数实验上机报告.docx(26页珍藏版)》请在冰豆网上搜索。
大连理工大学线性代数实验上机报告
大连理工大学线性代数实验上机报告
———————————————————————————————— 作者:
———————————————————————————————— 日期:
大连理工大学线性代数实验上机报告
实验一
首先随机生成五阶方阵A
A=rand(5)
A=
0.8147 0.0975 0.1576 0.1419 0.6557
0.9058 0.2785 0.9706 0.42180.0357
0.1270 0.54690.9572 0.9157 0.8491
0.9134 0.9575 0.48540.7922 0.9340
0.63240.9649 0.8003 0.9595 0.6787
>>B=rand(5)
随机生成五阶方阵B
B=
0.7577 0.7060 0.8235 0.4387 0.4898
0.7431 0.03180.6948 0.3816 0.4456
0.3922 0.27690.31710.76550.6463
0.6555 0.04620.95020.7952 0.7094
0.1712 0.0971 0.0344 0.1869 0.7547
>>b=rand(1,5)'
随机生成列向量b
b=
0.2760
0.6797
0.6551
0.1626
0.1190
计算A+B
>>A+B
ans=
1.57250.80360.9811 0.5806 1.1455
1.6489 0.3103 1.66540.8033 0.4813
0.51920.8238 1.2743 1.68131.4954
1.5689 1.0037 1.4356 1.58741.6434
0.8035 1.06200.8347 1.14641.4334
计算A-B
>>A-B
ans=
0.0570 -0.6085-0.6658-0.2969 0.1660
0.16270.2467 0.27580.0402-0.4099
-0.2652 0.27000.6401 0.1502 0.2028
0.2579 0.9113-0.4648-0.0030 0.2246
0.4612 0.8678 0.7658 0.7726-0.0760
计算A*B+B*A
>>A*B+B*A
ans=
3.02882.3058 3.14392.72763.1034
2.90942.1967 3.0040 3.0737 3.2584
3.3422 2.1423 3.2104 3.57343.9049
4.1446 2.9794 4.3676 4.2354 4.9170
3.1350 1.7787 3.2289 3.11703.2815
求Ax=b的解
>> x=A\b
x=
-0.9850
2.4396
3.3124
-5.6515
1.7085
验证克莱姆法则
>>c=A(:
1)
c=
0.8147
0.9058
0.1270
0.9134
0.6324
>>d=A(:
2)
d=
0.0975
0.2785
0.5469
0.9575
0.9649
>>e=A(:
3)
e=
0.1576
0.9706
0.9572
0.4854
0.8003
>>f=A(:
4)
f =
0.1419
0.4218
0.9157
0.7922
0.9595
>>g=A(:
5)
g=
0.6557
0.0357
0.8491
0.9340
0.6787
>>B1=[b';d';e';f';g']'
B1=
0.2760 0.0975 0.1576 0.14190.6557
0.67970.2785 0.9706 0.4218 0.0357
0.6551 0.5469 0.95720.9157 0.8491
0.1626 0.9575 0.4854 0.7922 0.9340
0.1190 0.9649 0.8003 0.9595 0.6787
>>B2=[c';b';e';f';g']'
B2=
0.81470.2760 0.15760.1419 0.6557
0.90580.67970.97060.4218 0.0357
0.1270 0.6551 0.95720.91570.8491
0.91340.16260.4854 0.7922 0.9340
0.6324 0.1190 0.8003 0.95950.6787
>> B3=[c';d';b';f';g']'
B3 =
0.8147 0.09750.2760 0.14190.6557
0.90580.2785 0.6797 0.42180.0357
0.1270 0.54690.6551 0.9157 0.8491
0.9134 0.9575 0.1626 0.7922 0.9340
0.63240.9649 0.11900.9595 0.6787
>> B4=[c';d';e';b';g']'
B4 =
0.8147 0.0975 0.1576 0.2760 0.6557
0.9058 0.2785 0.9706 0.6797 0.0357
0.1270 0.54690.95720.65510.8491
0.91340.95750.4854 0.16260.9340
0.6324 0.96490.80030.1190 0.6787
>>B5=[c';d';e';f';b']'
B5=
0.81470.0975 0.15760.14190.2760
0.9058 0.27850.97060.42180.6797
0.1270 0.5469 0.9572 0.91570.6551
0.9134 0.9575 0.4854 0.7922 0.1626
0.63240.9649 0.80030.9595 0.1190
>>x1=det(B1)/det(A)
x1=
-0.9850
>> x2=det(B2)/det(A)
x2=
2.4396
>> x3=det(B3)/det(A)
x3=
3.3124
>> x4=det(B4)/det(A)
x4=
-5.6515
>> x5=det(B5)/det(A)
x5=
1.7085
计算A的行列式
>>det(A)
ans=
-0.0250
计算B的行列式
>>det(B)
ans =
0.0647
求A的逆
>> inv(A)
ans=
3.1375 -0.8078-1.8788-4.2194 5.1680
-8.6076 3.5314 2.890713.7204-14.3665
-6.2824 3.72203.6132 10.0084 -12.4190
13.6173-6.8822 -6.3938 -23.5288 27.5825
-2.5292 1.0729 2.4193 5.8870-7.2671
求B的逆
>>inv(B)
ans=
-0.4430 3.4997 1.3255-2.6005 -0.4697
1.4047-1.16260.2422-0.4475 -0.0119
0.7210 -1.8189 -2.0635 2.44340.0765
-0.6122 -0.1837 2.0165 0.0375-1.2564
0.0384 -0.5157 -0.7370 0.5267 1.7407
求A的秩
>>rank(A)
ans=
5
求B的秩
>> rank(B)
ans=
5
求A*B的行列式
>>det(A*B)
ans =
-0.0016
求A*B的逆
>>inv(A*B)
ans=
-74.0649 35.0433 31.2288 121.5740-137.3442
6.8291 -1.2718 -2.2922 -8.9951 8.6972
63.9620-31.4202 -29.5061 -105.6918 122.3246
-9.3196 5.7452 4.6259 11.9660-15.4028
11.9582 -6.3521 -3.3817-16.7574 18.6360
>>rank(A*B)
ans =
5
>>det(A)*det(B)
ans=
-0.0016
验证
(1)
>>(A*B)'
ans=
0.9569 1.5566 1.6237 2.2732 2.2552
0.69220.9401 0.4969 0.93710.8090
0.94611.64921.6875 2.3563 2.3800
0.7507 1.5887 1.8840 1.9421 2.1481
1.1399 1.52122.2149 2.45452.4497
>>B'*A'
ans=
0.9569 1.55661.6237 2.27322.2552
0.69220.94010.49690.9371 0.8090
0.9461 1.6492 1.6875 2.35632.3800
0.75071.5887 1.8840 1.9421 2.1481
1.13991.5212 2.2149 2.45452.4497
(2)
>> inv(B)*inv(A)
ans=
-74.064935.0433 31.2288 121.5740-137.3442
6.8291 -1.2718 -2.2922 -8.99518.6972
63.9620-31.4202 -29.5061-105.6918 122.3246
-9.3196 5.7452 4.6259 11.9660-15.4028
11.9582 -6.3521-3.3817-16.757418.6360
(3)
>> A*B
ans=
0.95690.6922 0.9461 0.7507 1.1399
1.55660.9401 1.6492 1.58871.5212
1.62370.4969 1.6875 1.8840 2.2149
2.2732 0.9371 2.3563 1.9421 2.4545
2.25520.8090 2.3800 2.14812.4497
>>B*A
ans=
2.07191.61352.19781.9769 1.9635
1.3528 1.2566 1.3549 1.4850 1.7372
1.7186 1.6454 1.52291.6894 1.6900
1.8714 2.0423 2.0113 2.2932 2.4625
0.8797 0.9697 0.8489 0.9690 0.8317
求矩阵X使得AXB=C
首先随机生成五阶方阵C
>>C=rand(5)
C =
0.49840.75130.9593 0.8407 0.3500
0.9597 0.2551 0.5472 0.25430.1966
0.34040.5060 0.1386 0.8143 0.2511
0.5853 0.6991 0.1493 0.2435 0.6160
0.2238 0.8909 0.2575 0.9293 0.4733
X=A的逆*B的逆
>>X=inv(A)*C*inv(B)
X=
3.8432 -13.8858 2.1418 9.4404 -4.5871
-9.331241.9602-7.9101-28.4683 14.8942
-7.8738 35.1218 -5.4107-22.886110.1581
16.7545-75.6079 14.6784 49.3951-24.7450
-3.5568 17.0848 -2.9018 -11.2670 5.4559
实验二
1.验证:
对于一般的方阵A,B,C,D,
首先随机生成方阵A,B,C,D
A=rand(5)
A =
0.82580.10670.8687 0.43140.1361
0.5383 0.9619 0.0844 0.9106 0.8693
0.9961 0.0046 0.39980.1818 0.5797
0.0782 0.7749 0.2599 0.2638 0.5499
0.4427 0.8173 0.8001 0.1455 0.1450
>>B=rand(5)
B=
0.85300.0760 0.4173 0.4893 0.7803
0.6221 0.2399 0.0497 0.3377 0.3897
0.3510 0.1233 0.90270.9001 0.2417
0.5132 0.1839 0.9448 0.3692 0.4039
0.40180.2400 0.4909 0.1112 0.0965
>>C=rand(5)
C=
0.13200.2348 0.1690 0.54700.1835
0.94210.35320.6491 0.29630.3685
0.9561 0.8212 0.73170.7447 0.6256
0.57520.0154 0.6477 0.1890 0.7802
0.05980.0430 0.4509 0.68680.0811
>>D=rand(5)
D=
0.92940.3063 0.6443 0.9390 0.2077
0.7757 0.50850.3786 0.87590.3012
0.48680.51080.8116 0.5502 0.4709
0.4359 0.8176 0.5328 0.6225 0.2305
0.4468 0.7948 0.35070.5870 0.8443
>>Z=[A,B;C,D]
Z=
0.82580.1067 0.86870.4314 0.1361
0.8530ﻩﻩ0.0760 0.4173 0.4893 0.7803
0.5383 0.9619 0.0844 0.91060.8693
0.6221 0.2399 0.04970.3377 0.3897
0.99610.0046 0.3998 0.18180.5797
0.3510 0.1233 0.9027 0.90010.2417
0.0782 0.7749 0.25990.2638 0.5499
0.51320.18390.9448 0.36920.4039
0.4427 0.81730.80010.1455 0.1450 0.40180.24000.4909 0.1112 0.0965
0.1320 0.23480.1690 0.5470 0.1835 0.92940.3063 0.6443 0.9390 0.2077
0.9421 0.3532 0.6491 0.29630.36850.7757 0.5085 0.3786 0.8759 0.3012
0.9561 0.8212 0.7317 0.7447 0.6256 0.4868 0.5108 0.8116 0.5502 0.4709
0.5752 0.0154 0.6477 0.18900.7802 0.4359 0.8176 0.53280.62250.2305
0.0598 0.0430 0.4509 0.6868 0.0811 0.44680.79480.3507 0.5870 0.8443
求Z的行列式
>>det(Z)
ans=
-0.0295
求det(A)*det(D)-det(B)*det(C)
>>det(A)*det(D)-det(B)*det(C)
ans =
1.8656e-004
随机生成对角矩阵A
>>A=diag([randrandrandrand rand])
A=
0.1948 0 0 0 0
00.2259 0 0 0
0 0 0.1707 0 0
0 0 0 0.2277 0
00 0 0 0.4357
随机生成对角矩阵B
>> B=diag([randrandrand randrand])
B=
0.3111 00 0 0
0 0.9234 0 0 0
0 00.4302 0 0
00 00.1848 0
0 0 0 0 0.9049
随机生成对角矩阵C
>>C=diag([randrandrandrandrand])
C=
0.9797 0 0 0 0
0 0.4389 0 0 0
0 0 0.1111 0 0
0 0 00.2581 0
0 0 0 0 0.4087
随机生成对角矩阵D
>> D=diag([rand randrandrand rand])
D =
0.5949 0 0 0 0
0 0.2622 0 0 0
0 0 0.6028 0 0
0 0 0 0.7112 0
0 0 0 0 0.2217
>> Z=[A,B;C,D]
Z =
0.1948 0 0 000.3111 0 0 0 0
0 ﻩﻩ0.2259 0 0 0
0 0.9234 0 0 0
0ﻩ00.1707 0 0 00 ﻩ0.4302 0 0
0 0 0 ﻩ0.2277 0
0 0 0 0.18480
0 0 0 0 0.4357 0 ﻩ0 00 0.9049
0.9797 0 0 0 0 0.5949 0 0 0 0
00.4389 0 0 0 0 0.2622 0 00
0 0 0.1111 0 0 0 0 0.6028 00
0 0 00.25810 0 0 0 0.7112 0
0 0 0 0 0.4087 0 0 0 0 0.2217
计算Z的行列式
>>det(Z)
ans=
-1.1243e-004
计算det(A)*det(D)-det(B)*det(C)
>>det(A)*det(D)-det(B)*det(C)
ans=
-9.3107e-005
计算A*D-B*C的行列式
>>det(A*D-B*C)
ans=
-1.1243e-004
实验三
求A列向量组的一个最大无关组,并把不属于
极大无关组的向量利用极大无关组表示.
N= 200865083;
a=83;
b=86;
c=50;
d=88;
e=28;
f=63;
g=83;
h=60;
>>A=[a,b,c,d,3,4;1,2,3,4,4,3;12,15,22,17,5,7;e,f,g,h,8,0];
>> B=rref(A)
B
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 大连理工大学 线性代数 实验 上机 报告