Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

MATHEMATICS -II

ASSIGNMENT 

Solving system of Linear Equations by Gauss


Jordan Elimination Method Using MATLAB

Prepared by:
Misbaah Naz
2020A7PS0232U

Submitted to:
Dr.Priti Bajpayee

Date Submitted:
29/4/21
ACKNOWLEDGMENT 

I would like to express my special thanks to my


faculty Dr.Priti Bajpayee who gave us the
opportunity to do this assignment using the
MATLAB software. This assignment helped me to
learn how to solve a given problem using codes in
MATLAB software and getting results effectively.
CONTENTS
1. Theory
a. MATLAB
b. Guass-Jordan Elimination
c. Solving equations using Gauss-Jordan
Elimination
d. Solutions of linear system of Equations
e. Appliaction in Engineering Field

2. Questions
a. Codes
b. Output

3. Conclusions

4. Bibliography
MATLAB
MATLAB (Matrix laboratory) is a proprietary multi-
paradigm programming language and numeric
computing environment developed by MathWorks and
designed by Cleve Moler. It’s also used for
matrix manipulations, plotting of functions and data,
implementation of algorithms, creation of user interfaces,
and interfacing with programs written in other languages.

Up until now, the MATLAB has more than 4 million users


worldwide. The users come various backgrounds of
engineering, science and Economics.

In this project, I have used several functions of MATLAB to


solve system of equations using Gauss-Jordan
Elimination. For this an inbuilt function rref() is also used.
Gauss Jordan Elimination
Gauss-Jordan Elimination is a set of steps used to solve a
system of linear equations and also to find the inverse of 
an invertible matrix. It uses row operations to convert a
matrix to reduced row echelon form. 

Reduced Row Echelon Form (RREF)


A matrix is in RREF if it follows all the conditions listed
below:
1. If any non-zero rows, they are present at the bottom
of a matrix.
2. The pivot (leading coefficient) of a row should be to
the right of the leading coefficient of the row above it.
The pivot is always 1.
3. All the entries above and below a pivot are zeroes.
For example,
i)

which is in a form of RREF.

  , the matrix isn’t in RREF as the pivot is left to


the above’s row pivot. 
To Solve a System of Linear Equations
with Gauss-Jordan Elimination Method
If a system of linear equations is given by,
a1x + b1y + c1z = s
a2x + b2y + c2z = t
a3x + b3y + c3z = u
The Augmented matrix (A:B) is written as 
        a1      b1      c1           s
        a2       b2      c2           t
        a3       b3      c3           u 

where,
the elements to the left of the dotted line are the
coefficients of x, y and z of system of equations[(A)].
the elements to the right of the dotted line are the
constants of system of equations[(B)].
Augmented matrix is then reduced to RREF resulting as
1 0 0 e
0 1 0 f
0 0 1 g
Giving x = e
y=f
z=g
Solutions of Linear System of Equations
1. If r(A) ≠ r(A:B),
then system has no solutions.

2. If r(A) = r(A:B) = no. of variables


then system has a unique solution.

3. If r(A) = r(A:B) < no. of variables


then system has infinitely many solutions.
Application in Engineering Field
Linear system of equations can applicable to balance
chemical reactions. Thus the linear system can be solved
using Gauss-Jordan Elimination method.
For the given chemical reaction,
CH4 + O2 → CO2 +H2O
the sum of oxygen atoms(3) at the right side isn’t equal to
oxygen atoms(2) at left. Similar situation is found for
Hydrogen atom, 4 hydrogen atoms at left but 2 hydrogen
atoms at right.
Thus to balance the equation, we must find positive
integers, x,y,z and w such that
x(CH4 ) + y(O2 ) → z(CO2 ) + w(H2O)
Left side Right side
Carbon x = z
Hydrogen 4x = 2w
Oxygen 2y = 2z + w
We obtain linear system as,
x – z =0
4x – 2w =0
2y – 2z – w =0
Augmented matrix is written as
1 0 -1 0 0
4 0 0 -2 0

0 2 -2 -1 0
RREF of matrix is as follows
1 0 0 -1/2 0
0 1 0 -1 0
0 0 1 -1/2 0
We can conclude that the general solution are
x = k/2, y = k, z = k/2, w = k
where k is arbitrary. If k=2 then,
x = 1,
y = 2,
z = 1,
w = 2.
Therefore the balanced equation is
CH4 + 2O2 → CO2 + 2H2O
Questions
1. For given system of linear equations, find general
solution using Gauss-Jordan Elimination.
x + 2y + z = 9
2x + 2y – z = 2
3x – y + 2z = 9

Code:
Output:

Therefore,
x=1, y=2, z=4
r(A)=r(A:B)=n(3)
system has unique solution ; unique solution:(1,2,4).
Graph:
2. For given system of linear equations, find general
solution using Gauss-Jordan Elimination.
3x + y + 2z = 6
X + y +z + w =6
2x + y – z = 3

Code:

Output :

r(A) = r (A:B)(3) < n (4)


system has infinite solutions.
z+w=2
y–w=3
x+w=1
let w=k; k is an arbitrary
Then solution = (1-k , k+3 , 2-k , k)
3. For given system of linear equations, find general
solution using Gauss-Jordan Elimination.
x + 2y + 3z + 4w = 5
x + 3y + 5z + 7w = 11
x – z – 2w = -6

Code:

Output :

r(A) (2) ≠ r(A:B)


therefore, the system has no solution.
4. For given system of linear equations, find general
solution using Gauss-Jordan Elimination.
x + 2y – 3z = 6
2x –y + 4z = 1
x–y+z=3

Code:
Output :

r(A) = r(A:B) = n
therefore the system has unique solution.
The general solution : (3.4, -1.4, -1.8)

Graph:
CONCLUSIONS
This assignment helped in connecting theoretical
knowledge to practical applications. Through this
assignment many functions of MATLAB have been
learned and realized it’s ability in solving system of linear
equations.
We can solve the equations manually through row
operations giving the same solution. But MATLAB
provides solutions more accurately and less time
consuming.
BIBLOGRAPHY
 MATLAB Software
 Wikipedia
 Elementary Linear Algebra with Supplemental
Applications, Howard Anton and Chris Rorres,11th
Edition.
 Youtube

You might also like