You are on page 1of 1

Numerical and Statistical Methods | 1

Roll No.: 302B052


Name of Student: Shaunak Shetye
Experiment No. 01
Program on Simultaneous Equations
Program for Gauss-Seidal Method
Python Program

def f1(y,z):
return (95-11*y+4*z)/81
def f2(x,z):
return (104-7*x-13*z)/52
def f3(x,y):
return (71-3*x-8*y)/29
n=int(input("Enter number of iterations:"))
x0=0
y0=0
z0=0
for i in range(n):
x1=f1(y0,z0)

y1=f2(x1,z0)
z1=f3(x1,y1)
y0=y1
z0=z1
print("\n x1=%f,y1=%f,z1=%f \n"%(x1,y1,z1))

Output of Program:
x1=1.172840,y1=1.842118,z1=1.818777

x1=1.012492,y1=1.409009,z1=1.954843

x1=1.078028,y1=1.366170,z1=1.959881

x1=1.084095,y1=1.364094,z1=1.959826

x1=1.084374,y1=1.364070,z1=1.959804

x1=1.084376,y1=1.364075,z1=1.959802

Sinhgad College of Engineering, Pune | NSM- Journal

You might also like