Gauss Elimination Method Using Matlab
Gauss Elimination Method Using Matlab
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.
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.
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.
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
dett =
-2.0000
b=
10
18
16
A=
2 1 1 10
3 2 3 18
1 4 9 16
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.