You are on page 1of 6

Gauss-Jordan Method

Introduction

One of the methods that can be used to solve a system of linear equations is the
Gauss-Jordan Method. The Gauss-Jordan Method is done by manipulating the system
of linear equations into an equivalent diagonal form with normalized elements in the
diagonal (see equation below). The new vector is the solution when the diagonal
form of the matrix of the coefficients is reduced to the identity matrix.

Objectives

 To solve a system of linear equations using Gauss-Jordan Method.


 To write a user-defined MATLAB function that solves a system of linear
equations with Gauss-Jordan Method.

Sample Problem

1. Write a user-defined MATLAB function that solves a system of n linear


equations, [a][x] = [b], with the Gauss-Jordan method. The program should
include pivoting in which the pivot row is switched with the row that has a
pivot element with the largest absolute numerical value. For the function
name and arguments use x = Gauss Jordan (a, b), where a is the matrix of
coefficients, b is the right-hand-side column of constants, and x is the
solution.
a. Use the GaussJordan function to solve the system:
2 x1 + x 2 +4 x 3−2 x 4 =19
−3 x 1+ 4 x 2+ 2 x 3−x 4 =1
3 x 1+5 x 2−2 x 3+ x 4 =8
−2 x1 +3 x 2+ 2 x 3 +4 x 4=13
b. Use the GaussJordan function to solve the system:
1 2 3 4 5 6 x1 91

[ ][ ] [ ]
1 −3 2 5 −4 6 x2 37
6 1 −2 4 3 5 x3 = 63
3 2 −1 4 5 6 x4 81
4 −2 −1 3 6 5 x5 69
5 −6 −3 4 −2 1 x6 −4

Answer:

2 1 4 −2 19

[
a.)
−3 4 2 −1 1
3 5 −2 1
−2 3 2 4 13
8
]
x1 = 3
x2 = 1
x3 = 4
x4 = 2
1 2 3 4 5 6 91

b.)

[1 −3 2 5 −4
6 1 −2 4 3
3 2 −1 4 5
4 −2 −1 3 6
5 −6 −3 4 −2

Matlab Code
6 37
5 63
6 81
5 69
1 −4
]
The codes used for solving the given system of linear equations are given below.
The codes that were used in this experiment were patterned from the codes found
from the internet (see the link in the references).

Codes for part a: Codes for part b:


Results and Discussion

When the codes were run in Matlab, the command window displayed this:

Part (a): Part (b):

Based on the output, it can be observed that the main diagonal are mainly
composed of 1 and the rest of the elements are 0, for the coefficients of the
variables. The rightmost column presents the solution for the system of linear of
equations
Conclusion

When the system of linear of equations is manipulated into an equal diagonal, the
matrix would be composed of a diagonal composed of one and the rest are zero, for
the coefficient, and the numerical values that can be found at the rightmost part are
the solutions for the system of linear equations.

References

1. Gilat, A., Subramanian, V. 2014. Numerical methods for engineers and


scientists: an introduction applications using matlab.
2. Matlab code guide to create a user-defined function to solve the problem via
Gauss-Jordan Method:
https://gist.github.com/esromneb/1d57b1d16d54cde37332

You might also like