0% found this document useful (0 votes)
30 views

Lab 5

This document provides instructions for a lab assignment on solving linear equations using MATLAB. It covers graphical methods, Gauss elimination with and without pivoting, and LU factorization to solve systems of linear algebraic equations directly using MATLAB commands like backslash, matrix inversion, and the lu function. Students are given example problems to solve using each method and challenged to solve a simultaneous equation system using graphical, Gaussian elimination, and LU factorization methods in their code and results.

Uploaded by

Mahamed Hussein
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Lab 5

This document provides instructions for a lab assignment on solving linear equations using MATLAB. It covers graphical methods, Gauss elimination with and without pivoting, and LU factorization to solve systems of linear algebraic equations directly using MATLAB commands like backslash, matrix inversion, and the lu function. Students are given example problems to solve using each method and challenged to solve a simultaneous equation system using graphical, Gaussian elimination, and LU factorization methods in their code and results.

Uploaded by

Mahamed Hussein
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Numerical & Computing

Methods / Chemical Engineering


Laboratory III
LAB #5
Use MATLAB to solve linear equation

Topic covers:
1. Graphical method
2. Gauss Elimination
3. LU Factorization
Sol. of Algebraic Eq.
Graphical method
Q. Solve graphically and check your results by substituting them back into the equations.

3𝑥1 + 2𝑥2 = 18

−𝑥1 + 2𝑥2 = 2

A.
Gauss Elimination
without pivoting
Gauss Elimination
with pivoting
SOLVING LINEAR ALGEBRAIC EQUATIONS
WITH MATLAB
Direct solution to solve systems of linear algebraic
equations.
• to use backslash, or left-division, operator as in
>> x = A\b
• to use matrix inversion:
>> x = inv(A)*b
Try It Yourself!!!
Q1. Compute x1, x2 and x3

150 −100 0 𝑥1 588.6


−100 150 −50 𝑥2 = 686.7
0 −50 50 𝑥3 784.8

Q2. Write the following equation in matrix form and determine the unknowns

50 = 5𝑥3 − 6𝑥2

2𝑥2 + 7𝑥3 + 30 = 0

𝑥1 − 7𝑥3 = 50 − 3𝑥2 + 5𝑥1

Q3. Write the following equation in matrix form and determine the unknowns

3𝑥1 + 2𝑥2 = 18

−𝑥1 + 2𝑥2 = 2
LU Factorization with MATLAB
Given:
𝐴 {𝑥} = 𝑏
We can rearrange: LU factorization step.
1. [A] is factored or decomposed
𝐴 𝑥 − 𝑏 =0
into lower [L] and upper [U]
We know: triangular matrices.
𝐿 𝑈 = 𝐴 and let, 𝑏 = 𝐿 𝑑 2. Substitution step. [L] and [U]
are used to determine a solution
Thus, {x} for a right-hand side {b}.
𝐿 𝑈 𝑥 − 𝐿 𝑑 =0 MATLAB uses lu built-in
function to get LU of [A].
𝑥 = 𝑖𝑛𝑣 𝑈 𝑑
Where, >> [L,U] = lu(A)
𝑑 = 𝑈 𝑥
Q. Determine the unknowns by using LU Factorization method
0 −6 5 𝑥1 50
0 2 7 𝑥2 = −30
−4 3 −7 𝑥3 50
Challenge

Determine the solution of the simultaneous equations by using


the following method:

−3𝑥1 + 12𝑥2 = 9
10𝑥1 − 2𝑥2 = 8

1. Graphical Method
2. Gaussian Elimination Method
3. LU Factorization Method

NOTE: Answer should includes m-file code and result.


End of LAB#5

You might also like