03 DenseLinearSystemsA
03 DenseLinearSystemsA
Numerical Algorithms
Samir Moustafa
1 1 0.66̄ 1
1
Step function H(a) := 1a>0.5
Motivation LU Factorization Pivoting Arithmetic Error LU and Pivoting Relative Error
Revision
Ax = b
A = LU
Ax = b can be written as LU x = b
Can be solved by solving Ly = b
Forward substitution
U x = y can be solved by
Back substitution
y = intermediate solution: Ly = b
Gaussian elimination and LU factorization express the same
solution process
LU formation makes it clearer that the factorization phase need
not be repeated when solving additional systems having
different right-hand-side vectors but the same matrix A
L and U factors can be reused!
LU Factorization Algorithm:
1: for k = 1 to n − 1 do
2: if akk = 0 then
3: STOP
4: end if
5: for i = k + 1 to n do
6: mik = aik /akk
7: end for
8: for j = k + 1 to n do
9: for i = k + 1 to n do
10: aij = aij − mik akj
11: end for
12: end for
13: end for
Obvious problem:
If leading diagonal entry of the remaining unreduced portion of
the matrix is zero at any stage
Computing multiplier mi requires division by the diagonal entry
Solution:
If entry is 0 at stage k → interchange row k with some
subsequent row whose entry in column k is nonzero
Interchanges in both, matrix and right hand side
Does not alter the solution
0 1 2 1 0 1 0
With row interchanges P = ,M= ,L=
1 0 −ϵ 1 ϵ 1
1 1 1 1
and U = = in floating-point arithmetic.
0 1−ϵ 0 1
1 0 1 1 1 1
Therefore, LU = = which is the correct
ϵ 1 0 1 ϵ 1
result in floating-point arithmetic (after row interchange!).
2
The inverse of P matrix is it’s transpose: P−1 = P T .
Motivation LU Factorization Pivoting Arithmetic Error LU and Pivoting Relative Error
Pivoting
1 2 2 x1 3
Ax = 4 4 2 x2 = 6 = b
4 6 4 x3 10
0 1 0
P1 = 1 0 0
0 0 1
4 4 2 x1 6
P1 Ax = 1 2 2 x2 = 3 = P1 b
4 6 4 x3 10
1 0 0
M1 = −0, 25 1 0
−1 0 1
4 4 2 x1 6
M1 P1 Ax = 0 1 1, 5 x2 = 1, 5 = M1 P1 b
0 2 2 x3 4
1 0 0
P2 = 0 0 1
0 1 0
4 4 2 x1 6
P2 M1 P1 Ax = 0 2 2 x2 = 4 = P2 M1 P1 b
0 1 1, 5 x3 1, 5
3
The inverse of M matrix is the the negative sign for the element that
we changed.
Motivation LU Factorization Pivoting Arithmetic Error LU and Pivoting Relative Error
Example
1 22 0, 25 0, 5 1 4 4 2
A = 4 42 = 1 0 0 0 2 2 = LU
4 64 1 1 0 0 0 0, 5
1 0 0 0 1 0 0 1 0
P = P2 P1 = 0 0 1 1 0 0 = 0 0 1
0 1 0 0 0 1 1 0 0
1 0 0
L= 1 1 0
0, 25 0, 5 1
0 1 0 1 2 2 1 0 0 4 4 2
P A = 0 0 1 4 4 2 = 1 1 0 0 2 2 = LU
1 0 0 4 6 4 0, 25 0, 5 1 0 0 0, 5