0% found this document useful (0 votes)
224 views2 pages

Gauss Elimination Method

The document describes the Gauss elimination method, a technique for solving systems of linear equations. It works by performing row operations on the augmented matrix of coefficients and constants to put the matrix into upper triangular form. The method has various applications in linear algebra. The code provided implements Gauss elimination to solve the sample system of 3 equations and 3 unknowns, outputting the values of the variables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
224 views2 pages

Gauss Elimination Method

The document describes the Gauss elimination method, a technique for solving systems of linear equations. It works by performing row operations on the augmented matrix of coefficients and constants to put the matrix into upper triangular form. The method has various applications in linear algebra. The code provided implements Gauss elimination to solve the sample system of 3 equations and 3 unknowns, outputting the values of the variables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Gauss Elimination Method

Named after Carl Friedrich Gauss, Gauss Elimination Method is a popular technique of linear
algebra for solving system of linear equations. As the manipulation process of the method is
based on various row operations of augmented matrix, it is also known as row reduction
method. Gauss elimination method has various uses in finding rank of a matrix, calculation
of determinant and inverse of invertible matrix.
This source code is written to solve the following system of linear equation:
2x + y z = 8
-3x y + 2z = -11
-2x + y +2z = -3
Therefore, the value of A and B in the source code are fixed to be [2 1 -1; -3 -1 2; -2 1 2]
and [8 ; -11 ; -3 ]
Instead of creating a separate MATLAB file to define the function and give input, a single file
is designed to perform all the tasks. In order to solve other equation using this source code,
the user has to change the values of augmented matrices A and B defined in the source
code.
The sample output of the MATLAB program is given below:

M-File code
function X = elimination(X,i,j)
% Pivoting (i,j) element of matrix X and eliminating other column
% elements to zero
[ nX mX ] = size( X);
a = X(i,j);
X(i,:) = X(i,:)/a;
for k = 1:nX % loop to find triangular form
if k == i
continue
end
X(k,:) = X(k,:) - X(i,:)*X(k,j); % final result
end

Command Line code


A= [ 1 2; 4 5] % Inputting the value of coefficient matrix
B = [-1; 4] % % Inputting the value of coefficient matrix
i = 1; % loop variable
X = [ A B ];
[ nX mX ] = size( X); % determining the size of matrix
while i <= nX % start of loop
if X(i,i) == 0 % checking if the diagonal elements are zero or not
disp('Diagonal element zero') % displaying the result if there exists zero
return
end
X = elimination(X,i,i); % proceeding forward if diagonal elements are non-zero
i = i +1;
end
C = X(:,mX);

You might also like