Expt No 5 Numerical
Expt No 5 Numerical
Expt Name: Solving system of linear equations using Gauss Elimination method
Objectives:
To transform the system of linear equations into an upper triangular matrix.
To perform a back substitution to find the solution vector.
To verify the accuracy and consistency of the obtained solutions.
Theory:
Gauss elimination is a fundamental algorithm for solving systems of linear equations. It transforms a
given system into an upper triangular matrix, which can then be solved using back substitution. The
method involves two main phases: forward elimination and back substitution. In the forward elimination
phase, the algorithm systematically eliminates the lower triangular elements of the coefficient matrix by
performing row operations. This transforms the system into an upper triangular form, where all elements
below the main diagonal are zero. This process is achieved by iteratively subtracting a multiple of the
pivot row from the rows below it. The back substitution phase begins after the matrix is in upper
triangular form. The algorithm solves for that variable starting from the last equation, which contains only
one unknown. This solution is then used in the next equation up to solve for another variable, and the
process continues until all variables are determined.
Algorithm:
1. Initialize the augmented matrix A:
A is an 𝑛×(𝑛+1) matrix where the last column represents the constants of the linear equations.
2. For each column 𝑘 from 1 to 𝑛−1:
Select the pivot element: The pivot element is 𝐴(𝑘,𝑘).
For each row 𝑖 from 𝑘+1 to 𝑛:
Compute the multiplier:
factor=𝐴(𝑖,𝑘)/𝐴(𝑘,𝑘)
Update the row 𝑖 by subtracting the factor times the pivot row from the current row:
𝐴(𝑖,:)=𝐴(𝑖,:)−factor×𝐴(𝑘,:)
Back Substitution
1. Initialize the solution vector 𝑥 of size 𝑛.
𝑥 is a column vector where 𝑥(𝑖) represents the 𝑖-th variable.
2. For each row 𝑖 from 𝑛 to 1 (backward):
Initialize the sum: sum=0
For each column 𝑗 from 𝑖+1 to 𝑛:
Update the sum: sum=sum+ 𝐴(𝑖,𝑗)×𝑥(𝑗)
Compute the solution for 𝑥(𝑖): 𝑥(𝑖) = A(i , n+1)−
∑¿ ¿
A (i ,i)
MATLAB Code:
Discussion:
The Gauss elimination method was used to solve a system of linear equations. This method started with
an augmented matrix representing the coefficients and constants of the linear equations. Through a
process of forward elimination, we systematically reduced the matrix to an upper triangular form. This
involved performing row operations to eliminate the elements below the main diagonal. Once the matrix
was in upper triangular form, we applied back substitution to find the solutions to the system.
The forward elimination transformed the system into a simpler form, where each equation only involved
one additional unknown compared to the previous equation. This made the back substitution process
straightforward, starting from the last equation and working upwards to solve for each unknown in turn.
The main advantage of the Gauss elimination method was its straightforward and systematic approach,
making it suitable for solving systems of linear equations with a clear, step-by-step procedure. However,
the Gauss elimination method had some limitations. It could be computationally intensive for very large
systems, as the number of operations increased significantly with the size of the matrix. Despite these
limitations, the Gauss elimination method was successful in solving systems of linear equations
efficiently.
Lab Report
Department of EEE
Exp. No: 05
Exp. Name: Solving system of linear equations using the Gauss
Elimination method