Using MATLAB develop an Mfile for the GaussSeidel Method to
     Using MATLAB, develop an M-file for the Gauss-Seidel Method to solve the system of equations listed below until the percent relative error falls below epsilon_s = 5%. x_1 + x_2 + 5x_3 = -21.5 -3x_1 - 6x_2 + 2x_3 = -61.5 10 x_1 + 2x_2 - x_3 = 27
 
  
  Solution
Code is given below:
% solution of cause seidel method:
% x1+x2+5*x3 = (-21.5)
% -3*x1-6*x2+2*x3=(-61.5)
% 10*x1+2*x2-x3 =27
% initially x2=0 and x3 =0
% solution:
% x1= -21.5-x2-5*x3
% x2 = (1/6)*(61.5-3*x1+2*x3)
% x3 = 27- 10*x1+2*x2
clear;
clc
format(\'long\');
I=1;
x2(I)=0;
x3(I)=0;
e_s = 99999;
while e_s>0.05 % error within limit
x1(I+1)= -21.5-x2(I)-5*x3(I);
x2(I+1) = (1/6)*(61.5-3*x1(I)+2*x3(I));
x3(I+1) = 27- 10*x1(I)+2*x2(I);
e_1(I+1) = abs(((x1(I+1)-x1(I))/x1(I+1))*100);
e_2(I+1) = abs(((x2(I+1)-x2(I))/x2(I+1))*100);
e_3(I+1) = abs(((x3(I+1)-x3(I))/x3(I+1))*100);
e_s = max(e_1,e_2,e_3);
I = I +1 ;
end
p = length(x1);
fprintf(\' value of x1, x2 and x,3 are: %f, %f and %f\',x1(p),x2(p),x3(p));
% end of code.
% Have a Nice Day ...
.
... Have a Nice Day ...
.


