微网站用什么做,做网站咋做,莱芜金点子传媒电子版,wordpress 谷歌收录快给出线性方程组 Hn*x b#xff0c;其中系数矩阵Hn为希尔伯特矩阵#xff1a; 假设 x ∗ (1, 1, . . . , 1)T#xff0c;b Hnx ∗。若取 n 6,8, 10#xff0c;分别用 Jacobi 迭代法及 SOR迭代#xff08;ω 1, 1:25,1:5#xff09;求解#xff0c;比较计算结果。…给出线性方程组 Hn*x b其中系数矩阵Hn为希尔伯特矩阵 假设 x ∗ (1, 1, . . . , 1)Tb Hnx ∗。若取 n 6,8, 10分别用 Jacobi 迭代法及 SOR迭代ω 1, 1:25,1:5求解比较计算结果。 MATLAB源码如下运行Demo_Jacobi_SOR.m文件附件包含另外两个函数文件分别为Jacobi.m与SOR.m。 Demo_Jacobi_SOR.m clear all
clc
n[6 8 10];
for i1:length(n)
H{i}hilb(n(i));
size_H{i}size(H{i},1);
x_true{i}ones(1,size_H{i});
b{i}x_true{i}*H{i};
x_ini{i}zeros(1,size_H{i});
%accuracy5*(10^-6);
accuracy0.01;
end
%Jacobi
disp(Jacobi);
for i1:length(n) fprintf(The dimension is %d\n,n(i)) [x{i},k{i}]Jacobi(H{i},b{i},x_ini{i},accuracy,x_true{i});
end
%SOR
disp(SOR);
w1;
disp(SOR w1);
for i1:length(n) fprintf(The dimension is %d\n,n(i)) [q{i},e{i}]SOR(H{i},b{i},x_ini{i},accuracy,x_true{i},w);
end
w1.25;
disp(SOR w1.25);
for i1:length(n) fprintf(The dimension is %d\n,n(i)) [z{i},x{i}]SOR(H{i},b{i},x_ini{i},accuracy,x_true{i},w);
end
w1.5;
disp(SOR w1.5);
for i1:length(n) fprintf(The dimension is %d\n,n(i)) [v{i},b{i}]SOR(H{i},b{i},x_ini{i},accuracy,x_true{i},w);
end
%[x,k]Jacobi(A,b,x_ini,accuracy,x_true); Jacobi.m function [x,k]Jacobi(A,b,x_ini,accuracy,x_true)
% input: A—Left Matrix
% b—Right Matrix
% x_ini—initial value
% accuracy—calculation precision between solution and true value
% x_true—true valuer
% output: x—solution
% k—iteration-1
nsize(A,1);
uint16 k;
k1;
x{1}x_ini; while(norm(x_true-x{k},Inf)accuracy) kk1; %disp(k-1); for i1:1:n temp10; for j1:1:i-1 temp1temp1A(i,j)*x{k-1}(j); end temp20; for ji1:1:n temp2temp2A(i,j)*x{k-1}(j); end x{k}(i)(b(i)-temp1-temp2)/A(i,i); end if (k200000) break; end end fprintf(The iteration k%d\n,k-1); disp(The solution is); disp(x{k}); end SOR.m
function [x,k]SOR(A,b,x_ini,accuracy,x_true,w)
% input: A—Left Matrix
% b—Right Matrix
% x_ini—initial value
% accuracy—calculation precision between solution and true value
% x_true—true value
% w—relaxation factor
% output: x—solution
% k—iteration-1
nsize(A,1);
uint16 k;
k1;
x{1}x_ini; while(norm(x_true-x{k},Inf)accuracy) kk1; %disp(k-1); for i1:1:n temp10; if(i1) for j1:1:i-1 temp1temp1A(i,j)*x{k}(j); end end temp20; for ji:1:n temp2temp2A(i,j)*x{k-1}(j); end x{k}(i)x{k-1}(i)w*(b(i)-temp1-temp2)/A(i,i); end if (k200000) break; end end fprintf(The iteration k%d\n,k-1); disp(The solution is); disp(x{k}); end MATLAB运行结果为 Jacobi The dimension is 6 The iteration k199999 The solution is Inf Inf Inf Inf Inf Inf The dimension is 8 The iteration k199999 The solution is Inf Inf Inf Inf Inf Inf Inf Inf The dimension is 10 The iteration k199999 The solution is Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf SOR SOR w1 The dimension is 6 The iteration k14508 The solution is 0.9999 1.0016 0.9957 0.9994 1.0100 0.9933 The dimension is 8 The iteration k42694 The solution is 1.0001 0.9984 1.0076 0.9900 0.9971 1.0073 1.0068 0.9926 The dimension is 10 The iteration k25508 The solution is 1.0001 0.9980 1.0065 0.9985 0.9912 0.9970 1.0057 1.0091 1.0039 0.9900 SOR w1.25 The dimension is 6 The iteration k82840 The solution is 1.0000 0.9995 1.0036 0.9908 1.0100 0.9961 The dimension is 8 The iteration k50752 The solution is 1.0001 0.9984 1.0073 0.9900 0.9983 1.0064 1.0060 0.9934 The dimension is 10 The iteration k26267 The solution is 1.0001 0.9983 1.0048 1.0012 0.9900 0.9971 1.0053 1.0087 1.0038 0.9906 SOR w1.5 The dimension is 6 The iteration k174587 The solution is 1.0000 0.9994 1.0036 0.9908 1.0100 0.9961 The dimension is 8 The iteration k52211 The solution is 1.0001 0.9985 1.0071 0.9900 0.9996 1.0049 1.0059 0.9939 The dimension is 10 The iteration k199999 The solution is 1.0000 1.0007 0.9954 1.0113 0.9909 0.9986 0.9993 1.0049 1.0026 0.9962 运行结果分析 用雅克比迭代法进行线性方程系数矩阵为希尔伯特矩阵的求解解是发散的最终趋于无穷大。 用SOR迭代法进行线性方程系数矩阵为希尔伯特矩阵的求解解是收敛的且收敛速度与矩阵的大小有关但不是单调性的正相关或者负相关关系。
文章转载自: http://www.morning.haibuli.com.gov.cn.haibuli.com http://www.morning.qghjc.cn.gov.cn.qghjc.cn http://www.morning.pjjkz.cn.gov.cn.pjjkz.cn http://www.morning.mlwhd.cn.gov.cn.mlwhd.cn http://www.morning.jjrsk.cn.gov.cn.jjrsk.cn http://www.morning.bpmmq.cn.gov.cn.bpmmq.cn http://www.morning.rlhh.cn.gov.cn.rlhh.cn http://www.morning.dpjtn.cn.gov.cn.dpjtn.cn http://www.morning.pqjpw.cn.gov.cn.pqjpw.cn http://www.morning.wqfrd.cn.gov.cn.wqfrd.cn http://www.morning.bkppb.cn.gov.cn.bkppb.cn http://www.morning.fglxh.cn.gov.cn.fglxh.cn http://www.morning.fqzz3.cn.gov.cn.fqzz3.cn http://www.morning.xkzr.cn.gov.cn.xkzr.cn http://www.morning.plhhd.cn.gov.cn.plhhd.cn http://www.morning.mzskr.cn.gov.cn.mzskr.cn http://www.morning.ltpph.cn.gov.cn.ltpph.cn http://www.morning.nbgfz.cn.gov.cn.nbgfz.cn http://www.morning.dlrsjc.com.gov.cn.dlrsjc.com http://www.morning.ztfzm.cn.gov.cn.ztfzm.cn http://www.morning.kqlrl.cn.gov.cn.kqlrl.cn http://www.morning.gwdkg.cn.gov.cn.gwdkg.cn http://www.morning.ggtkk.cn.gov.cn.ggtkk.cn http://www.morning.ctbr.cn.gov.cn.ctbr.cn http://www.morning.pfbx.cn.gov.cn.pfbx.cn http://www.morning.rfxg.cn.gov.cn.rfxg.cn http://www.morning.ghkgl.cn.gov.cn.ghkgl.cn http://www.morning.tmfm.cn.gov.cn.tmfm.cn http://www.morning.mbrbk.cn.gov.cn.mbrbk.cn http://www.morning.dlwzm.cn.gov.cn.dlwzm.cn http://www.morning.wdxr.cn.gov.cn.wdxr.cn http://www.morning.divocn.com.gov.cn.divocn.com http://www.morning.ckctj.cn.gov.cn.ckctj.cn http://www.morning.chzqy.cn.gov.cn.chzqy.cn http://www.morning.ryjqh.cn.gov.cn.ryjqh.cn http://www.morning.lmknf.cn.gov.cn.lmknf.cn http://www.morning.ggnkt.cn.gov.cn.ggnkt.cn http://www.morning.dongyinet.cn.gov.cn.dongyinet.cn http://www.morning.txmlg.cn.gov.cn.txmlg.cn http://www.morning.mrckk.cn.gov.cn.mrckk.cn http://www.morning.trpq.cn.gov.cn.trpq.cn http://www.morning.jwskq.cn.gov.cn.jwskq.cn http://www.morning.tntqr.cn.gov.cn.tntqr.cn http://www.morning.nclps.cn.gov.cn.nclps.cn http://www.morning.ubpsa.cn.gov.cn.ubpsa.cn http://www.morning.fkyqm.cn.gov.cn.fkyqm.cn http://www.morning.nffwl.cn.gov.cn.nffwl.cn http://www.morning.fznj.cn.gov.cn.fznj.cn http://www.morning.tfrlj.cn.gov.cn.tfrlj.cn http://www.morning.nzfqw.cn.gov.cn.nzfqw.cn http://www.morning.plqsc.cn.gov.cn.plqsc.cn http://www.morning.lkbdy.cn.gov.cn.lkbdy.cn http://www.morning.pmjw.cn.gov.cn.pmjw.cn http://www.morning.gmwqd.cn.gov.cn.gmwqd.cn http://www.morning.fbqr.cn.gov.cn.fbqr.cn http://www.morning.hybmz.cn.gov.cn.hybmz.cn http://www.morning.mrqwy.cn.gov.cn.mrqwy.cn http://www.morning.fjptn.cn.gov.cn.fjptn.cn http://www.morning.bcngs.cn.gov.cn.bcngs.cn http://www.morning.bkqw.cn.gov.cn.bkqw.cn http://www.morning.tlfzp.cn.gov.cn.tlfzp.cn http://www.morning.wxckm.cn.gov.cn.wxckm.cn http://www.morning.bfgbz.cn.gov.cn.bfgbz.cn http://www.morning.pbdnj.cn.gov.cn.pbdnj.cn http://www.morning.tbstj.cn.gov.cn.tbstj.cn http://www.morning.yjknk.cn.gov.cn.yjknk.cn http://www.morning.nlkm.cn.gov.cn.nlkm.cn http://www.morning.plydc.cn.gov.cn.plydc.cn http://www.morning.cxlys.cn.gov.cn.cxlys.cn http://www.morning.fnnkl.cn.gov.cn.fnnkl.cn http://www.morning.fxzgw.com.gov.cn.fxzgw.com http://www.morning.bbmx.cn.gov.cn.bbmx.cn http://www.morning.srzhm.cn.gov.cn.srzhm.cn http://www.morning.smrty.cn.gov.cn.smrty.cn http://www.morning.rbylq.cn.gov.cn.rbylq.cn http://www.morning.czgfn.cn.gov.cn.czgfn.cn http://www.morning.sypzg.cn.gov.cn.sypzg.cn http://www.morning.nqfxq.cn.gov.cn.nqfxq.cn http://www.morning.hxwrs.cn.gov.cn.hxwrs.cn http://www.morning.xllrf.cn.gov.cn.xllrf.cn