0% found this document useful (0 votes)
61 views

Gauss Elimination, Gauss-Jordan Elimination and Gauss Seidel Iteration Method: Performance Comparison Using Mat Lab

The document compares the performance of three methods for solving linear systems: Gauss elimination, Gauss-Jordan elimination, and Gauss-Seidel iteration. It describes how each method works and discusses related research showing that Gauss-Jordan elimination is generally more efficient than Gauss elimination, and that the Gauss-Seidel iteration method converges for diagonally dominant matrices. The paper uses MATLAB to solve sample linear systems with each method and compare the execution times.

Uploaded by

Johan Tobing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Gauss Elimination, Gauss-Jordan Elimination and Gauss Seidel Iteration Method: Performance Comparison Using Mat Lab

The document compares the performance of three methods for solving linear systems: Gauss elimination, Gauss-Jordan elimination, and Gauss-Seidel iteration. It describes how each method works and discusses related research showing that Gauss-Jordan elimination is generally more efficient than Gauss elimination, and that the Gauss-Seidel iteration method converges for diagonally dominant matrices. The paper uses MATLAB to solve sample linear systems with each method and compare the execution times.

Uploaded by

Johan Tobing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

International Journal of Engineering Technology Science and Research

IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

Gauss Elimination, Gauss-Jordan Elimination and Gauss


Seidel Iteration Method: Performance Comparison using
MAT LAB

*Dr. Udai Bhan Trivedi , **Mr. Santosh Kumar Sharma, ***Mr. Vishok Kumar Singh
*PSIT college of Higher Education, Kanpur
** PSIT college of Higher Education, Kanpur
***IMS Unison University, Dehradun

ABSTRACT:
This Paper compares the Execution time taken by various methods for solving linear systems i.e. Gauss Elimination,
Gauss Jordan Elimination Methods and Gauss Seidel iterative Methods. The paper uses MAT LAB R2012a software to
solve the problems of linear equations with these methods.
The Various Linear Equations with two, three, four, five and six variable has been solved with these methods using
computer program developed in MAT LAB language. Total Time taken by these algorithms involved have calculated and
compared. This paper also explicitly reveals that in some situations the Gauss Seidel Iteration Method is not convergent.
KEYWORDS: Gauss Elimination, Gauss Jordan Elimination, Gauss Seidel Iteration Method, MAT LAB
Programming, Linear system.

I. RELATED RESERCH WORKS


Adenegan and his batch mate from mathematics department, Adeyemi College of Education ,Ondo Quoted in
their research paper that Gauss Jordan Method is more efficient method than Gaussian Elimination methods
because it avoids the process of backward substitution. It was was also observed that Gauss Jordan Method
and Gaussian Elimination methods gives the same answer for each worked example with pivoting and partial
pivoting process.[3].
Fadugba Sunday Emmanuel from Department of Mathematical Sciences, Ekiti State University, Ado Ekiti,
Nigeria study on his paper on “Some Iterative Methods for Solving Systems of Linear Equations” shows that
the modified Jacobi method is more efficient in term of storage than the Jacobi method. Thus, the modified
Jacobi method is proceed through less numbers of iterations and the rate of its convergence is faster than
Jacobi method. They also Quotes that System with a diagonally dominant coefficient matrix will always
convergent.
Diagonally dominant: [A] in [A] [X] = [C] is diagonally dominant if the coefficient on the diagonal must
satisfied the condition below for all value of i and j where n*n is the dimension of augmented matrix [A] [6].
n n

aii   aij For all ‘i’ and aii   aij for at least one ‘i’
j 1
j 1 j i
j i

Dr.P.V.Ubale, G.S.Sci,Arts,Comm. College , Khamgaon on his article “Comparison of solution of 3x3 system
of linear equation in terms of Cost” concludes that Gauss Jordan method is very expensive as compared to the
Gauss elimination method in order to find out solution from system of linear Equations. [7].

753 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh
International Journal of Engineering Technology Science and Research
IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

R. B. Srivastava and Vinod Kumar examined the comparison of numerical efficiencies of Gaussian
Elimination and Gauss -Jordan Elimination methods for the solutions of linear simultaneous equations. In his
research work they solved twenty simultaneous equations with the help of computer program which was
developed in C++ Programming Language. They find that the efficiency of Gaussian elimination method
depends on the number of calculation involved in the solution of linear simultaneous equation. As the number
of calculations increases; the efficiency of Gaussian elimination method decreases and vice-versa [4].

II. BACKGROUND THEORATICAL CONCEPTS


A linear system of variables x1, x2 ...xn is linear equations of the form
a1x1 + a2x2 +........ + anxn = b;
The value of a1, a2....... an and b are any constant real / complex numbers. The constant ai is called the
coefficient of xi, and b is called the constant term of the equation.
A system of linear equations (or linear system) is a finite collection of linear equations in same variables.
a11x1 + a12x2 + … + a1nxn = a1,n+1
a21x1 + a22x2 + … + a2nxn = a2,n+1
a31x1 + a32x2 + … + a3nxn = a3,n+1
………………
an1x1 + an3x2 + … + annxn = an,n+1
A solution of a linear system is a tuple (v1,v2.......vn) of numbers that satisfied each linear equation when the
values v1,v2.......vn are substituted for x1, x2, .....xn respectively.
The set of all solutions of a linear system is called the solution set of the system. A linear system can have:
(a) No possible solution.
(b) Unique solution
(c) Many solutions.
A linear system is consistent if it has at least one solution otherwise inconsistent. In general, a system with
less number of equation than unknown have many possible solution and that system is known as an un
deterministic system. A system with the equal number of equation and unknowns has a unique solution. A
system with more equations than unknowns has no solution.
There are many methods of solving linear systems. Among them, Gauss, Gauss Jordan elimination and Gauss
Seidel Iteration methods shall be considered. So, they are discussed in details in the following sections [8].
A) GAUSS ELIMINATION METHOD
Gaussian elimination method is based on method which applies various row operations in matrix in such
manner which finally convert Augmented Matrix [A] in the form of upper triangular Matrix.
Consider the system of linear equation
a11x1 + a12x2 + … + a1nxn = a1,n+1
a21x1 + a22x2 + … + a2nxn = a2,n+1
a31x1 + a32x2 + … + a3nxn = a3,n+1
………………
an1x1 + an3x2 + … + annxn = an,n+1
This can be represented in matrix form as follows
a11 a12 + … + a1n x1 a1, n+1
a21 a22 + ... +a2n x2 a2, n+1
a31 a32 + … + a3n x3 == a3, n+1
… … … … … …............... .......
an1 an3 + … + ann xn an, n+1

754 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh
International Journal of Engineering Technology Science and Research
IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

The algorithms consists of following three major steps


1. Read the Augment matrix A
2. Reduce the matrix in upper triangular form
3. Use backward substitution to get the solution
If 0 is located on the diagonal, switch the rows until a non zero is in that place. If shifting of row not possible
then system has either infinite or no solution.
The Matlab Function GAUSS_ELIM (A,b) code of above procedure is listed below, This function accept input
(i) augmented matrix(A) (ii) and Constant Vector (b) and return solution to the linear system AX = b as vector
[x]
function x = GAUSS_ELIM(A, b)
n = size(A, 1);
r = zeros(n, 1);
for i = 1 : 1 : n
r(i) = i;
end
x = zeros(n, 1);
for k = 1 : 1 : n
% Compare each element in r(k)th column for the max
max = abs(A(r(k), r(k)));
max_pos = k;
for l = k : 1 : n
if abs(A(r(l), r(k))) > max
max = abs(A(r(l), r(k)));
max_pos = l;
end
end
temp_r = r;
r(k) = temp_r(max_pos);
r(max_pos) = temp_r(k);
for i = 1 : 1 : n
if i ~= k
zeta = A(r(i), k) / A(r(k), k);
for j = k : 1 : n
A(r(i), j) = A(r(i), j) - A(r(k), j) * zeta;
end
b(r(i)) = b(r(i)) - b(r(k)) * zeta;
end
end
end
for i = 1 : 1 : n
x(i) = b(r(i)) / A(r(i), i);
end
end
B) GAUSS JORDAN ELIMINATION METHOD
In the Gauss elimination method the coefficient matrix was reduced to an upper triangular matrix and the
backward substitution was applied. In Gauss Jordan elimination method the matrix is reduced into a diagonal

755 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh
International Journal of Engineering Technology Science and Research
IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

matrix. At all steps of Gauss elimination method the elimination is done not only for the lower diagonal
entries but also the upper diagonal entries.
Consider the system of linear equation
a11x1 + a12x2 + … + a1nxn = a1,n+1
a21x1 + a22x2 + … + a2nxn = a2,n+1
a31x1 + a32x2 + … + a3nxn = a3,n+1
………………
an1x1 + an3x2 + … + annxn = an,n+1

Where aij and ai,j+1 are known constant and xi’s are unknowns. The system is equivalent to AX = b. Where
A is augmented matrix and X is column vector of unknown variable and b is Column Vector of Constant
known as Constant vector
The general procedure for Gauss Jordan elimination can be summarized in the following steps:
The algorithms consists of following three major steps
1. Read the Augment matrix A
2. Reduce the augmented matrix [A/b] to the transform A into diagonal form (pivoting).
3. Divide right-hand side’s elements as well as diagonal elements by the diagonal elements in the row, which
will make each diagonal element equal to one

If a 0 is located on the diagonal, switch the rows until a non-zero is in that place. If you are unable to do so,
stop; the system has either infinite or no solution.

The MAT LAB Function gauss_jordan (x) code of above procedure is listed below, This function accept input
(i) concatenation of augmented matrix(A) and Constant Vector (b) and return solution to the linear system AX
= b as vector [y]

function [y] = gauss_jordan (x)


for n = 1:(length(x)-1)
A = x(n,:);
A = A/A(n);
x(n,:) = A;
for k = 1:(length(x)-1)
if n~=k
x(k,:) = A*(-1*x(k,n)) + x(k,:);
end
end
end
y = x(:,length(x))';
end

C) THE GAUSS-SEIDEL METHOD


The Gauss-Seidel method, named after Carl Friedrich Gauss (1777–1855) and Philipp L. Seidel (1821–1896).
With the Gauss-Seidel method, algorithm uses the new values of each xi as soon as they are known. That is,
first we have to determined x1from the first equation and then value of x1 is used in the second equation to

756 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh
International Journal of Engineering Technology Science and Research
IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

find the new value of x2. Similarly, the new x1 and x2 will be used in third equation to find the value of x3 and
so on.
after every iteration, the algorithm calculates the absolute relative error for each of xi as
|e|=| (xi(new)-xi(old))/ xi(new) | * 100
When the absolute relative approximate error for each xi is less than the pre-specified tolerance, the iterations
are stopped [8]
Consider the system of linear equation
a11x1 + a12x2 + … + a1nxn = a1,n+1
a21x1 + a22x2 + … + a2nxn = a2,n+1
a31x1 + a32x2 + … + a3nxn = a3,n+1
………………
an1x1 + an3x2 + … + annxn = an,n+1
Rewriting each equation
From Equation (1)

c1  a12 x 2  a13 x3    a1n x n


x1 
From equation (2) anda11so on from equation (n-1) and from equation (n)

c2  a21 x1  a23 x3    a2 n xn
x2 
a22
  
cn 1  an 1,1 x1  an 1, 2 x2    an 1,n  2 xn  2  an 1,n xn
xn 1 
an 1,n 1
cn  an1 x1  an 2 x2     an ,n 1 xn 1
xn 
ann
General Form of each equation

n
c1   a1 j x j
j 1
j 1
x1 
a11
n
c2   a 2 j x j
j 1
j2
x2 
a22

................................
n
cn 1 
j 1
a n 1, j xj
j  n 1
xn 1 
an 1,n 1

757 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh
International Journal of Engineering Technology Science and Research
IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

n
c n   a nj x j
j 1
jn
xn 
a nn

The algorithm start with an initial guess x1=x2=......xn=0 the initial guess can also be stored in another variable
y1=y2=.......yn=0 when these values are substituted in equation (1) that will produce the a new value for x1 and
when the new values of x1, together with old values of x2,x3,....xn are substituted in equation(2) we get the new
value of x2. And in same manner the algorithm calculate the new value of x1, x2 ...xn. The old values are
available in y1, y2 ...yn. If the old values and new values are become identical the process will stop, otherwise
transfer the new values to the variable y1,y2,....yn and continuing the same procedure to get fresh better value
of x1, x2,....xn. The procedure will stop when old values and new values are almost same
The MAT LAB Function gauss_jordan itergauss( A,b,n ) code of above procedure is listed below, This
function accept input (i) augmented matrix(A) (ii) Constant Vector (b) (iii) number of iteration(n) and solution
to the linear system AX = b as vector [x]
function [ x ] = itergauss( A,b,n )
%%check if gauss-seidel method is applicable

[si,sj]=size(A);
if si~=sj
disp('error matrix is not square');
return
end
if prod(diag(A))==0
disp('gauss-seidel iterative method is not applicable');
return
end
E=tril(A,-1);
F=triu(A,1);
D=A-E-F
Bj=-inv(D)*(E+F);
rho=max(abs(eig(Bj))); %spectral radius
if rho>=1
disp('gauss-seidel method do not converge');
return
end
y=zeros(si,n);
tic
for i=[1:1:n]
y(:,i+1)=inv(D+E)*(b-F*y(:,i));
end
x=y(:,n);
execution_time=toc
end

758 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh
International Journal of Engineering Technology Science and Research
IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

III. DESIGN AND IMPLEMENTATION OF THE COMPARATIVE SYSTEM


In The comparative study of Execution time among Gauss Elimination method, Gauss Jordan method and
Gauss Seidel Methods Which have been implemented by MAT LAB. GAUSS_ELIM(A, b) , gauss_jordan (x)
and itergauss( A,b,n ) respectively. These functions has been called between tic..toc syntax in order to get the
execution time of the algorithm. Three Scripts file names as gelim.m, gjor.m and gsei.m has been created to
call these functions in MAT LAB environment. Six inputs have been submitted to these methods and recorded
execution time for each input.
Figure 1: The Proposed System Design

START

Gauss Elimination or
Gauss Jordan or Gauss
Seidel Iteration

Send input problem Send input problem Send input problem

Apply GAUSS_ELIM(A, b) method of Apply gauss_jordan (x) method of Apply itergauss( A,b,n ) method of
Gauss Elimination Gauss Jordan Gauss Seidel

Show result and execution time Show result and execution time Show result and execution time

Compare the result

END

759 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh
International Journal of Engineering Technology Science and Research
IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

Figure 2: Snap Shot of MAT LAB Software


The table listed below is shows the execution time taken by each function in case of 2, 3, 4, 5, 6 Variable. The
script has been fired five times in each case and then average of these times is taken as execution time for the
algorithm
The value of execution time between the Gauss Elimination, Gauss Jordan Elimination and Gauss Seidel
Algorithm is mentioned in Table 1 and summative table 2.

760 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh
International Journal of Engineering Technology Science and Research
IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

TABLE 1: EXECUTION TIME


Execution Execution
Time for Time for
Numbers of Gauss Gauss-Jordan Execution Time for Gauss-seidel
Linear Equation
Variables Elimination Elimination Iteration method (seconds)
method method
(seconds) (seconds)
0.00024 0.000337 0.000993
0.00024 0.000282 0.001008
2
0.000259 0.000288 0.001007
0.000302 0.000343 0.000979 3x1-x2=7
2x1+3x2=1
0.000231 0.000342 0.000994
Average 0.0002544 0.0003184 0.0009962
63 0.000282 0.000338 0.001044
0.000304 0.000511 0.00105
0.000315 0.000317 0.002077 10x1+2x2+x3=9
0.000283 0.000345 0.001217 2x1+20x2-2x3= - 44
0.000314 0.000363 0.001135 -2x1+3x2+10x3=22
Average
0.0002996 0.0003748 0.0013046
4 0.000346 0.00031 0.001073
0.000355 0.000345 0.001067
10x1-2x2-x3-x4=3
0.000335 0.000352 0.00106
-2x1+10x2-x3-x4=15
0.000371 0.000375 0.001061 -x1-x2+10x3-2x4=27
0.000331 0.000385 0.001081 -x1-x2-2x3+10x4= - 9
Average
0.0003476 0.0003534 0.0010684
0.000363 0.000416 gauss-seidel method do not converge
0.000377 0.000411 gauss-seidel method do not converge
0.000462 0.000417 gauss-seidel method do not converge
0.000364 0.000342 gauss-seidel method do not converge
0.000381 0.000404 gauss-seidel method do not converge
x1+2x2-3x3+x4+2x5=4
3x1+2x2-x3-3x4+3x5= -8
-2x1+3x2-2x3-3x4+x5= -7
x1+x2-3x3-2x4-x5= -1
x1-2x2+3x3-2x4-2x5= -5
0.0003894 0.000398 gauss-seidel method do not converge
5

Average

6 0.000352 0.000373 gauss-seidel method do not converge


0.000348 0.000392 gauss-seidel method do not converge x1+x2-2x3+x4+3x5-x6=4
2x1-x2+x3+2x4+x5-3x6=20
0.000382 0.000385 gauss-seidel method do not converge
x1+3x2-3x3-x4+2x5+x6= -15
0.000385 0.000371 gauss-seidel method do not converge 5x1+2x2-x3-x4+2x5+x6= -3
0.000399 0.000372 gauss-seidel method do not converge -3x1-x2+2x3+3x4+x5+3x6=16
Average 4x1+3x2+x3-6x4-3x5-2x6= -27
0.0003732 0.0003786 gauss-seidel method do not converge

Because the standard deviation of all the above observation in the table is very low for respective methods we
can conclude that the average can be represent the entire class.

761 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh
International Journal of Engineering Technology Science and Research
IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

TABLE 2: SUMMATIVE EXECUTION TIME


Execution Time Execution Time
for Gauss for Gauss-Jordan
Elimination Elimination
Numbers of method (Macro method (Macro Execution Time for Gauss-seidel Iteration
Variables Second) Second) method (Macro Second)
2 254.4 318.4 996.2
3 299.6 374.8 1304.6
4 347.6 353.4 1068.4
5 389.4 398 gauss-seidel method do not converge
6 373.2 378.6 gauss-seidel method do not converge

Figure 3: Line Graph Among time taken by different Algorithm in MAT LAB

IV. CONCLUSION
After analysing the above table, conclusion can be drawn that generally Gauss Elimination Method is faster
than the Gauss Jordan Elimination method and Gauss Seidel Iterative Method. The efficiency of Gaussian
elimination method depends on the number of calculation involved in the solution of linear simultaneous
equation. As the number of calculations increases; the efficiency of Gaussian elimination method decreases
and vice-versa due to more time has been taken by algorithm in backward substitution.
The time taken by these algorithms implemented in MAT LAB software is far less than if same would be
implemented by using C++, Java or any high programming language, due to support of Vector
Processing(parallel processing) while dealing with Matrix, by MAT LAB.
The Gauss Seidel Iterative Method is the slowest among all algorithms and suffers with problem of
convergence (in our five and six variable case). Gauss Seidel Algorithm which is iterative algorithm can find
the solution for linear system where the augmented matrix [A] has diagonally dominant coefficient [6].

762 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh
International Journal of Engineering Technology Science and Research
IJETSR
www.ijetsr.com
ISSN 2394 – 3386
Volume 4, Issue 10
October 2017

V. REFERENCES
[1]. Luke Smith, Joan Powell. An Alternative Method to Gauss-Jordan Elimination: Minimizing Fraction Arithmetic, the
Mathematics Educator, 2011.
[2]. K. Rajalakshmi. Parallel Algorithm for Solving Large System of Simultaneous Linear Equations, IJCSNS
International Journal of Computer Science and Network Security.
[3]. Adenegan, Kehinde Emmanuel1, Aluko. Tope Moses:Gauss and Gauss-Jordan elimination methods for solving
system of linear equations: comparisons and applications, Journal of Science and Science Education, Ondo.
[4]. R.B Srivastava, Vinod Kumar. Comparison of Numerical Efficiencies of Gaussian Elimination and Gauss-Jordan
Elimination methods for the Solutions of linear Simultaneous Equations, Department of Mathematics M.L.K.P.G.
College Balrampur. U.P., India.
[5]. T.J. Dekker, W. Hoffmann. Rehabilitation of the Gauss- Jordan algorithm, Department of Computer Systems,
University of Amsterdam, Kruisl
[6] Fadugba Sunday Emmanuel. Some Iterative Methods for Solving Systems of Linear Equations. Department of
Mathematical Sciences, Ekiti State University, Ado Ekiti, Nigeria
[7] Dr.P.V.Ubale. “Comparison of solution of 3x3 system of linear equation in terms of Cost” G.S.Sci,Arts,Comm.
College , Khamgaon
[8] C.xavier. Fortran 77 and Numerical Methods. Derpartment of Computer Science, Madurai Kamraj University.
[9] Jeff Christensen. A Brief History of Linear Algebra. Final Project Math 2270 Grant Gustafson, University of Utah
[10] Tucker, Alan. (1993). “The Growing Importance of Linear Algebra in Undergraduate Mathematics” . The College
Mathematics Journal, 1, 3-9

763 Dr. Udai Bhan Trivedi , Mr. Santosh Kumar Sharma,Mr. Vishok Kumar Singh

You might also like