EEE 2206 Lab Report 7 by Saklain
EEE 2206 Lab Report 7 by Saklain
of
Electrical & Electronic Engineering
Lab. Report on
Experiment No: 07
Experiment Name: Experimental study on solution of linear system of
equations by Gaussian Elimination and Gauss-Jordan method using MATLAB
Comments:
Objectives:
Theory:
Linear System of Equations: A system of linear equations consists of multiple linear equations
involving the same set of variables. Solving such systems is essential in various fields of
engineering, physics, and mathematics, where linear relationships model real-world phenomena.
Mathematically, a system of n linear equations with n variables can be represented as
퐴. 푋 =
퐵
Where:
The Gaussian Elimination Method: The Gaussian Elimination method is a systematic procedure
used to transform a system of linear equations into an upper triangular form. This method uses
elementary row operations (row swapping, scaling, and addition/subtraction) to simplify the matrix
into a form where the solutions can be obtained through back-substitution.
1. Forward Elimination: The process begins by creating zeros below the main diagonal to
achieve an upper triangular matrix. This involves scaling rows and eliminating coefficients
in a step-by-step manner.
2. Back Substitution: After achieving the upper triangular form, we solve for each variable
starting from the last equation and moving upwards.
Gaussian Elimination is efficient for many systems, especially when speed is essential. However,
the method may suffer from numerical instability, especially for ill-conditioned matrices, where
small changes in input can lead to significant changes in output.
Algorithms:
1. Start
2. Input the coefficient matrix A and source vector B
3. Determine the length N of the vector B and initialize the solution vector X as a zero vector
of length N.
4. Create an augmented matrix Aug by appending B to A
5. Perform forward elimination to transform the matrix into an upper triangular form
Outer loop: for each row from 1 to N-1
Inner loop: For each row i from j+1 to N
Aug(i,j)
Calculate the multiplier m =
Aug(j,j)
Update the i-th row by subtracting m × j-th row from it
6. Display the augmented matrix Aug after forward elimination.
7. Perform the back substitution for each variable.
Aug(N,N+1)
Set the last element X as
Aug( N,N)
For each row k from N-1 to 1 calculate x(k) using the formula
Aug(k, N + 1) − ∑푁푙 =푘 +1(Aug(k, l) × X(l))
X(k) =
Aug(k, k)
8. Display the solution vector X.
9. End
Gauss-Jordan Method:
1. Start
2. Input the coefficient matrix A and the source vector B.
3. Determine the length N of B
4. Create an augmented matrix Aug by appending B as the last column of A.
5. Perform Gauss-Jordan Elimination to convert the matrix into reduced row echelon form
(RRFF)
For each row j from 1 to N
Normalize the j-th row by dividing it by the pivot element Aug(j,j)
For each i to N
If i≠j calculate the multiplier m= Aug(i,j)
Update the i-th row by subtracting m× the j-th row from it to make all other entries
in the j-th column zero
6. Display the augmented matrix Aug after Gauss-Jordan Elimination.
7. Extract the solution vector X from the last column of the augmented matrix Aug.
8. Display the solution vector X.
9. End
Script code:
Output:
Gauss-Jordan Method:
Script Code:
Output:
Discussion:
In this experiment, both Gaussian Elimination and Gauss-Jordan Elimination methods were used
to solve a system of linear equations in MATLAB, highlighting their approaches, efficiencies, and
practical applications.
Gaussian Elimination transforms the matrix into an upper triangular form, enabling solutions
through back-substitution. This method is computationally efficient, making it suitable for larger
systems. However, it requires an additional step of back-substitution to find the solution, which
can add complexity in manual calculations but is handled efficiently by MATLAB.
Gauss-Jordan Elimination, on the other hand, takes the process further by reducing the matrix to
reduced row echelon form (RREF), allowing direct extraction of the solution vector without back-
substitution. Although Gauss-Jordan Elimination provides a clearer path to unique solutions and
matrix inverses, it involves more operations, making it computationally heavier for large matrices.
Additionally, both methods may encounter numerical instability when pivot elements are close to
zero, which can lead to inaccuracies, especially in ill-conditioned matrices.
The MATLAB implementation of these methods effectively managed the row operations and
minimized potential errors. This experiment demonstrated MATLAB’s capability to perform
complex matrix transformations accurately, facilitating the practical use of Gaussian and Gauss-
Jordan methods for solving linear systems. Both methods proved useful, with Gaussian
Elimination offering efficiency and Gauss-Jordan providing a straightforward approach to unique
solutions, each suited to different applications depending on matrix size and computational needs.
References: