You are on page 1of 2

Name :- Sumit Satishrao Salunke.

Roll No :- 202E051. Div :- E

Experiment No. 01
Program on Simultaneous Equations.
Program for Gauss-Seidal Method based on Iteration Criteria.

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

x0=0

y0=0

z0=0

n=int(input("enter no of iterations: "))

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 and z1=%f\n' %(x1,y1,z1))

Output:-
= RESTART: C:/Users/Admin/AppData/Local/Programs/Python/Python310/sumit trial 8-8-2022.py

enter no of iterations: 5

x1=1.172840,y1=1.842118 and z1=1.818777

x1=1.012492,y1=1.409009 and z1=1.954843

x1=1.078028,y1=1.366170 and z1=1.959881

x1=1.084095,y1=1.364094 and z1=1.959826

x1=1.084374,y1=1.364070 and z1=1.959804

You might also like