ict tool: - ‘c’ language program for gauss elimination method · gauss elimination method is a...

6
International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: [email protected] Volume 6, Issue 11, November 2017 ISSN 2319 - 4847 Volume 6, Issue 11, November 2017 Page 33 Abstract In Mathematics to solve System of Linear Equations, manually it is very difficult task to get the required output need to perform. Gauss Elimination Method is a popular technique of linear algebra for solving system of linear equations. As the manipulation process of the method is based on various row operations of augmented matrix, it is also known as row reduction method. Gauss elimination method has various uses in finding rank of a matrix, calculation of determinant and inverse of invertible matrix. In the era of Information Communication Technology (ICT) .The ICT programming technique, it is easier task. One of the very popular programs in C programming is Gauss Elimination Method. This paper discuss Gauss Elimination Method in C language, source code and methods with outputs. The source codes of program for Gauss Elimination Method in C programming are to be compiled. Running them on Turbo C or available version and other platforms might require a few modifications to the code. Keywords: Gauss Elimination, ICT, C Lang., Turbo C, System of Linear Equations. 1. INTRODUCTION When One of the very popular programs in C programming is Gauss Elimination Method. Gauss Elimination method can be adopted to find the solution of linear simultaneous equations arising in engineering problems. In the method, equations are solved by elimination procedure of the unknowns successively, whereas a program in C can carry out the operations with short, simple and understandable codes. In engineering and science, the solution of linear simultaneous equations is very important. Different analysis such as electronic circuits comprising invariant elements, a network under steady and sinusoidal condition, output of a chemical plant and finding the cost of chemical reactions in such plants require the solution of linear simultaneous equations. In Gauss-Elimination method, these equations are solved by eliminating the unknowns successively. In linear algebra, Gaussian elimination (also known as row reduction) is an algorithm for solving systems of linear equations. It is usually understood as a sequence of operations performed on the corresponding matrix of coefficients. This method can also be used to find the rank of a matrix, to calculate the determinant of a matrix, and to calculate the inverse of an invertible square matrix. 2. GAUSS ELIMINATION METHOD The equation a x + b y + c z + d w = h where a, b, c, d, and h are known numbers, while x, y, z, and w are unknown numbers, is called a linear equation. If h =0, the linear equation is said to be homogeneous. A linear system is a set of linear equations and a homogeneous linear system is a set of homogeneous linear equations. 2.1 Method for Gauss Elimination Gaussian elimination is a method for solving matrix equations of the form (1) To perform Gaussian elimination starting with the system of equations ICT Tool: - ‘C’ Language Program for Gauss Elimination Method Sanjay C. Gawande 1 , Pradip P. Kolhe 2 and Prakash R. Kolhe 3 1 Assistant Professor, College of Agriculture, Dr. PDKV, Akola 2 Assistant Professor, ARIS Cell, Dr. PDKV, Akola 3 Associate Professor (CAS), CAET, Dr. BSKKV, Dapoli

Upload: others

Post on 10-Feb-2020

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ICT Tool: - ‘C’ Language Program for Gauss Elimination Method · Gauss Elimination Method is a popular technique of linear algebra for solving system of linear equations. As the

International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: [email protected]

Volume 6, Issue 11, November 2017 ISSN 2319 - 4847

Volume 6, Issue 11, November 2017 Page 33

Abstract In Mathematics to solve System of Linear Equations, manually it is very difficult task to get the required output need to perform. Gauss Elimination Method is a popular technique of linear algebra for solving system of linear equations. As the manipulation process of the method is based on various row operations of augmented matrix, it is also known as row reduction method. Gauss elimination method has various uses in finding rank of a matrix, calculation of determinant and inverse of invertible matrix. In the era of Information Communication Technology (ICT) .The ICT programming technique, it is easier task. One of the very popular programs in C programming is Gauss Elimination Method. This paper discuss Gauss Elimination Method in C language, source code and methods with outputs. The source codes of program for Gauss Elimination Method in C programming are to be compiled. Running them on Turbo C or available version and other platforms might require a few modifications to the code. Keywords: Gauss Elimination, ICT, C Lang., Turbo C, System of Linear Equations.

1. INTRODUCTION When One of the very popular programs in C programming is Gauss Elimination Method. Gauss Elimination method can be adopted to find the solution of linear simultaneous equations arising in engineering problems. In the method, equations are solved by elimination procedure of the unknowns successively, whereas a program in C can carry out the operations with short, simple and understandable codes.

In engineering and science, the solution of linear simultaneous equations is very important. Different analysis such as electronic circuits comprising invariant elements, a network under steady and sinusoidal condition, output of a chemical plant and finding the cost of chemical reactions in such plants require the solution of linear simultaneous equations.

In Gauss-Elimination method, these equations are solved by eliminating the unknowns successively. In linear algebra, Gaussian elimination (also known as row reduction) is an algorithm for solving systems of linear equations. It is usually understood as a sequence of operations performed on the corresponding matrix of coefficients. This method can also be used to find the rank of a matrix, to calculate the determinant of a matrix, and to calculate the inverse of an invertible square matrix. 2. GAUSS ELIMINATION METHOD The equation a x + b y + c z + d w = h where a, b, c, d, and h are known numbers, while x, y, z, and w are unknown numbers, is called a linear equation. If h =0, the linear equation is said to be homogeneous. A linear system is a set of linear equations and a homogeneous linear system is a set of homogeneous linear equations. 2.1 Method for Gauss Elimination

Gaussian elimination is a method for solving matrix equations of the form

(1)

To perform Gaussian elimination starting with the system of equations

ICT Tool: - ‘C’ Language Program for Gauss Elimination Method

Sanjay C. Gawande1, Pradip P. Kolhe2 and Prakash R. Kolhe3

1Assistant Professor, College of Agriculture, Dr. PDKV, Akola

2Assistant Professor, ARIS Cell, Dr. PDKV, Akola

3Associate Professor (CAS), CAET, Dr. BSKKV, Dapoli

Page 2: ICT Tool: - ‘C’ Language Program for Gauss Elimination Method · Gauss Elimination Method is a popular technique of linear algebra for solving system of linear equations. As the

International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: [email protected]

Volume 6, Issue 11, November 2017 ISSN 2319 - 4847

Volume 6, Issue 11, November 2017 Page 34

(2) compose the "augmented matrix equation"

(3) Here, the column vector in the variables is carried along for labeling the matrix rows. Now, perform elementary row operations to put the augmented matrix into the upper triangular form

(4) Solve the equation of the th row for , then substitute back into the equation of the st row to obtain a solution for , etc., according to the formula

(5) A matrix that has undergone Gaussian elimination is said to be in echelon form. For example, consider the matrix equation

(6) In augmented form, this becomes

(7) Switching the first and third rows (without switching the elements in the right-hand column vector) gives

(8) Subtracting 9 times the first row from the third row gives

(9) Subtracting 4 times the first row from the second row gives

(10)

Page 3: ICT Tool: - ‘C’ Language Program for Gauss Elimination Method · Gauss Elimination Method is a popular technique of linear algebra for solving system of linear equations. As the

International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: [email protected]

Volume 6, Issue 11, November 2017 ISSN 2319 - 4847

Volume 6, Issue 11, November 2017 Page 35

Finally, adding times the second row to the third row gives

(11) Restoring the transformed matrix equation gives

(12) which can be solved immediately to give , back-substituting to obtain (which actually follows trivially in this example), and then again back-substituting to find 2.2 Rules for Gauss Elimination Gaussian elimination is summarized by the following three steps:

1. Write the system of equations in matrix form. Form the augmented matrix. You omit the symbols for the variables, the equal signs, and just write the coefficients and the unknowns in a matrix. You should consider the matrix as shorthand for the original set of equations.

2. Perform elementary row operations to get zeros below the diagonal.

3. An elementary row operation is one of the following:

_ multiply each element of the row by a non-zero constant

_ switch two rows

_ add (or subtract) a non-zero constant times a row to another row

4. Inspect the resulting matrix and re-interpret it as a system of equations.

If you get 0 = a non-zero quantity then there is no solution.

_ If you get less equations than unknowns after discarding equations of the form 0=0 and if there is a solution then there is an infinite number of solutions

_ If you get as many equations as unknowns after discarding equations of the form 0=0 and if there is a solution then there is exactly one solution

For two equations and two unknowns, the equations represent two lines. There are three possibilities:

a) There is a unique solution (the lines intersect at a unique point)

b) There is no solution (the two lines are parallel and don't intersect)

c) There is an infinite number of solutions (the two equations represented the same line)

For three equations and three unknowns, each equations represents a plane and there are again three

Possibilities

a) There is a unique solution

b) There is no solution

c) There is an infinite number of solutions.

2.3 Gauss Elimination Algorithm: 1. Start 2. Declare the variables and read the order of the matrix n. 3. Take the coefficients of the linear equation as:

Do for k=1 to n Do for j=1 to n+1 Read a[k][j]

Page 4: ICT Tool: - ‘C’ Language Program for Gauss Elimination Method · Gauss Elimination Method is a popular technique of linear algebra for solving system of linear equations. As the

International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: [email protected]

Volume 6, Issue 11, November 2017 ISSN 2319 - 4847

Volume 6, Issue 11, November 2017 Page 36

End for j End for k

4. Do for k=1 to n-1 Do for i=k+1 to n Do for j=k+1 to n+1 a[i][j] = a[i][j] – a[i][k] /a[k][k] * a[k][j] End for j End for i End for k

5. Compute x[n] = a[n][n+1]/a[n][n] 6. Do for k=n-1 to 1

sum = 0 Do for j=k+1 to n sum = sum + a[k][j] * x[j] End for j x[k] = 1/a[k][k] * (a[k][n+1] – sum) End for k

7. Display the result x[k] 8. Stop

2.4 Flowchart for Gauss Elimination

2.5 C Program for Gauss Elimination

#include<stdio.h> int main() { inti,j,k,n; float A[20][20],c,x[10],sum=0.0; printf("\nEnter the order of matrix: "); scanf("%d",&n); printf("\nEnter the elements of augmented matrix row-wise:\n\n"); for(i=1; i<=n; i++) {

Page 5: ICT Tool: - ‘C’ Language Program for Gauss Elimination Method · Gauss Elimination Method is a popular technique of linear algebra for solving system of linear equations. As the

International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: [email protected]

Volume 6, Issue 11, November 2017 ISSN 2319 - 4847

Volume 6, Issue 11, November 2017 Page 37

for(j=1; j<=(n+1); j++) { printf("A[%d][%d] : ", i,j); scanf("%f",&A[i][j]); } } for(j=1; j<=n; j++) /* loop for the generation of upper triangular matrix*/ { for(i=1; i<=n; i++) { if(i>j) { c=A[i][j]/A[j][j]; for(k=1; k<=n+1; k++) { A[i][k]=A[i][k]-c*A[j][k]; } } } } x[n]=A[n][n+1]/A[n][n]; /* this loop is for backward substitution*/ for(i=n-1; i>=1; i--) { sum=0; for(j=i+1; j<=n; j++) { sum=sum+A[i][j]*x[j]; } x[i]=(A[i][n+1]-sum)/A[i][i]; } printf("\nThe solution is: \n"); for(i=1; i<=n; i++) { printf("\nx%d=%f\t",i,x[i]); /* x1, x2, x3 are the required solutions*/ } return(0); }

2.6 Output o Gauss Elimination

Page 6: ICT Tool: - ‘C’ Language Program for Gauss Elimination Method · Gauss Elimination Method is a popular technique of linear algebra for solving system of linear equations. As the

International Journal of Application or Innovation in Engineering & Management (IJAIEM) Web Site: www.ijaiem.org Email: [email protected]

Volume 6, Issue 11, November 2017 ISSN 2319 - 4847

Volume 6, Issue 11, November 2017 Page 38

References [1] Atkinson, Kendall A. (1989), An Introduction to Numerical Analysis (2nd ed.), New York: John Wiley & Sons,

ISBN 978-0-471-50023-0. [2] Bolch, Gunter; Greiner, Stefan; de Meer, Hermann; Trivedi, Kishor S. (2006), Queueing Networks and Markov

Chains: Modeling and Performance Evaluation with Computer Science Applications (2nd ed.), Wiley-Interscience, ISBN 978-0-471-79156-0.

[3] Calinger, Ronald (1999), A Contextual History of Mathematics, Prentice Hall, ISBN 978-0-02-318285-3. [4] Farebrother, R.W. (1988), Linear Least Squares Computations, STATISTICS: Textbooks and Monographs, Marcel

Dekker, ISBN 978-0-8247-7661-9. [5] Lauritzen, Niels, Undergraduate Convexity: From Fourier and Motzkin to Kuhn and Tucker. [6] Golub, Gene H.; Van Loan, Charles F. (1996), Matrix Computations (3rd ed.), Johns Hopkins, ISBN 978-0-8018-

5414-9. [7] Grcar, Joseph F. (2011a), "How ordinary elimination became Gaussian elimination", HistoriaMathematica, 38 (2):

163–218, arXiv:0907.2397, doi:10.1016/j.hm.2010.06.003 [8] Grcar, Joseph F. (2011b), "Mathematicians of Gaussian elimination" (PDF), Notices of the American

Mathematical Society, 58 (6): 782–792 [9] Higham, Nicholas (2002), Accuracy and Stability of Numerical Algorithms (2nd ed.), SIAM, ISBN 978-0-89871-

521-7. [10] Katz, Victor J. (2004), A History of Mathematics, Brief Version, Addison-Wesley, ISBN 978-0-321-16193-2. [11] Kaw, Autar; Kalu, Egwu (2010). "Numerical Methods with Applications" (1st ed.). [1]. External link in

|publisher= (help); , Chapter 5 deals with Gaussian elimination. [12] Lipson, Marc; Lipschutz, Seymour (2001), Schaum's outline of theory and problems of linear algebra, New York:

McGraw-Hill, pp. 69–80, ISBN 978-0-07-136200-9. [13] Press, WH; Teukolsky, SA; Vetterling, WT; Flannery, BP (2007), "Section 2.2", Numerical Recipes: The Art of

Scientific Computing (3rd ed.), New York: Cambridge University Press, ISBN 978-0-521-88068-8