Pages From Linear Fall23 Pp21-40
Pages From Linear Fall23 Pp21-40
21 / 143
Review: eigenvalue problems
by hand.
I Is the matrix A nonsingular?
22 / 143
I Positive Definite: A matrix A is positive definite if
x T Ax > 0 for every nonzero vector x.
2 1
I Example: A = is positive definite, since
1 2
T 2 1 x1
= (x1 +x2 )2 +x12 +x22 > 0
x Ax = x1 x2
1 2 x2
23 / 143
LU and Cholesky Factorizations
24 / 143
I How to solve linear systems?
I Let us begin with the Easy-to-Solve Systems
1. Diagonal Structure
x b1
a11 0 0 ··· 0 1
0 a22 0 · · · x2 b2
0
x3 b3
0 0 a · · · 0 =
33
.. ..
··· . .
0 0 0 · · · ann xn bn
25 / 143
2. Triangular linear systems
x1 b1
a11 0 0 ··· 0 x2 b2
a21 a22 0 ··· 0
x3 =
b3
a31 a32 a33 ··· 0
.. ..
an1 an2 an3 ··· ann
. .
xn bn
I Some simple observations:
If a11 6= 0, then we have x1 = b1 /a11 .
I Once we have x1 , we can simplify the second equation
a21 x1 + a22 x2 = b2
27 / 143
I The complexity of an algorithm is often measured using the
unit called flop
One flop = one addition + one multiplication
I Forward substitution is an O(n2 ) algorithm
I A remark: Forward substitution is a sequential algorithm (not
parallel at all)
28 / 143
3 Another Simple System If we re-order the equations, we can
get a lower triangular system:
a11 a12 0 x1 b1
a21 a22 a23 x2 b2
a31 0 0 x3 b3
29 / 143
LU Factorizations
A = LU
Lz = b solve for z
Ux = z solve for x
30 / 143
I We begin with an n × n matrix A and search for matrices:
31 / 143
I Using the formula for matrix multiplication, we have:
n min(i,j)
X X
aij = lis usj = lis usj (∗)
s=1 s=1
I At each new step k, we know rows 1, 2, ..., k − 1 for U and
columns 1, 2, ..., k − 1 for L. Setting i = j = k in (∗), we have
k−1
X
akk = lks usk + lkk ukk
s=1
32 / 143
I Use (∗) in the previous slide again to get the k-th row (i = k)
and the k-th column (j = k)
k−1
X
akj = lks usj + lkk ukj (k + 1 ≤ j ≤ n)
s=1
|{z}
unknown
k−1
X
aik = lis usk + lik ukk (k + 1 ≤ i ≤ n)
|{z}
s=1 unkown
33 / 143
The algorithm for the general LU-factorization is as follows:
input n, (aij )
for k = 1 to n do
Specify a nonzero value for either
lkk or ukk and compute the other from
lkk ukk = akk − k−1
P
s=1 lks usk
for j = k + 1to n do
Pk−1
ukj ← akj − s=1 lks usj /lkk
end do
for i = k + 1 to n do
Pk−1
lik ← aik − s=1 lis usk /ukk
end do
end do
output (lij ), (uij )
34 / 143
I In-class exercise. Find the Doolittle, Crout, and Cholesky
factorizations of the matrix
60 30 20
A = 30 20 15
20 15 12
35 / 143
Theorem on LU-Decomposition
36 / 143
Cholesky Theorem on LLT -Factorization
37 / 143
Basic steps for solving a linear system
I Consider
Ax = b
I Obtain a LU decomposition
A = LU
Lz = b
Ux = z
38 / 143
Complexity analysis
I Consider the number of multiplications in the general
LU-decomposition:
k = 1, 0
k = 2, 1 + ((n − 1) ∗ 1) ∗ 2
k = 3, 2 + ((n − 2) ∗ 2) ∗ 2
......
k = n, (n − 1) + ((n − (n − 1)) ∗ (n − 1)) ∗ 2
I Total:
n−1
X n−1
X n
X X n
= i +2 (n − i) ∗ i ≈ i +2 (n − i) ∗ i
i=1 i=1 i=1 i=1
n
X Xn n
X n
X n
X
= i + 2n i −2 i 2 = (2n + 1) i −2 i2
i=1 i=1 i=1 i=1 i=1
(2n + 1)n(n + 1) 2n(n + 1)(2n + 1)
= −
2 6
1
= n(n + 1)(2n + 1)
6
39 / 143
I In the LU decomposition phase, the cost is O(n3 )
I In the triangular solve phases, the cost is O(n2 )
I Total cost is O(n3 ) or more precisely
1 3
n + O(n2 )
3
I Remark: Once L and U are obtained, A is no longer needed.
One can over-write A with L and U.
40 / 143