In: Advanced Math
A) Use Jacobi or Gauss-Seidel iteration and perform three iterations by hand.
B) Use Jacobi or Gauss-Siedel iteration for ten iterations with a MAT-LAB function.
* A= [5, -1,0;-1,5,-1;0,-1,5] , B=[9;4;-6]
Code
A=[5 -1 0;-1 5 -1;0 -1 5];
b=[9;4;-6];
x=[0;0;0];
format long
for k=1:10
disp('iteration')
disp(k)
for i=1:3
sum=0;
sum=sum+b(i);
for j=1:3
if i==j
sum=sum;
else
sum=sum-A(i,j)*x(j);
end
end
sum=(1/A(i,i))*sum;
x(i)=sum;
end
x
end
Output