Lec3 Numerical Model
Lec3 Numerical Model
Lec3 Numerical Model
Reading Assignment:
Chapter 9 & 10 in Textbook
1
LEARNING OUTCOMES
• Numerical Methods to solve Linear Algebraic Equations
(LA E)
1. Direct methods exact solution
2. Iterative methods approximate solution
Chap9/3
2
LINEAR ALGEBRAIC EQUATIONS (LAE)
unknown
variables
4
MATRIX FORM OF L.A.E
A x b
a11 a1n x1 b1
A , x , b
a amn x b
m1 n n
A = coefficient matrix; dimension: m x n
x = vector of unknowns; dimension: n x 1
b = vector of constants; dimension: n x 1
5
MATRIX FORM OF L.A.E
7
Numerical methods to solve LAE
8
GRAPHICAL METHOD
•The SOLUTION is
shown graphically
•They are in the forms of
straight lines because of
the linear equations
3x1 2x2 18
x1 2x2 2
3x1
x2 9 .......(1)
solve for x 2 2
x1
x2 1..........(2) Chap9/10
2
9
BASIC CONCEPTS OF SOLUTION
x1
• Without Solution
x2
3x1 9x2 5 parallel lines
x1 3x2 6
x1
10
(con’t)
11
GAUSS ELIMINATION
12
GAUSS ELIMINATION - ALGORITHM
Augmented
form
Upper
triangular
matrix, U
13
FORWARD ELIMINATION
2 3 1
• Forward Elimination stage reduces the
4 1 5
augmented matrix into an upper triangular
matrix, U.
4 1 5
• It requires Elementary Row
2 3 1
Transformations (3 Basic approaches).
You can:
4 1 5
1. Interchange any two row in position
4 6 2
2. Multiply (or divide) a row by a
nonzero scalar , k (eg. k i R )
4 1 5
3. Multiply (or divide) a row by a
scalar and adding it (or subtracting 0 7 7
it from) another row ( Rj + k Ri)
14
EXAMPLE: Reduction to an upper triangular matrix
4R 4 Elimination factor or
R2 R2 1
1 1 multiplier
‘1’ is called the 1st pivot element
•It means “ To get the new second row R2' , multiply every
element of the first row, R1 by 4 and subtract it from the
element in the second row, R2".
15
(con’t)
17
4
Elimination factor =
1
4
R2 R2 R1
1
4
R3 R3 R1
1
Back substitution
-2 on U-matrix
Elimination factor =
-4
x1 = 1; x2 =3; x3 = 1
2
R"3 R3 R2
4 18
CLASS ACTIVITY
Use Gauss elimination method to solve
2x1 x2 3x3 2
4x1 x2 x3 1
2x1 3x2 2x3 3.
Note: Use fraction number to reduce round-off errors.
Ans: x1 = 0.5; x2 =0; x3 =1
2 2 -1 3 2
Elimination factor = 0 3 -5 -5 Back substitution
3 on U-matrix
2 0 0 25/3 25/3
R"3 R3 R2 x1 = 0.5; x2 =0; x3 =1
3
20
Pitfalls of Gauss Elimination
partial pivoting – by switching the rows so that the largest element is the
pivot element (diagonal term)
21
GAUSS-JORDAN METHOD
22
GAUSS-JORDAN
Elimination +
Normalization
Identity
Matrix
x1 = C1 ; x2 = C2; x3 = C3 23
CLASS ACTIVITY
x1 2 x2 x3 7
2 x1 5 x2 2 x3 6
3x1 2 x2 x3 1
Ans: x1 = 2 ; x2 = 8; x3 = 21 24
SOLUTION
Gauss-Jordan
2
Elimination factor =
1
2
R2 R2 R1
1
3
R3 R3 R1
1 new R1 R1 R3
2
R1 R3 R2 new R3 R3 / 4 Identity matrix:
1
8
Elimination factor =
-1
8
R"3 R3 R2
1 R2 R2 x1 = 2; x2 = 8; x3 =21
25
*MATRIX INVERSION
STEP 1 : Form A I
STEP 2 : Transform A I to I B using the
elementary row transformations.
26
*CLASS ACTIVITY
Find the inverse of the matrix below using the Gauss-Jordan Method
1 2 2
A 1 3 1
2 1 6
17 10 4
1
Answer A 4 2 1
5 1
3 27
MDB3053
Numerical Methods
LU DECOMPOSITION
Chapter 10 in Textbook
28
RECAP on previous lecture
• What is L.A.E ?
• L.A.E in matrix form
• Direct Methods to solve L.A. E
• Gaussian Elimination
• Gauss-Jordan
29
Gaussian Elimination
Gauss-Jordan Method
30
LU DECOMPOSITION
Doolittle Method
*Crout’s Method
31
LU DECOMPOSITION
32
LU DECOMPOSITION
33
(con’t)
STEP 2 : Let Ux = y
given Ax b
Ax LUx Ly b
35
Decomposing A into LU
Example of Chap 9
• Perform the Gauss elimination as Original Matrix:
usual to obtain upper tri. matrix.
1 2 2 3
4 4 2 6
• The elimination factors employed can 4 6 4 10
be assembled into lower tri. matrix
Gauss Elimination:
a21 term: f21 = 4/1= 4
Elimination 1 2 2 3
a31 term: f31 = 4/1 = 4 factors
0 -4 -6 -6
a’32 term: f32 = 2/4 = 0.5
0 0 -1 1
1 0 0 1 2 2
L 4 1 0 U 0 4 6
4 0.5 1 0 0 1
36
Example: Substitution Steps
1 2 2 3
given A 4 4 2 b 6
4 6 4 10
• Let’s say after applying decomposition: A = LU
1 0 0 1 2 2
A L1U 4 1 0 0 4 6
4 0.5 1 0 0 1
1 0 0 y1 3 y1 3
4 1 0 y2 6 y2 6
4 0.5 1 y 10 y 1
3 3
37
(con’t)
38
LU DECOMPOSITION – Doolittle Method
Answers: x1 = 1; x2 = 3; x3 = 5
40
SOLUTION
43
(con’t)
Solution
44
ITERATIVE METHODS
• 2 methods
– Gauss-Seidel
– *Jacobi
• Advantages
– Can be used to solve nonlinear simultaneous
equations x2
x1
45
GAUSS-SEIDEL METHOD
• Gauss-seidel method is an Iterative or approximate method that
continuously update the variables.
•Next step, assume initial guesses x’s are zeros at zero iteration:
at zero iteration.
x1 0
0
b1 a12 x2 a13 x3
x1
a11
b2 a21 x1 a23 x3
x’s are x2
continuously a22
updated
b3 a31 x1 a32 x2
x3
a33
xij xij 1
error estimate: a ,i j
100% s
xi
For all i, where j is the present and j-1 is the previous iterations
GAUSS-SEIDEL METHOD
Continuous updating of the subdiagonal variable
as the computations proceed
( k 1) 1
x1 (b1 a12 x k2 a13 x 3k a1n x kn )
a11
( k 1) 1 ( k 1)
x2 (b2 a21 x1 a23 x 3 a2 n x n )
k k
a22
Variables are updated
continuously
Note: For good convergence, the equations should be arranged so that they
are diagonally dominant, that is the diagonal element must be greater than
the off-diagonal element for each row. (see text book, p293)
SOLUTION
First Iteration:
Rewrite the equations assume x2=x3 = 0
at zero iteration 3 0 0
x1 0.5
6
3 x2 x3
x1 x2
40 6(0.5) 0
4.1111
6 9
40 6 x1 x3 50 3(0.5) 4.11111
x2 x3
12
3.9491
9
50 3x1 x2
x3
12
2nd Iteration:
Error estimate for 3 4.1111 3.9491
each variable: x1 1.8434
6
40 6(1.8434) 3.9491
1.8434 0.5 x2 2.7767
a ,1 100% 72.88% 9
1.8434
50 3(1.8434) 2.7767
2.7767 4.1111 x3 4.3961
a,2 100% 48.05% 12
2.7767
*JACOBI’S METHOD
• Jacobi’s method is almost similar to Gauss-Seidel
method except that the x values are not updated
immediately.
CM/Chap 5/p55
LINEAR ALGEBRAIC EQUATIONS
57