Professional Documents
Culture Documents
Job#5 Guass Siedal Mine
Job#5 Guass Siedal Mine
INTRODUCTION:
The Gauss-Seidel method is an iterative procedure to find approximate
solutions to a system of linear algebraic equations with arbitrarily chosen precision. The method
is applied to square matrices with nonzero elements in their diagonals and convergence is
guaranteed if the matrix is diagonally dominant.
Gauss–Seidel method is an improved form of
Jacobi method, also known as the successive displacement method. This method is named after
Carl Friedrich Gauss (Apr. 1777–Feb. 1855) and Philipp Ludwig von Seidel (Oct. 1821–Aug.
1896).
WHY WE NEED GAUSS SIEDAL METHOD?
In certain cases, such as when a system of equations is large, iterative methods of solving
equations are more advantageous. Elimination methods, such as Gaussian elimination, are prone
to large round-off errors for a large set of equations. Iterative methods, such as the Gauss-Seidel
method, give the user control of the round-off error. Also, if the physics of the problem are well
known, initial guesses needed in iterative methods can be made more judiciously leading to
faster convergence.
Tools:
⦁ Install python in your computer
⦁ Access to the python documentation
Procedure
Algebraically solve each linear equation for xi. Assume an initial guess solution array. Solve for
each xi and repeat. Use absolute relative approximate error after each iteration to check if error is
within a pre-specified tolerance.
Programme:
#step 1 define the equation as function
def equation1 (x,y,z):
return (18 -y -2*z)/3
def equation2 (x,y,z):
return (9 -x -z)/2
def equation3 (x,y,z):
return (14 - 2*x - y)/4
# step 2: Initializing variable
x0, y0, z0 = 0,0,0 #Initial guesses
tolerance = 1e-6 #Tolerance for convergance
max_iteration =3 #Maximum number of iteration
#step 3:Gauss-seidal iteration
for i in range(max_iteration):
x1 = equation1(x0,y0,z0)
y1 = equation2(x1,y0,z0)
z1 = equation3(x1,y1,z0)
for i in range(max_iteration):
x1 = equation1(x0,y0,z0)
y1 = equation2(x1,y0,z0)
z1 = equation3(x1,y1,z0)
if abs(x1-x0) < tolerance and abs(y1 - y0) <tolerance and abs(z1 - z0)<tolerance:
break
#update variable