资源描述:
《数值分析作业.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、数值分析上机报告-------土建学院-------岩土工程09研------鲁鹏数值分析作业(鲁鹏:2009020979岩土工程)1.已知A和b1.1用超松弛法求解Ax=b(取松弛因子=1.4,=0,迭代9次)解:1.1.1原理:其基本思想是在高斯方法已求出x(m),x(m-1)的基础上,经过重新组合的新序列,而此新序列收敛速度加快。其算式是:xi(m)=(1-ω)xi(m-1)+ω(bijxi(m)+xj(m-1)+gi)其中ω是超松弛因子,当ω>1时,可以加快收敛速度。1.1.2.程序:#include#include#include
2、#definesorc1.4#defineA9voidmain(){inti,j,k;doubleaa[A][A]={{12.38412,2.115237,-1.061074,1.112336,-0.113584,0.718719,1.742382,3.067813,-2.031743},{2.115237,19.141823,-3.125432,-1.012345,2.189736,1.563849,-0.784165,1.112348,3.123124},Page14of14数值分析上机报告-------土建学院-------岩土工程09研------
3、鲁鹏{-1.061074,-3.125432,15.567914,3.123848,2.031454,1.836742,-1.056781,0.336993,-1.010103},{1.112336,-1.012345,3.123848,27.108437,4.101011,-3.741856,2.101023,-0.71828,-0.037585},{-0.113584,2.189736,2.031454,4.101011,19.897918,0.431637,-3.111223,2.121314,1.784317},{0.71819,1.563849,1.836742,
4、-3.741856,0.431637,9.789365,-0.103458,-1.103456,0.238417},1.742382,-0.784165,-1.056781,2.101023,-3.111223,-0.103458,14.7138465,3.123789,-2.213474},{3.067813,1.112348,0.336993,-0.71828,2.121314,-1.103456,3.123789,30.719334,4.446782},{-2.031743,3.123124,-1.010103,-0.037585,1.784317,0.238417,
5、-2.213474,4.446782,40.00001}};doublebb[A]={2.1874369,33.992318,-25.173417,0.84671695,1.784317,-86.612343,1.1101230,4.719345,-5.6784392};doublexl[A],x[9],tem=0.0;clrscr();for(i=0;i6、;}x[i]=(tem+bb[i])/aa[i][i];x[i]=xl[i]+sorc*(x[i]-xl[i]);xl[i]=x[i];}}printf("tttheresultsareshownbelow!");for(i=0;i7、弛法,对G-S方法每一步得到的结果与前一步所得到的结果进行了处理,迭代收敛更快,实践证明,选择恰当的松弛系数不仅可以加快收敛速度,而且可以得到满足精度的解答!1.2请用列主元素消去法求解Ax=b:1.2.1原理:对矩阵作恰当的调整,选取绝对值尽量大的元素作为主元素。然后进行行变换,把矩阵化为上三角阵,再进行回代,求出方程的解。1.2.2程序:#include#include#includevoidmain(){inti,j,k,l,m,n,r,maxi;doubl