欢迎来到天天文库
浏览记录
ID:49941440
大小:177.50 KB
页数:6页
时间:2020-03-03
《数值分析计算机作业.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、数值分析计算机作业电信少41刘星辰21204061021.用列主元高斯消去法求解线性方程组_3_564-2-38_「1111-9151-9222-175一161129A=-11327-1-2fb=9431-7211529-811-1-4-18_72-127-1925解:代码如下functionx=nagauss2(a,b,flag)a=[3-5611-92-17-1134-2-38;151-92;5-1611;27-1-2;431-7211;29-811-1一4-1;72-127-19];b=[ll;2;29;9;
2、5;8;25];ifnargin<3zflag=0;endn=length(b);a=[ab];fork=l:n-1%选主元[ap,p]=max(abs(a(k:nzk)));p=p+k-l;ifp>ka(kz:)=a(p,:);a(pz:)=t;end%消元a((k+1):nz(k+1):(n+1))=a((k+1):nz(k+1):(n+1))-a((k+1):nzk)/a(kzk)*a(k/(k+1):(n+1));a((k+1):n,k)=zeros(n-k,1);ifflag==0,a,endend%回代
3、x=zeros(nz1);x(n)=a(nzn+1)/a(n,n);fork=n-l:-1:1x(k,:)=(a(k,n+1)-a(k,(k+1):n)*x((k+1):n))/a(k,k);end过程截图:a=7.00002.0000-1.00002.00007.0000-1.00009.000025.000000.7143-8.857114.71430-8.85710.7143-1.57140-1.57147.28574.4286-3.00006.28578.428621.857101.28572.85712.
4、28578.0000-1.1429-0.714312.571401.85711.5714-8.1429-2.00001.5714-4.1429-9.285708.4286-7.714310.4286-3.0000-3.7143-3.57140.85710-o.85716.42863.1429-5.0000-2.57144.14290.285700002.0000-1.00002.00007.0000-1.00009.000025.000008.4286-7.714310.4286-3.0000-3.7143-3.5
5、7140.8571005.84756.3729-3.55935.59327.762722.0169004.03390.69498.4576-0.5763-0.169512.4407003.2712-10.4407-1.33902.3898-3.3559-9.474600-8.203413.83050.2542-8.54241.0169-1.6441001.067810.3898-7.0847-5.15251.66100.8814a=7.00002.0000-1.00002.000008.4286-7.714310.
6、428600-8.203413.830500016.23140000000000007.0000-1.00009.000025.0000-3.0000-3.7143-3.57140.85710.2542-8.54241.0169-1.6441-3.3781-0.49598.487620.8450-2.2627-1.1670-0.3747-3.804510.1427-4.5479-3.58912.0057-4.5146-5.8921-4.5810-14.98777.00002.0000-1.00002.00007.0
7、000-1.00009.000025.000008.4286-7.714310.4286-3.0000-3.7143-3.57140.857100-8.203413.83050.2542-8.54241.0169-1.64410007.49598.5826-4.77690.330611.6322000-4.9256-1.2376-1.0165-2.9504-10.130200016.2314-3.3781-0.49598.487620.845000012.1901-7.0517-6.26451.79340.6674
8、7.00002.0000-1.00002.000008.4286-7.714310.428600-8.203413.830500016.2314000000000000a=7.00002.0000-1.00002.000008.4286-7.714310.428600-8.203413.830500016.2314000000000000结果为:7.0000
此文档下载收益归作者所有