Program for Gauss-Jordan Elimination Method
Prerequisite : Gaussian Elimination to Solve Linear Equations
Introduction : The Gauss-Jordan method, also known as Gauss-Jordan elimination method is used to solve a system of linear equations and is a modified version of Gauss Elimination Method.
It is similar and simpler than Gauss Elimination Method as we have to perform 2 different process in Gauss Elimination Method i.e.
1) Formation of upper triangular matrix, and
2) Back substitution
But in case of Gauss-Jordan Elimination Method, we only have to form a reduced row echelon form (diagonal matrix). Below given is the flow-chart of Gauss-Jordan Elimination Method.
Flow Chart of Gauss-Jordan Elimination Method :
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
Input : 2y + z = 4 x + y + 2z = 6 2x + y + z = 7 Output : Final Augmented Matrix is : 1 0 0 2.2 0 2 0 2.8 0 0 -2.5 -3 Result is : 2.2 1.4 1.2
Explanation : Below given is the explanation of the above example.
- Input Augmented Matrix is :
- Interchanging R1 and R2, we get
- Performing the row operation R3 <- R3 – (2*R1)
- Performing the row operations R1 <- R1 – ((1/2)* R2) and R3 <- R3 + ((1/2)*R2)
- Performing R1 <- R1 + ((3/5)*R3) and R2 <- R2 + ((2/5)*R3)
- Unique Solutions are :
Final Augmented Matrix is : 1 0 0 2.2 0 2 0 2.8 0 0 -2.5 -3 Result is : 2.2 1.4 1.2
- Solving System of Linear Equations: Gauss-Jordan Elimination Method can be used for finding the solution of a systems of linear equations which is applied throughout the mathematics.
- Finding Determinant: The Gaussian Elimination can be applied to a square matrix in order to find determinant of the matrix.
- Finding Inverse of Matrix: The Gauss-Jordan Elimination method can be used in determining the inverse of a square matrix.
- Finding Ranks and Bases: Using reduced row echelon form, the ranks as well as bases of square matrices can be computed by Gaussian elimination method.