Write a MatLab program to solve the following system of equation using Gauss-Seidel
methad:
54x+y+2=110;2x+ 15y+6z=72;=x+6y+272=85
n = 3;
A=[54, 1, 2;
2, 15, 6;
1, 6, 272];
b = [110; 72; 85];
x = [1; 1; 1];
for iter=1:100
for i=1:n
s = 0;
for j=1:n
if j~= i
s = s + A(i,j)*x(j);
end
end
x(i) = (b(i) - s) /A(i,i);
end
end
disp(x)
>> seidel
1.9468
4.4576
0.2070
>> A*x
ans =
110.0000
72.0000
85.0000
>>
Comments
Leave a comment