Linear Equation
System Methods
MODULE PIC :
SHAQUILLE SHIDDIQ PRIATA (15321003)
ADELIA PARAMESTI ZAHRA (15320114)
Solving linear equations with the use of
matrices
There are 5 methods of solving linear
equations this way
1. GAUSS ELIMINATION
2. GAUSS JORDAN
3. LU ELIMINATION
4. INVERSE MATRIX
5. GAUSS SEIDEL
Gauss Elimination
LET’S TAKE A LOOK AT AN EXAMPLE
10x+3y+z=19
3x+10y+2z=29
1x+2y+10z=35
We turn this into a set of matrices , and augment these 2 components
To turn it into this :
Coefficient Matrix Source Vector
HOW?
Continue until a triangle of
zeros are made, such that
the LAST row only has one
coefficient left
Think of this matrix like a substitution problem, then solve for all coefficients
Matlab How-To
You can combine two matrices
like this.
Matlab can directly interpret array from
user inputs. Use the above notation in
case the question asks for a user-defined
array.
Let’s do it in Matlab, since we love you all.
If array comes from user
input
If array is manually
created
Is basically this part repeated
until the bottom :
Result Matrix :
You can solve for the coefficients manually, unless...
Last row only has one
coefficient, so we make a
simple division
Source vector solver
CHEAT CODE
Gauss Jordan Elimination
Very similar to normal Gauss
elimination, but the resulting
matrix is like this :
LU Decomposition
Solving LES
A linear equation system is
a system which contain
several linear equation with
several unknown variables.
To solve a linear equation
system we could turn the
mathematical equations
into a matrix multiplication
which consist three matrix.
Coefficient Variables Constant
matrix (a) matrix (x) matrix (b)
Steps
1. Find Matrix L and U by splitting the Notes : You can find Matrix U by
A Matrix changing the A Matrix with Forward
Elimination Process
[A] [L] [U]
Steps
3. The L matrix is composed by taking its multipliers you use while doing the
Forward Elimination Process
Before After
so
Multipliers
4. Enter all the multipliers used in the forward elimination process so that it
becomes the L matrix
with
Steps
5. [D] can be determined by doing matrix multiplication with the [L] and [D] matrix
with [B] as the constant matrix.
[L] [D] [B]
6. Then, do forward substitution to determine [D]
Steps
7. [X] can be determined by forming matrix multiplication with 𝑈 and 𝐷 . Then, do
backward substitution to determine [D]
LU Matrix Factorization : MATLAB Function
This function can divide or factorize variable that contains array of matrix 𝑨 into
upper triangular matrix 𝑼 and lower triangular matrix 𝑳. With this function, step 1
can be passed and can proceed step 2 and 3
[L,U] = lu(A)
Matrix Inverse
Analytical Solution
General Form using The Matrix Example for Matrix 2x2
Inverse
Note:
Note:
Must be square matrix
It’s not effective for matrix with order
Multiplication by its inverse
more than 2x2 because you need to
must result an identity matrix
find its determinant and its adjoint
Steps
1. Find Matrix L and U by deviding the 2. [U] can be determined by operating
coefficient matrix. the forward elimination step to [A]
[A] [L] [U]
Steps
3. The L matrix is composed by taking its multipliers you use while doing the
Forward Elimination Process
Before After
so
Multipliers
4. Enter all the multipliers used in the forward elimination process so that it
becomes the L matrix
with
Steps
5. After divide 𝐴 to 𝐿 and 𝑈 , do forward substitution several times with 𝐵 that
contains constant = 1 and zeros elsewhere, and do backward substitution several
times with result from forward substitution. In The Matrix Inverse, 𝐵 ’s are used to
calculate every column in The Inverse of 𝐴 , 𝐴 −1 . For example, using matrix with
order 3x3 all 𝐵 are shown below
First Column of [A]-1 Second Column of [A]-1 Last Column of [A]-1
Because 𝐴 has order 3x3, so it need to do forward substitution 3 times for
determine every columns in [𝐴]−1
Steps
6. Determine matrix inverse by column-by-column method
First Column of [A]-1
Do this 3 times using
different [B]
The solution :
Matrix Inverse Function in MATLAB
This function can compute the inverse of a variable that contains array of
square matrix 𝑨 into its inverse.
Note: with this function, step 1 and step 2 can be passed and can proceed
step 3
Reference: https://www.mathworks.com/help/matlab/ref/inv.html
The Jacobi Iterative
& Gauss Seidel Iterative
Steps
The Jacobi Iterative Methods
Ensure the main axis (red line) for Matrix
A is dominant! If it’s not dominant, then
do partial pivoting or complete pivoting.
After that, determine initial value for
starting iteration.
Steps
The Jacobi Iterative Methods
Steps
The Gauss Seidel Iterative Methods
After you find its new value,
Gauss Seidel will use it
immediately to find another
value but The Jacobi will use it
in next iteration
QUESTIONS 1-3
QUESTION 1
Create a program that takes user inputs for the coefficient Output :
matrix and the source vector. Use at least 5 unknown The code should clearly show the
variables. augmentation of the coefficient
matrix and source vector
Use Gaussian Elimination to solve for the unknown The code should clearly modify the
variables! matrix
The output should show the values
of each coefficient.
QUESTION 2
The multi-billion dollar piping industry, Perri Inc. , is studying Output :
the energy loss generated by fittings used in its pipes. It takes The code should clearly show the
data from the combinations of accessories in 3 piping systems. augmentation of the coefficient
matrix and source vector
SUM (Number of Fittings * Fitting Type) = Energy Loss (m) The code should clearly modify the
Like so : matrix
10X1 + 3X2 + X3 = 19 The output should clearly answer
3X1 + 10X2 + 2X3 = 29 the two sub-questions
1X1 + 2X2 + 10X3 = 35
Where X1, X2, and X3 represent different types of fittings or
accessories.
Help Perri Inc. determine the energy loss generated from each
of these components! Which accessory is the greatest
contributor to energy loss? Use the Gauss or Gauss Jordan
method.
QUESTION 3
Three reactors are connected by pipes as in the picture below. The rate of mass transfer through the pipe is equal to
the product of the flow rate or Q (m3/sec) and the concentration in the reactor (mg/m3) according to the direction of
flow.
If the system is in steady state conditions, the mass entering the reactor will be the same as leaving the reactor. Make
a mass balance equation for the three reactors, then find the values of C1, C2, and C3 using the Gauss Seidel method!
Output :
Practitioners are able to write
simple mass balance equations and
display them in the program output
Practitioners are able to calculate
the error from each iteration carried
out and display the results of the
concentration and error calculations
in a table
Practitioners are able to displays the
results of the final concentration
calculations (C1, C2, C3) in each
reactor.
bit.ly/46HS10p