- 0
- 0
- 约2.33千字
- 约 6页
- 2026-02-06 发布于北京
- 举报
作业四:编写用平方根法求解线性方程组的程序,并求下列方程
组的解。
621―1―1
2410x22
114―1x3=1
―10―13x43
流程图
开
计算下三角矩阵G的
数据值
计算中间变量y
计算x的值
结束
程序
A=[621-1;2410;114-1;-10-13];
[n,n]=size(A);
G=zeros(n,n);
G(1,1)=sqrt(A(1,1));
G(2:n,1)=A(2:n,1)/G(1,1);
forj=2:n-1
G(j,j)=sqrt(A(j,j)-sum(G(j,1:j-1).^2));
fori=j+1:n
G(i,j)=(A(i,j)-sum(G(i,1:j-1).*G(j,1:j-1)))/G(j,j);
end
end
G(n,n)=sqrt(A(n,n)-sum((G(n,1:n-1)).^2));
b=[-1213];
x=zeros(n,1);%未知向量
y=zeros(n,1);%中间向量
y(1)=b(1)/G(1,1);
fori=2:n
y(i)=(b(i)-sum(G(i,1:i-1).*y(1:i-1)))/G(i,i);
end
G=G;
x(n)=y(n)/G(n,n);
fori=n-1:-1:1
x(i)=(y(i)-sum(G(i,i+1:n).*x(i+1)))/G(i,i);
end
程序结果
AssignmentFour:Writeastandardprogramusingthesquareroot
methodtosolvelinearequationsystems,andfindthesolutiontothe
followingsystemofequations.
621―1―1
2410x22
114―1x3=1
―10―13x43
流程图
开
Calculatethelowertriangular
matrixG
数据值
Calculatethe
intermediate
variabley
Calculatethe
eo
valufx
结束
程序
A=[621-1;2410;114-1;-10-13];[n,n]size(A);Gzeros(n,n);
G(1,1)sqrt(A(1,1));G(2:n,1)A(2:n,1)/G(1,1);forj=2:n-1G(j,j)
sqrt(A(j,j)-sum(G(j,1:j-1).^2));forij+1:nG(i,j)
(A(i,j)-sum
您可能关注的文档
最近下载
- 创业培训结业试题及答案.docx VIP
- (新版)大学生GYB创业意识培训考试题库(附答案).docx VIP
- DLT664-2025带电设备红外诊断应用规范.docx VIP
- 2025年大学生GYB创业意识培训考试题(附答案).docx VIP
- 12J926 无障碍设计-标准图集.docx VIP
- T∕CECS G-D66-01-2019 公路波纹钢涵洞技术规程.pdf
- gyb创业培训考试题及答案.doc VIP
- 门座式起重机.pptx VIP
- (高清版)DB3301∕T 0209-2018 农村生活垃圾处理技术管理规范 .pdf VIP
- (新版)大学生GYB创业意识培训考试题(附答案) .pdf VIP
原创力文档

文档评论(0)