资源描述:
《相对Gauss列主元消去法.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验题目5相对Gauss列主元消去法摘要由一般线性方程组在使用Gauss消去法求解时,从求解过程中可以清楚地看到,若,必须施以行交换的手续,才能使消去过程继续下去。有时既使,但其绝对值很小,由于舍入误差的影响,消去过程也会出现不稳定现象。因此,为使这种不稳定现象发生的可能性减至最小,在施行消去过程时每一步都要选主元素,即要寻找行,使并将第行与第行交换,以使的当前值(即的数值)远大于0。这种列主元消去法的主要步骤如下:1.消元过程对,做1º选主元,记若,说明方程组系数矩阵奇异,则停止计算,否则进行2º。2º交换(增广矩阵)的两行元素3º计算2.回代过程对,计算前言利用Gauss列主
2、元消去法、显式相对Gauss列主元消去法、隐式相对Gauss列主元消去法求解线性方程组程序设计流程是否否是开始输入(增广矩阵)交换中两行输出结束问题1(1)程序运行如下:x=GaussSysSolve(Mat1_1,b1_1)x=1.00001.00001.00001.0000x=GaussExpSysSolve(Mat1_1,b1_1)x=1.00001.00001.00001.0000x=GaussIneSysSolve(Mat1_1,b1_1)x=1.00001.00001.00001.0000(2)程序运行如下:x=GaussSysSolve(Mat1_2,b1_2)x=
3、1.00001.00001.00001.0000x=GaussExpSysSolve(Mat1_2,b1_2)x=1.00001.00001.00001.0000x=GaussIneSysSolve(Mat1_2,b1_2)x=1.00001.00001.00001.0000(3)程序运行如下:x=GaussSysSolve(Mat1_3,b1_3)x=1.00001.00001.00001.0000x=GaussExpSysSolve(Mat1_3,b1_3)x=1.00001.00001.00001.0000x=GaussIneSysSolve(Mat1_3,b1_3)x=1
4、.00001.00001.00001.0000(4)程序运行如下:x=GaussSysSolve(Mat1_4,b1_4)x=1.00001.00001.00001.0000x=GaussExpSysSolve(Mat1_4,b1_4)x=1.00001.00001.00001.0000x=GaussIneSysSolve(Mat1_4,b1_4)x=1.00001.00001.00001.0000问题2(1)程序运行如下:=GaussSysSolve(Mat2_1,b2_1)x=1.09150.28321.1463-0.1008x=GaussExpSysSolve(Mat2_1
5、,b2_1)x=1.09150.28321.1463-0.1008x=GaussIneSysSolve(Mat2_1,b2_1)x=1.09150.28321.1463-0.1008(2)程序运行如下:x=GaussSysSolve(Mat2_2,b2_2)x=0.51620.41520.11001.0365x=GaussExpSysSolve(Mat2_2,b2_2)x=0.51620.41520.11001.0365x=GaussIneSysSolve(Mat2_2,b2_2)x=0.51620.41520.11001.0365(3)程序运行如下:x=GaussSysSolv
6、e(Mat2_3,b2_3)x=1.00001.00001.0000x=GaussExpSysSolve(Mat2_3,b2_3)x=111x=GaussIneSysSolve(Mat2_3,b2_3)x=1.00001.00001.0000(4)程序运行如下:x=GaussSysSolve(Mat2_4,b2_4)x=111x=GaussExpSysSolve(Mat2_4,b2_4)x=1.00001.00001.0000x=GaussIneSysSolve(Mat2_4,b2_4)x=111使用的函数functionx=GaussSysSolve(A,b)%GaussSys
7、Solve用Gauss消去法解线性方程组Ax=b%%Synopsis:x=GaussSysSolve(A,b)%%Input:A=系数矩阵%b=方程组右端%%Output:x=线性系统的解向量[m,n]=size(A);b=b(:);%将b变为列向量ifm~=n%A必须为方阵error('ArgumentmatrixAmustbesquare!');elseifm~=length(b)%b的长度应与A维度相同error('ThedimentionsofAandbdonotagre