《2022年5线性代数方程组数值解法.docx》由会员分享,可在线阅读,更多相关《2022年5线性代数方程组数值解法.docx(19页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精品学习资源试验 5 线性代数方程组的数值解法化工系毕啸天 2021011811【试验目的】1. 学会用 MATLAB 软件数值求解线性代数方程组,对迭代法的收敛性和解的稳固性作初步分析;2. 通过实例学习用线性代数方程组解决简化的实际问题;【试验内容】题目 3已知方程组 Ax=b,其中 A, 定义为A31/ 21/ 41/ 231/ 21/ 41/ 231/ 41/ 21/ 41/ 21/ 431/ 21/ 41/ 23试通过迭代法求解此方程组,熟悉迭代法收敛的含义以及迭代初值和方程组系数矩阵性质对收敛速度的影响;试验要求:b5E2RGbCAP和不同的方程组右端项向量b ,给定迭代误差要求,
2、用雅可比迭代法和高斯 -赛德尔迭代法运算,观测得到的迭代向量序列是否均收敛?如收敛, 记录迭代次数,分析运算结果并得出你的结论;p1EanqFDPw,将 A 的主对角线元素成倍增长如干次,非主对角线元素不变,每次用雅可比迭代法运算,要求迭代误差满意,比较收敛速度,分析现象并得出你的结论; DXDiTa9E3d3.1 模型分析选取初始向量x0=1,1, ,1T, b=1,1,1T,迭代要求为误差满意,编写雅各比、高斯-赛德尔迭代法的函数,迭代求解;RTCrpUDGiT3.2 程序代码function x = Jacobi x0,A,b,m D=diagdiagA;U=-triuA,1 ;L=-t
3、rilA,-1 ;B1=DL+U;f1=Db ;x:,1=x0;x:,2=B1*x:,1+f1 ;k=1;while normx:,k+1-x:,k,infm x:,k+2=B1*x:,k+1+f1 ;欢迎下载精品学习资源k=k+1;endendfunction x = Gauss x0,A,b,m D=diagdiagA;U=-triuA,1 ;L=-trilA,-1 ;B2=D-LU;f2=D-Lb;x:,1=x0;x:,2=B2*x:,1+f2 ;k=1;while normx:,k+1-x:,k,infm x:,k+2=B2*x:,k+1+f2 ;k=k+1;end endA1=3.*
4、eye20,20 ;A2=sparse1:19,2:20,-1/2,20,20 ;A3=sparse1:18,3:20,-1/4,20,20 ;AA=A1+A2+A3+A2+A3;A=fullAA;b=ones20,1 ; %输入自选右端项向量bx0=ones20,1; %输入自选初始向量x0m=1e-5 ;x1=Jacobx0,A,b,m;x2=Gaussx0,A,b,m;结果输出数据:k0123456710.5833330.5277780.4994210.4895830.4851390.4832390.48237410.750.6388890.6024310.5860340.5791620
5、.5760460.57463910.8333330.7152780.6701390.6495950.6405450.6363960.63448710.8333330.7430560.6932870.6715860.6611850.65640.65413710.8333330.750.7042820.6817130.6709150.6657180.66323810.8333330.750.7077550.6855710.6747160.6693670.66676810.8333330.750.7083330.6870660.6762720.6709240.66827410.8333330.750
6、.7083330.6874520.676850.6715350.66888310.8333330.750.7083330.68750.6770390.6717670.66912710.8333330.750.7083330.68750.6770790.6718440.6692110.8333330.750.7083330.68750.6770790.6718440.6692110.8333330.750.7083330.68750.6770390.6717670.669127x 各重量欢迎下载精品学习资源10.8333330.750.7083330.6874520.676850.6715350
7、.66888310.8333330.750.7083330.6870660.6762720.6709240.66827410.8333330.750.7077550.6855710.6747160.6693670.66676810.8333330.750.7042820.6817130.6709150.6657180.66323810.8333330.7430560.6932870.6715860.6611850.65640.65413710.8333330.7152780.6701390.6495950.6405450.6363960.63448710.750.6388890.6024310
8、.5860340.5791620.5760460.57463910.5833330.5277780.4994210.4895830.4851390.4832390.482374k891011121314150.481980.4817980.4817130.4816720.4816530.4816440.481640.4816380.5739880.5736860.5735430.5734760.5734440.5734290.5734210.5734180.6335970.6331790.6329810.6328870.6328430.6328210.6328110.6328060.65307
9、10.6525650.6523240.6522080.6521530.6521260.6521130.6521070.6620480.6614770.6612020.6610690.6610050.6609740.6609590.6609520.6655040.664890.6645910.6644460.6643760.6643410.6643250.6643160.6669720.6663330.6660190.6658650.665790.6657530.6657350.6657270.6675650.6669130.666590.6664310.6663530.6663140.6662
10、950.6662860.6678060.6671480.6668210.6666590.6665780.6665390.6665190.66651x 各重量0.667890.667230.6669010.6667380.6666570.6666170.6665970.666587值0.667890.667230.6669010.6667380.6666570.6666170.6665970.6665870.6678060.6671480.6668210.6666590.6665780.6665390.6665190.666510.6675650.6669130.666590.6664310.6
11、663530.6663140.6662950.6662860.6669720.6663330.6660190.6658650.665790.6657530.6657350.6657270.6655040.664890.6645910.6644460.6643760.6643410.6643250.6643160.6620480.6614770.6612020.6610690.6610050.6609740.6609590.6609520.6530710.6525650.6523240.6522080.6521530.6521260.6521130.6521070.6335970.6331790
12、.6329810.6328870.6328430.6328210.6328110.6328060.5739880.5736860.5735430.5734760.5734440.5734290.5734210.5734180.481980.4817980.4817130.4816720.4816530.4816440.481640.4816383.3 转变迭代初始值3.3.1 将 x0 各重量初值置为 0增加一句代码为 :x0=zeros20,1;k012345600.3333330.4166670.4537040.4689430.4758230.47892800.3333330.472222
13、0.5277780.5526620.5637860.56891100.3333330.50.5717590.6045520.6195670.62655900.3333330.50.5810190.6184410.6361560.644499x 各分00.3333330.50.5833330.623650.6430040.652308量值00.3333330.50.5833330.6248070.6450620.65494700.3333330.50.5833330.6250.6456890.65588300.3333330.50.5833330.6250.6458170.65616200.33
14、33330.50.5833330.6250.6458330.65623500.3333330.50.5833330.6250.6458330.656249欢迎下载精品学习资源00.3333330.50.5833330.6250.6458330.65624900.3333330.50.5833330.6250.6458330.65623500.3333330.50.5833330.6250.6458170.65616200.3333330.50.5833330.6250.6456890.65588300.3333330.50.5833330.6248070.6450620.65494700.33
15、33330.50.5833330.623650.6430040.65230800.3333330.50.5810190.6184410.6361560.64449900.3333330.50.5717590.6045520.6195670.62655900.3333330.4722220.5277780.5526620.5637860.56891100.3333330.4166670.4537040.4689430.4758230.478928k789101112130.4803650.4810350.481350.4814990.481570.4816040.4816210.571290.5
16、724060.5729330.5731840.5733040.5733610.5733890.6298380.6313880.6321240.6324760.6326440.6327250.6327640.6484660.6503560.6512610.6516960.6519050.6520060.6520550.6567780.6589310.659970.6604720.6607150.6608330.6608910.6597530.6620920.6632290.6637830.6640520.6641840.6642480.6608970.6633560.6645610.665152
17、0.6654410.6655820.6656520.6612860.6638180.6650670.6656820.6659850.6661340.6662070.6614130.6639840.6652580.6658880.6661990.6663520.666428x 各分0.6614470.6640350.665320.6659570.6662720.6664270.666504量值0.6614470.6640350.665320.6659570.6662720.6664270.6665040.6614130.6639840.6652580.6658880.6661990.666352
18、0.6664280.6612860.6638180.6650670.6656820.6659850.6661340.6662070.6608970.6633560.6645610.6651520.6654410.6655820.6656520.6597530.6620920.6632290.6637830.6640520.6641840.6642480.6567780.6589310.659970.6604720.6607150.6608330.6608910.6484660.6503560.6512610.6516960.6519050.6520060.6520550.6298380.631
19、3880.6321240.6324760.6326440.6327250.6327640.571290.5724060.5729330.5731840.5733040.5733610.5733890.4803650.4810350.481350.4814990.481570.4816040.481621k1415160.4816280.4816320.4816340.5734020.5734090.5734120.6327830.6327920.6327970.6520790.652090.6520960.6609180.6609320.6609390.6642790.6642940.6643
20、02x 各分0.6656860.6657020.66571量值0.6662420.666260.6662690.6664650.6664830.6664920.6665410.666560.6665690.6665410.666560.6665690.6664650.6664830.6664920.6662420.666260.6662690.6656860.6657020.66571欢迎下载精品学习资源0.6642790.6642940.6643020.6609180.6609320.6609390.6520790.652090.6520960.6327830.6327920.6327970
21、.5734020.5734090.5734120.4816280.4816320.481634【分析】从数据中可以看出,当迭代的初值变化了,达到相同精度所需要的迭代次数也变化了;3.3.2 将各重量初始值置为 10直接在下面给出数据结果k0123456102.8333331.5277780.910880.6753470.5689780.522036104.52.1388891.2743060.8863810.7175440.640258105.3333332.6527781.5555561.0549770.8293470.724922105.3333332.9305561.7037041.14
22、98840.8864450.763505105.33333331.7928241.2042820.9221080.786414105.33333331.8275461.2324460.9416070.799154105.33333331.8333331.245660.9515170.806292105.33333331.8333331.2495180.9561470.809893105.33333331.8333331.250.9578910.811558x 各分105.33333331.8333331.250.9582930.812201量值105.33333331.8333331.250.
23、9582930.812201105.33333331.8333331.250.9578910.811558105.33333331.8333331.2495180.9561470.809893105.33333331.8333331.245660.9515170.806292105.33333331.8275461.2324460.9416070.799154105.33333331.7928241.2042820.9221080.786414105.3333332.9305561.7037041.1498840.8864450.763505105.3333332.6527781.555556
24、1.0549770.8293470.724922104.52.1388891.2743060.8863810.7175440.640258102.8333331.5277780.910880.6753470.5689780.522036k789101112130.5004530.4904920.4858280.4836320.482590.4820940.4818560.6047850.5882290.5804540.5767750.5750250.5741890.5737880.6763310.6534790.6426720.6375310.6350750.6338970.6333310.7
25、051740.6775090.6642990.6579760.6549370.6534730.6527660.7213780.6900960.6750370.6677680.6642540.6625520.6617260.7299010.6962110.6798360.671870.6679940.6661050.6651850.7346720.699520.6822740.6738250.6696870.6676610.6666690.7372550.7012870.683520.674760.6704460.6683240.6672820.7385570.7022020.6841550.6
26、752150.6707960.6686150.667540.7390810.702590.6844230.6754030.6709340.6687250.6676350.7390810.702590.6844230.6754030.6709340.6687250.6676350.7385570.7022020.6841550.6752150.6707960.6686150.667540.7372550.7012870.683520.674760.6704460.6683240.667282x 各重量值欢迎下载精品学习资源0.7346720.699520.6822740.6738250.6696
27、870.6676610.6666690.7299010.6962110.6798360.671870.6679940.6661050.6651850.7213780.6900960.6750370.6677680.6642540.6625520.6617260.7051740.6775090.6642990.6579760.6549370.6534730.6527660.6763310.6534790.6426720.6375310.6350750.6338970.6333310.6047850.5882290.5804540.5767750.5750250.5741890.5737880.5
28、004530.4904920.4858280.4836320.482590.4820940.481856k141516171819200.4817420.4816870.4816610.4816480.4816420.4816390.4816370.5735950.5735020.5734570.5734350.5734250.5734190.5734170.6330580.6329250.6328610.632830.6328150.6328080.6328040.6524240.6522580.6521780.6521380.6521190.652110.6521060.6613250.6
29、61130.6610350.6609890.6609660.6609550.660950.6647370.6645180.6644110.6643590.6643330.6643210.6643150.6661830.6659460.665830.6657730.6657450.6657310.6657240.666770.6665190.6663950.6663350.6663050.6662910.6662840.6670110.6667510.6666240.6665610.666530.6665150.666508x 各分0.6670980.6668330.6667030.666639
30、0.6666080.6665930.666585量值0.6670980.6668330.6667030.6666390.6666080.6665930.6665850.6670110.6667510.6666240.6665610.666530.6665150.6665080.666770.6665190.6663950.6663350.6663050.6662910.6662840.6661830.6659460.665830.6657730.6657450.6657310.6657240.6647370.6645180.6644110.6643590.6643330.6643210.664
31、3150.6613250.661130.6610350.6609890.6609660.6609550.660950.6524240.6522580.6521780.6521380.6521190.652110.6521060.6330580.6329250.6328610.632830.6328150.6328080.6328040.5735950.5735020.5734570.5734350.5734250.5734190.5734170.4817420.4816870.4816610.4816480.4816420.4816390.481637【分析】可见,起初值置为10 时,并不转变
32、其收敛性,但是达到结果所需要的迭代次数更长了,要 20 次;3.4 用高斯方法重新运算输出结果如下 :10.5833330.5088730.4900550.4843390.48251910.6805560.6060640.5838240.5768050.5745310.745370.6685310.6444190.6366190.63406310.7642750.6887170.6641480.6560850.65342210.7728270.6978880.673180.6650060.66229510.7758270.7013390.6766140.6684020.66567110.777
33、040.7027680.6780520.6698260.66708710.7774920.7033290.6786230.6703930.66765110.7776690.7035550.6788560.6706250.66788210.7777360.7036450.6789490.6707180.66797510.7777620.703680.6789870.6707560.668009k012345x 各重量值欢迎下载精品学习资源10.7777720.7036940.6790020.6707710.6679810.7777750.70370.6790080.6707290.6677661
34、0.7777770.7037020.6790110.6703140.66707910.7777770.7037030.6784330.6685950.66538410.7777780.7037030.6746720.6642460.66168210.7777780.6967590.6624390.6541940.65254910.7777780.6666670.6385650.6339530.63303910.6944440.5881560.5761160.5739360.57352210.5138890.4869150.4825660.4818190.481674k67891011x 各分量
35、值0.4819270.4817320.4816680.4816460.4816390.4816370.5737840.5735370.5734550.5734280.5734190.5734160.6332190.632940.6328470.6328160.6328060.6328030.652540.6522470.652150.6521180.6521070.6521030.6613940.6610950.6609950.6609620.6609510.6609470.6647630.664460.664360.6643260.6643140.6643110.6661750.665872
36、0.665770.6657360.6657240.665720.6667380.6664330.666330.6662940.6662820.6662790.6669670.666660.6665540.6665170.6665050.6665020.6670560.6667390.6666290.6665930.6665820.6665790.6670670.6667350.6666240.6665910.6665810.6665790.6669830.6666430.6665390.6665110.6665030.6665010.6667150.6663940.6663070.666284
37、0.6662790.6662770.6660720.6658060.665740.6657230.6657190.6657180.6645640.6643690.6643230.6643120.6643090.6643090.6611120.6609830.6609540.6609470.6609450.6609450.6521990.6521230.6521060.6521020.6521020.6521010.6328520.6328120.6328040.6328020.6328010.6328010.5734380.573420.5734160.5734150.5734150.5734150.4816440.4816380.4816360.4816360.4816360.4816363.4.2转变各重量初值为0k01234500.3333330.4336420.4658780.4764270.47990800.3888890.5129890.5534660.5668030.57121800.4259260.5645580.6101930.6252930.63030400.4367280.5807220.6283940.6442170.64947700.44161
限制150内