You are on page 1of 8

LAB 0 5

Introduction to Power System Analysis

Study and Implementation of Gauss Seidel Method for


the solution of equations using MATLAB

Submitted By:

18-EE-047

Power System Analysis (Lab)

Department of Electrical Engineering

University of Engineering and Technology, Taxila


5.1 Objectives:

i). To study about , the Gauss–Seidel method and perform it on matlab by solving equations.

ii). To understand about the Algorithm Design and formulation of code that formulates the
Gauss–Seidel method

5.2 Theoretical Background:

In numerical linear algebra, the Gauss–Seidel method, also known as the Liebmann method or
the method of successive displacement, is an iterative method used to solve a system of linear
equations. It is named after the German mathematicians Carl Friedrich Gauss and Philipp Ludwig von
Seidel, and is similar to the Jacobi method. Though it can be applied to any matrix with non-zero
elements on the diagonals, convergence is only guaranteed if the matrix is either strictly diagonally
dominant, or symmetric and positive definite. Gauss-Seidel method is a popular iterative method of
solving linear system of algebraic equations. It is applicable to any converging matrix with non-zero
elements on diagonal. The method is named after two German mathematicians: Carl Friedrich Gauss
and Philipp Ludwig von Seidel.

Gauss-Seidel is considered an improvement over Gauss Jacobi Method. In this method, just like any
other iterative method, an approximate solution of the given equations is assumed, and iteration is
done until the desired degree of accuracy is obtained.

The Gauss–Seidel method is an iterative technique for solving a square system


of n linear equations with unknown x:
AX=b
The element-wise formula for the Gauss–Seidel method is extremely similar to that of
the Jacobi method.
The computation of x(k+1) uses the elements of x(k+1) that have already been
computed, and only the elements of x(k) that have not been computed in the k+1 iteration.
This means that, unlike the Jacobi method, only one storage vector is required as elements
can be overwritten as they are computed, which can be advantageous for very large
problems.
However, unlike the Jacobi method, the computations for each element cannot be done
in parallel. Furthermore, the values at each iteration are dependent on the order of the
original equations.

The matrices, iterations, and the procedure explained below cover the basic guidelines to
write the program code for Gauss-Seidel method in MATLAB.
equations can be presented in matrix form
Or simply, it can be written as: [A][X] = [B]

Now, decomposing the matrix A into its lower triangular component and upper triangular
component, we get:

A=LxU

where,

Further, the system of linear equations can be expressed as:

L x X = B – UX —–(a)

In Gauss-Seidel method, the equation (a) is solved iteratively by solving the left
hand value of x and then using previously found x on right hand side.
Mathematically, the iteration process in Gauss-Seidel method can be expressed
as:

X(k+1) = L -1( B –UX(k) )

Applying forward substitution, the elements of X(k+1) can be computed as follows:


The same procedure aforementioned is followed in the MATLAB program for this
method. The process of iteration is continued till the values of unknowns are
under the limit of desired tolerance.

5.2.1 Example:
2x+5y=21
x+2y=8

Solve Equations 2x+5y=16, 3x+y=11 using Gauss Seidel method

Solution:
Total Equations are 2
2x+5y=16

3x+y=11

The coefficient matrix of the given system is not diagonally dominant.


Hence, we re-arrange the equations as follows, such that the elements in the coefficient matrix are
diagonally dominant.
3x+y=11

2x+5y=16

From the above equations


x=13(11-y)

y=15(16-2x)

Solution steps;
1st Approximation

x1=13[11-(0)]=13[11]=3.666667

y1=15[16-2(3.666667)]=15[8.666667]=1.733333

2nd Approximation

x2=13[11-(1.733333)]=13[9.266667]=3.088889

y2=15[16-2(3.088889)]=15[9.822222]=1.964444

3rd Approximation

x3=13[11-(1.964444)]=13[9.035556]=3.011852
y3=15[16-2(3.011852)]=15[9.976296]=1.995259

4th Approximation

x4=13[11-(1.995259)]=13[9.004741]=3.00158

y4=15[16-2(3.00158)]=15[9.99684]=1.999368

5th Approximation

x5=13[11-(1.999368)]=13[9.000632]=3.000211

y5=15[16-2(3.000211)]=15[9.999579]=1.999916

6th Approximation

x6=13[11-(1.999916)]=13[9.000084]=3.000028

y6=15[16-2(3.000028)]=15[9.999944]=1.999989

Solution By Gauss Seidel Method.


x=3.000028
y=1.999989
5.2 Gauss-Seidel Method MATLAB Program
Example:

4x1 – x2 –x3 = 3
-2x1 + 6x2 + x3 = 9
-x1 + x2 – 7x3 = -6

5.2.1 Code:
5.2.2 Answers:
So,
X1 = 1;
X2 = 2;
X3 = -1;

5.3 Conclusion:
The algorithm and code of Gauss-Seidel Method can be formulated using MATLAB and data
can be made user defined to solve different equations by just adding different values for equations. To
solve equations by using Gauss –seidel method code is the easiest way to get accurate answer.

5.3 Lesson learned:


In this lab, I learned to make a MATLAB program which can solve any equation by Gauss-seidel
method. I also learned to solve equations mathematically .

You might also like