You are on page 1of 3

Experiment No:06

Name of the Experiment: Solving of linear equation using Gauss Elimination Method.

Objective: Our objectives are to know about gauss elimination method and to determine the
roots of simultaneous linear equations which are related to Electrical and Electronic
Engineering.

Theory: 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 associated 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. To perform row reduction on a matrix, one uses a
sequence of elementary row operations to modify the matrix until the lower left-hand corner
of the matrix is filled with zeros, as much as possible. There are three types of elementary
row operations: 1) Swapping two rows, 2) Multiplying a row by a non-zero number, 3)
Adding a multiple of one row to another row. Using these operations, a matrix can always be
transformed into an upper triangular matrix, and in fact one that is in row echelon form. Once
all of the leading coefficients (the left-most non-zero entry in each row) are 1, and in every
column containing a leading coefficient has zeros elsewhere, the matrix is said to be
in reduced row echelon form.

To illustrate the gauss elimination method we shall consider three simultaneous equations in
three unknowns:
a11x1+a12x2+a13x3=a14 …….…….(i)
a21x1+a22x2+a23x3=a24 …….…….(ii)
a31x1+a32x2+a33x3=a34 …....…….(iii)

The 1st step is to eliminate the 1st term from equation (ii) and (iii).In order to do it equation
(i) is divided by a11 and multiplied by a21 and subtracted from (ii).This eliminates x1 from (ii)
as shown below:

a11x1+a12x2+a13x3=a14 ………….(i)
a11 a12 a13 a14
(a21 - a21)x1+ (a22 - a21)x2+(a23 - a21)x3= (a24 - a21) ………….(iv)
a11 a11 a11 a11

a21
If we call =k2 Equation (iv) may be rewritten as
a11
(a21 -k 2a11)x1+ (a22 -k 2a12) x2+(a23 --k 2a13)x3= (a24 -k 2a14) ….....……….(v)
a31
Multiplying equation (i) by ( )=k3 and subtracing from (iii) we get
a11
(a31 -k 3a11)x1+ (a32 -k 3a12) x2+(a33 --k 3a13)x3= (a34 -k 3a14) …….....…….(vi)

We observe that (a21 -k 2a11) and (a31 -k 3a11) are both zero.

So in summary we can say that the steps of solving problem is –


1.The unknown are eliminated to obtain upper triangular system by simple multiplication
and addition.

2. Now back substitution process is executed until all the unknown are onrained.

Algorithm:

1. First of all the coefficient & Constant matrix were taken by using ‘input” function.
2. Then the size of co efficient matrix and a zero matrix of that size were taken.
3. After that the forward elimination process was done for finding an upper tri-angular matrix.
4. Then the back substitution process was done until the unknown were obtained.
5. Finally getting the root in a tabular form.

Program in the editor:

clear
clc
n = input('Please Enter the size of the equation system n = ') ;%to leanrn about the
number of euations
C = input('Please Enter the elements of the Matrix C ' ) ;
b = input('Please Enter the elements of the Matrix b ' ) ;
dett = det(C)
if dett == 0
print('This system unsolvable because det(C) = 0 ')
else
b = b'
A=[C b]
for j = 1:(n-1)
for i= (j+1) : n
u = A(i,j)/A(j,j) ;
for k= j:n+1
A(i,k) = A(i,k)- u*A(j,k) ;
end
end
end
x(n)=A(n,n+1)/A(n,n); %to obtain the value of Z
for i=n-1:-1:1 %this loop is used obtain the value of X and Y
s=0;
for j=i+1:n
s=s+x(j)*A(i,j);
end
x(i)=(A(i,n+1)-s)/A(i,i);
end
disp('the value of X,Y,Z......in this'); % to display the value of the variables
disp(x(1:n))
end

Output in the command window:

Please Enter the size of the equation system n = 3


Please Enter the elements of the Matrix C [2 1 1; 3 2 3; 1 4 9]
Please Enter the elements of the Matrix b [ 10 18 16]

dett =

-2.0000

b=

10
18
16

A=

2 1 1 10
3 2 3 18
1 4 9 16

the value of X,Y,Z......in this


7 -9 5

Discussion: This method is the simplest method among all the method of linear equation
solving. This method took very small amount of time. If the value of pivot element is zero
the process failed. And pivoting needed . Which is time consuming .It is extraordinarily
simple, but its importance cannot be overemphasized. Before exploring the relevant issues, it
will help to reformulate our method in a more convenient matrix notation.

You might also like