Algorithm for Gauss-Seidel Method

  • Start
  • Given system is:
a1x+b1y+c1z=d1
a2x+b2y+c2z=d2
a3x+b3y+c3z=d3
  • Convert the 1st equation in terms of 1st variable, 2nd equation in terms of 2nd variable and so on.
x=(d1-b1y-c1z)/a1
y=(d2-c2z-a2x)/b2
z=(d3-a3x-b3y)/c3
  • Assume initial guesses as x0,y0,z0.
  • Substituting x0,y0,z0, find x1, y1, z1 from above converted form as
x1=(d1-b1y0-c1z0)/a1
y1=(d2-c2z0-a2x1)/b2
z1=(d3-a3x1-b3y1)/c3
  • If |x0-x1|<accuracy && |y0-y1|<accuracy&& |z0-z1|<accuracy, required roots are x1,y1,z1, Else set x0=x1,y0=y1,z0=z1 and go to step (5).
  • End

No comments:

Post a Comment