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= [10 -2 1;-2 10 -2;-2 -5 10] , B=[9;12;18]
(A)


(B)
Code
A=[10 -2 1;-2 10 -2;-2 -5 10];
b=[9 ;12;18];
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

