cs450 Chapt02
cs450 Chapt02
†
Chapter 2: Systems of Linear Equations
Survey by Michael T. Heath, copyright
c 2018 by the Society for Industrial and
Applied Mathematics. http://www.siam.org/books/cl80
2
Ax =b
2. det(A) 6= 0
3. rank(A) = n
A b # solutions
nonsingular arbitrary 1
singular b ∈ span(A) ∞
singular b∈
/ span(A) 0
7
Geometric Interpretation
Example: Nonsingularity
I 2 × 2 system
2x1 + 3x2 = b1
5x1 + 4x2 = b2
or in matrix-vector notation
2 3 x1 b
Ax = = 1 =b
5 4 x2 b2
Example: Singularity
I 2 × 2 system
2 3 x1 b
Ax = = 1 =b
4 6 x2 b2
is singular regardless of value of b
T
I With b = 4 7 , there is no solution
T T
I With b = 4 8 , x = γ (4 − 2γ)/3 is solution for any real
number γ, so there are infinitely many solutions
10
Vector Norms
n
!1/p
X p
kxkp = |xi |
i=1
h interactive example i
13
Equivalence of Norms
Matrix Norms
kAxk
kAk = maxx6=0
kxk
Condition Number
max |di |
I For any diagonal matrix D = diag(di ), cond(D) =
min |di |
h interactive example i
20
kzk
≤ kA−1 k
ky k
Assessing Accuracy
23
Error Bounds
I Condition number yields error bound for approximate solution to
linear system
I Let x be solution to Ax = b, and let x̂ be solution to Ax̂ = b + ∆b
I If ∆x = x̂ − x, then
k∆xk k∆bk
≤ cond(A)
kxk kbk
h interactive example i
24
kx̂ − xk
≤ cond(A) mach
kxk
h interactive example i
26
Residual
I Since
k∆xk kr k
≤ cond(A)
kx̂k kAk · kx̂k
small relative residual implies small relative error in approximate
solution only if A is well-conditioned
28
Residual, continued
(A + E )x̂ = b
then
kr k kE k
≤
kAk kx̂k kAk
so large relative residual implies large backward error in matrix, and
algorithm used to compute solution is unstable
I Exact solution is x = [1, −1]T , so x̂2 is much more accurate than x̂1 ,
despite having much larger residual
I A is ill-conditioned (cond(A) > 104 ), so small residual does not
imply small error
30
Example: Permutations
I Permutation matrix P has one 1 in each row and column and zeros
elsewhere, i.e., identity matrix with rows or columns permuted
I P T reverses permutation, so P −1 = P T
I Premultiplying both sides of system by permutation matrix,
PAx = Pb, reorders rows, but solution x is unchanged
I Postmultiplying A by permutation matrix, APx = b, reorders
columns, which permutes components of original solution
x = (AP)−1 b = P −1 A−1 b = P T (A−1 b)
33
Triangular Matrices
Forward-Substitution
Back-Substitution
2 4 −2 x1 2
0 1 1 x2 = 4
0 0 4 x3 8
Elimination
where mi = ai /ak , i = k + 1, . . . , n
I Divisor ak , called pivot, must be nonzero
I Matrix Mk , called elementary elimination matrix, adds multiple of
row k to each subsequent row, with multipliers mi chosen so that
result is zero
42
2
I For a = 4,
−2
1 0 0 2 2
M1 a = −2 1 0 4 = 0
1 0 1 −2 0
and
1 0 0 2 2
M2 a = 0 1 0 4 = 4
0 1/2 1 −2 0
44
Example, continued
I Note that
1 0 0 1 0 0
L1 = M1−1 = 2 1 0 , L2 = M2−1 = 0 1 0
−1 0 1 0 −1/2 1
and
1 0 0 1 0 0
M1 M2 = −2 1 0 , L1 L2 = 2 1 0
1 1/2 1 −1 −1/2 1
45
Gaussian Elimination
I To reduce general linear system Ax = b to upper triangular form,
first choose M1 , with a11 as pivot, to annihilate first column of A
below first row
I System becomes M1 Ax = M1 b, but solution is unchanged
I Next choose M2 , using a22 as pivot, to annihilate second column of
M1 A below second row
I System becomes M2 M1 Ax = M2 M1 b, but solution is still unchanged
LU Factorization
L = M −1 = M1−1 · · · Mn−1
−1
= L1 · · · Ln−1
I So we have
A = LU
with L unit lower triangular and U upper triangular
LU Factorization, continued
Example, continued
I To annihilate subdiagonal entry of second column of M1 A,
1 0 0 2 4 −2 2 4 −2
M2 M1 A = 0 1 0 0 1 1 = 0 1 1 = U,
0 −1 1 0 1 5 0 0 4
1 0 0 2 2
M2 M1 b = 0 1 0 4 = 4 = Mb
0 −1 1 12 8
Example, continued
so that
2 4 −2 1 0 0 2 4 −2
A= 4 9 −3 = 2 1 0 0 1 1 = LU
−2 −3 7 −1 1 1 0 0 4
53
Pivoting
54
Row Interchanges
Partial Pivoting
h interactive example i
56
M = Mn−1 Pn−1 · · · M1 P1
PA = L U
Complete Pivoting
I Complete pivoting is more exhaustive strategy in which largest entry
in entire remaining unreduced submatrix is permuted into diagonal
pivot position
Example: Pivoting
I For example,
0 1
A=
1 0
is nonsingular yet has no LU factorization unless rows are
interchanged, whereas
1 1
A=
1 1
is singular yet has LU factorization
59
Example, continued
Pivoting, continued
I Diagonally dominant
n
X
|aij | < |ajj |, j = 1, . . . , n
i=1, i6=j
Residual
63
Residual
Residual, continued
kr k kE k
≤ / n mach
kAk kx̂k kAk
Example, continued
for
for
for
aij = aij − (aik /akk )akj
end
end
end
I Indices i, j, and k of for loops can be taken in any order, for total of
3! = 6 different arrangements
Uniqueness of LU Factorization
Storage Management
Gauss-Jordan Elimination
I In Gauss-Jordan elimination, matrix is reduced to diagonal rather
than triangular form
I Row combinations are used to annihilate entries above as well as
below diagonal
I Elimination matrix used for given column vector a is of form
1 ··· 0 −m1 0 ··· 0 a1 0
.. .. .. .. .. .. .. .. ..
. . . . . . . . .
0
··· 1 −mk−1 0 ··· 0
ak−1 0
0
··· 0 1 0 ··· 0 ak = ak
0
··· 0 −mk+1 1 ··· 0 ak+1
0
. .. .. .. .. .. .. . .
.. . . . . . . .. ..
0 ··· 0 −mn 0 ··· 1 an 0
where mi = ai /ak , i = 1, . . . , n
74
h interactive example i
75
Updating Solutions
76
I If right-hand side of linear system changes but matrix does not, then
LU factorization need not be repeated to solve new system
Sherman-Morrison Formula
x = (A − uv T )−1 b
= A−1 b + A−1 u(1 − v T A−1 u)−1 v T A−1 b
Example, continued
Improving Accuracy
82
Example: Scaling
I Linear system
1 0 x1 1
=
0 x2
has condition number 1/, so is ill-conditioned if is small
Iterative Refinement
x1 = x0 + z0
A = L LT
implies
√
q
l11 = a11 , l21 = a21 /l11 , l22 = 2
a22 − l21
89
Cholesky Factorization
I Thus, Cholesky factorization requires only about half work and half
storage compared with LU factorization of general matrix by
Gaussian elimination, and also avoids need for pivoting
h interactive example i
91
I Factorization of form
PAP T = LDLT
with L unit lower triangular and D either tridiagonal or block
diagonal with 1 × 1 and 2 × 2 diagonal blocks, can be computed
stably using symmetric pivoting strategy
Band Matrices
Tridiagonal Matrices
I Consider tridiagonal matrix
b1 c1 0 ··· 0
.. ..
a
2 b2 c2 . .
A= .. .. ..
0 . . . 0
..
..
. . an−1 bn−1 cn−1
0 ··· 0 an bn
Examples of BLAS
Level-3 BLAS have more opportunity for data reuse, and hence higher
performance, because they perform more operations per data item than
lower-level BLAS
101