Lab 5
Lab 5
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
Q2. Write the following equation in matrix form and determine the unknowns
50 = 5𝑥3 − 6𝑥2
2𝑥2 + 7𝑥3 + 30 = 0
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
−3𝑥1 + 12𝑥2 = 9
10𝑥1 − 2𝑥2 = 8
1. Graphical Method
2. Gaussian Elimination Method
3. LU Factorization Method