《数值分析实验报告7...doc》由会员分享,可在线阅读,更多相关《数值分析实验报告7...doc(14页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、实验七、QR 算法一、实验目的1、熟悉 matlab 编程并学习 QR 算法原理及计算机实现;2、学习用 matlab 内置函数 eig 和 QR 算法求矩阵的特征值,并比对二者差异。二、实验题目1、课本第 277 页第 1 题已知矩阵11263761172345078756, , .0899110ABH(1)用 MATLAB 函数“eig”求矩阵全部特征值;(2)用基本 QR 算法求全部特征值(可用 MATLAB 函数“qr ”实现矩阵的 QR 分解) 。2、用 QR 算法求矩阵特征值:136)(i 01098276354)(i根据 QR 算法原理编制求(i)及( ii)中矩阵全部特征值的程
2、序并输出计算结果(要求误差 A=10 7 8 7;7 5 6 5;8 6 10 9;7 5 9 10; B=2 3 4 5 6;4 4 5 6 7;0 3 6 7 8;0 0 2 8 9;0 0 0 1 0; H6=hilb(6);1、eig 求矩阵特征值 eig(A),eig(B),eig(H6)ans = 0.01015004839789240.8431071498550323.8580574559449530.2886853458021ans = 13.17235139810326.551878351915661.59565457314994-0.390788045416488-0.92
3、9096277752298ans = 1.08279948406811e-0071.25707571226224e-0050.0006157483541826520.01632152131987580.242360870575211.618899858924342、QR 算法求矩阵特征值 eig(A),qrsf(A,10-8)ans = 0.01015004839789240.8431071498550323.8580574559449530.2886853458021t = 10特征值 1=30.2887特征值 2=3.8581特征值 3=0.84311特征值 4=0.01015特征值 an
4、s = 30.2886853457915特征值 ans = 3.85805737835431特征值 ans = 0.843107227456257特征值 ans = 0.0101500483978911 eig(B),qrsf(B,10-8)ans = 13.17235139810326.551878351915661.59565457314994-0.390788045416488-0.929096277752298t = 2特征值 1=13.1724特征值 2=6.5519特征值 3=1.5957特征值 4=-0.9291特征值 5=-0.39079特征值 ans = 13.1723513
5、891479特征值 ans = 6.55187836087093特征值 ans = 1.59565457937031特征值 ans = -0.929096283974607特征值 ans = -0.390788045414554 eig(H6),qrsf(H6,10-8)ans = 1.08279948406811e-0071.25707571226224e-0050.0006157483541826520.01632152131987580.242360870575211.61889985892434t = 1特征值 1=1.6189特征值 2=0.24236特征值 3=0.016322特征
6、值 4=0.00061575特征值 5=1.2571e-005特征值 6=1.0828e-007特征值 ans = 1.6188998588068特征值 ans = 0.24236087069274特征值 ans = 0.01632152131988特征值 ans = 0.000615748354182639特征值 ans = 1.25707571226506e-005特征值 ans = 1.08279948456401e-0073、改进后的 QR 算法求特征值 eig(A),qrsf(A,10-8)ans = 0.01015004839789240.8431071498550323.8580
7、574559449530.2886853458021特征值 1=30.2887特征值 2=3.8581特征值 3=0.84311特征值 4=0.01015特征值 ans = 30.2886853458019特征值 ans = 3.85805745223919特征值 ans = 0.843107153560957特征值 ans = 0.0101500483978911 eig(B),qrsf(B,10-8)ans = 13.17235139810326.551878351915661.59565457314994-0.390788045416488-0.929096277752298特征值 1=
8、13.1724特征值 2=6.5519特征值 3=1.5957特征值 4=-0.9291特征值 5=-0.39079特征值 ans = 13.1723513936489特征值 ans = 6.55187835636998特征值 ans = 1.59565456952802特征值 ans = -0.929096274131193特征值 ans = -0.390788045415675 eig(H6),qrsf(H6,10-8)ans = 1.08279948406811e-0071.25707571226224e-0050.0006157483541826520.0163215213198758
9、0.242360870575211.61889985892434特征值 1=1.6189特征值 2=0.24236特征值 3=0.016322特征值 4=0.00061575特征值 5=1.2571e-005特征值 6=1.0828e-007特征值 ans = 1.61889985892171特征值 ans = 0.242360870577844特征值 ans = 0.0163215213198758特征值 ans = 0.000615748354182638特征值 ans = 1.25707571226506e-005特征值 ans = 1.08279948456401e-007六、实验结果
10、分析与小结从实验结果可以看出,用 MATLAB 内置函数 eig 求矩阵特征值与用 QR 算法求矩阵特征值的结果基本一致,数据只有微小差别。且单就 QR 算法而言,精度不同,计算出来特征值也存在一定的差异。不过这些微小差别对于计算来说影响不是很明显,除了有特殊需要要求更精确的数值外,这些结果已经能够满足计算结果的要求。七、附录3、eig 与 QR 算法求矩阵特征值的结果比较 eig(A),qrsf(A,10-8)ans = 0.01015004839789240.8431071498550323.8580574559449530.2886853458021t = 10特征值 1=30.2887
11、特征值 2=3.8581特征值 3=0.84311特征值 4=0.01015特征值 ans = 30.2886853457915特征值 ans = 3.85805737835431特征值 ans = 0.843107227456257特征值 ans = 0.0101500483978911A =Columns 1 through 330.2886853457915 1.67263719509357e-005 2.4658715813052e-0091.67263719456478e-005 3.85805737835431 0.0004836980794362152.4658734170851
12、9e-009 0.000483698079436138 0.843107227456257-5.08101348050736e-023 5.50511453327879e-018 -1.40098262801473e-013Column 4-1.07002288191827e-0158.90438591778815e-016-1.38231041042597e-0130.0101500483978911Q =Columns 1 through 3-0.999999999990602 4.33543882155126e-006 4.37465097621799e-010-4.3354378570
13、8671e-006 -0.999999835419719 0.000573708757424641-2.92474424482639e-009 -0.000573708757417352 -0.999999835429117-5.00590074187535e-021 5.42373229907221e-016 -1.38027186974381e-011Column 4-1.31911901611722e-0218.46111373361065e-015-1.38027161147482e-0111R =Columns 1 through 3-30.2886853454344 -0.0001
14、48041080872945 -1.00648595392028e-0070 -3.85805646596483 -0.002697099304463010 0 -0.843107366207180 0 0Column 4-1.07019946786611e-015-3.69340289178865e-015-1.17754026710534e-0110.0101500483978911 eig(B),qrsf(B,10-8)ans = 13.17235139810326.551878351915661.59565457314994-0.390788045416488-0.9290962777
15、52298t = 2特征值 1=13.1724特征值 2=6.5519特征值 3=1.5957特征值 4=-0.9291特征值 5=-0.39079特征值 ans = 13.1723513891479特征值 ans = 6.55187836087093特征值 ans = 1.59565457937031特征值 ans = -0.929096283974607特征值 ans = -0.390788045414554A =Columns 1 through 313.1723513891479 -11.2224332964075 1.38327278837818-5.28299810482253e-
16、009 6.55187836087093 -1.450972623750310 -4.57824183023911e-018 1.595654579370310 0 4.55829734055894e-0080 0 0Columns 4 through 512.2876570415913 2.18439169839953-5.46614907884632 -0.424112905513863-0.344534349380365 2.00394783492873-0.929096283974607 -0.2949149322931933.5295461400519e-012 -0.3907880
17、45414554Q =Columns 1 through 3-1 -8.06333361799512e-010 -2.31352650689045e-0278.06333361799512e-010 -1 -2.86919358232593e-0180 2.86919358232594e-018 -0.9999999999999990 0 4.90616249270291e-0080 0 0Columns 4 through 5-1.13505369739799e-034 -1.02516554521335e-045-1.40767299379114e-025 -1.2713917019698
18、5e-036-4.90616249270291e-008 -4.43118132496026e-019-0.999999999999999 -9.03186825049292e-012-9.03186825049293e-012 1R =Columns 1 through 3-13.1723513800989 11.2224333070288 -1.38327339123060 -6.55187836087093 1.450972891928470 0 -1.59565456246690 0 00 0 0Columns 4 through 5-12.2876569737454 2.184391
19、698288555.46614900766307 -0.4241129054644930.344534427647672 2.003947834931840.929096283977272 -0.2949149322848020 -0.390788045414554 eig(H6),qrsf(H6,10-8)ans = 1.08279948406811e-0071.25707571226224e-0050.0006157483541826520.01632152131987580.242360870575211.61889985892434t = 1特征值 1=1.6189特征值 2=0.24
20、236特征值 3=0.016322特征值 4=0.00061575特征值 5=1.2571e-005特征值 6=1.0828e-007特征值 ans = 1.6188998588068特征值 ans = 0.24236087069274特征值 ans = 0.01632152131988特征值 ans = 0.000615748354182639特征值 ans = 1.25707571226506e-005特征值 ans = 1.08279948456401e-007A =Columns 1 through 31.6188998588068 1.27197394498537e-005 1.19
21、768529656603e-0121.2719739449838e-005 0.24236087069274 3.08869246409526e-0081.19788968013046e-012 3.08869246092437e-008 0.01632152131988-3.6564854489204e-021 -1.05134059527256e-016 -8.3901223728756e-011-2.51874460802941e-031 -7.62887310800373e-027 -7.24698049380747e-0217.33769428846597e-044 2.287556
22、93138363e-039 2.38462685027147e-033Columns 4 through 6-4.65299860612185e-017 -7.85630875258594e-017 -4.99030380731949e-017-4.69661140762161e-017 5.64100067650242e-017 -2.24039311154526e-017-8.39012342417141e-011 -1.90672523361959e-017 9.70102034419473e-0180.000615748354182639 8.55921938191856e-014 -
23、5.5822503075125e-0188.560823435926e-014 1.25707571226506e-005 -1.79372765726032e-017-3.50196992607807e-026 -8.60412731528914e-018 1.08279948456401e-007Q =Columns 1 through 3-0.999999998622786 5.24826445620704e-005 -2.59251450345072e-011-5.24826445620255e-005 -0.999999998620995 1.89240475959173e-006-
24、7.33932613664668e-011 -1.8924047583461e-006 -0.99999999999825.93827888305781e-018 1.70741925354901e-013 1.36258949226309e-0072.00365386384803e-026 6.06874592641492e-022 5.76495148470373e-0166.77659566066424e-037 2.11263208377376e-032 2.20227926247271e-026Columns 4 through 6-5.09824115576308e-019 3.4
25、008272077694e-028 1.97571398705825e-0398.71151586217316e-014 -1.0917621219594e-022 -1.05044049606577e-033-1.36258949226388e-007 3.51443236235137e-016 5.88051420890885e-027-0.999999999999991 6.81010964765256e-009 2.17725918000353e-019-6.81010964765255e-009 -1 -7.9461871176948e-011-3.23418137522306e-0
26、19 -7.9461871176948e-011 1R =Columns 1 through 3-1.61889985590967 -9.76838853035816e-005 -1.44084921219927e-0100 -0.242360871026031 -4.89531790510286e-0070 0 -0.01632152131990910 0 00 0 00 0 0Columns 4 through 65.84784525152272e-017 7.8563087887546e-017 -4.99030380669521e-0174.56367477791708e-014 -5.64098415545824e-017 -2.2403931119935e-0172.30785457906863e-009 2.90479067967698e-017 9.70102034609643e-018-0.000615748354182645 -4.2789060011646e-012 -5.58245625301427e-0180 -1.25707571226506e-005 -1.01683315964937e-0150 0 1.08279948456401e-0074、eig 与改进后的 QR 算法求矩阵特征值的结果比较 eig(A),qrsf(A,10-8)