Skip to content

exp4 (1) #2

Description

@legend17-dot

clc;clear;format long;
A=[3 1 1;1 4 1;1 1 5]; b=[5;6;7];
x=[0;0;0];tol=1e-6;
for iter=1:100
x_old=x;
x(1)=(b(1)-A(1,2)*x(2)-A(1,3)*x(3))/A(1,1);
x(2)=(b(2)-A(2,1)*x(1)-A(2,3)*x(3))/A(2,2);
x(3)=(b(3)-A(3,1)*x(1)-A(3,2)*x(2))/A(3,3);

if norm(x-x_old)<tol,break;end

end
fprintf('x=[%.8f,%.8f,%.8f]\n',x(1),x(2),x(3));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions