数值分析作业:使用平方根法求解线性方程组.pdfVIP

  • 0
  • 0
  • 约2.33千字
  • 约 6页
  • 2026-02-06 发布于北京
  • 举报

数值分析作业:使用平方根法求解线性方程组.pdf

作业四:编写用平方根法求解线性方程组的程序,并求下列方程

组的解。

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

文档评论(0)

1亿VIP精品文档

相关文档