Name: AKSHAY ZOMAN
Roll No:69 Batch: T8
% PROGRAM FOR GAUSS SEIDAL METHOD
clc;
clear all;
close all;
fx=input(' Enter function fx(y,z)=');
fy=input('Enter function fy(x,z)=');
fz=input('Enter function fz(x,y)=');
n=input('Enter the number of iteration n=')
x=0;
y=0;
z=0;
fprintf('\n\n>> Solution by programme:\n');
for i=1:n
x=fx(y,z);
y=fy(x,z);
z=fz(x,y);
fprintf('\n x= %f',x);
fprintf('\n y= %f',y);
fprintf('\n z= %f',z);
end;
OUTPUT
Enter function fx(y,z)=@(y,z)((5-y-z)/4)
Enter function fy(x,z)=@(x,z)((19-x-2*z)/6)
Enter function fz(x,y)=@(x,y)((10+x+2*y)/-5)
Enter the number of iteration n=5
n=
5
>> Solution by programme:
x= 1.250000 y= 2.958333 z= -3.433333
x= 1.368750 y= 4.082986 z= -3.906944
x= 1.205990 y= 4.267983 z= -3.948391
x= 1.170100 y= 4.287780 z= -3.949132
x= 1.165338 y= 4.288821 z= -3.948596
>>