Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
A Collection of Notes
on Numerical Linear Algebra
10 9 8 7 6 5 4 3 2 1
All rights reserved. No part of this book may be reproduced, stored, or transmitted in
any manner without the written permission of the publisher. For information, contact
any of the authors.
No warranties, express or implied, are made by the publisher, authors, and their em-
ployers that the programs contained in this volume are free of error. They should not
be relied on as the sole basis to solve a problem whose incorrect solution could result
in injury to person or property. If the programs are employed in such a manner, it
is at the user’s own risk and the publisher, authors, and their employers disclaim all
liability for such misuse.
Trademarked names may be used in this book without the inclusion of a trademark
symbol. These names are used in an editorial context only; no infringement of trade-
mark is intended.
Preface ix
i
2.1. Absolute Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2. Vector Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2.1. Vector 2-norm (length) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2.2. Vector 1-norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.2.3. Vector ∞-norm (infinity norm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.2.4. Vector p-norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3. Matrix Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3.1. Frobenius norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3.2. Induced matrix norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.3.3. Special cases used in practice . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.3.4. Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.3.5. Submultiplicative norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.4. An Application to Conditioning of Linear Systems . . . . . . . . . . . . . . . . . . . . . 32
2.5. Equivalence of Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
19. Notes on Descent Methods and the Conjugate Gradient Method 313
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
19.1. Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
19.2. Descent Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
19.3. Relation to Splitting Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
19.4. Method of Steepest Descent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
19.5. Preconditioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
19.6. Methods of A-conjugate Directions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
19.7. Conjugate Gradient Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
Bibliography 397
Index 401
Preface
This document was created over the course of many years, as I periodically taught an introductory course
titled “Numerical Analysis: Linear Algebra,” cross-listed in the departments of Computer Science, Math,
and Statistics and Data Sciences (SDS), as well as the Computational Science Engineering Mathematics
(CSEM) graduate program.
Over the years, my colleagues and I have used many different books for this course: Matrix Computations
by Golub and Van Loan [21], Fundamentals of Matrix Computation by Watkins [45], Numerical Linear
Algebra by Trefethen and Bau [36], and Applied Numerical Linear Algebra by Demmel [11]. All are books
with tremendous strenghts and depth. Nonetheless, I found myself writing materials for my students that
add insights that are often drawn from our own research experiences in the field. These became a series of
notes that are meant to supplement rather than replace any of the mentioned books.
Fundamental to our exposition is the FLAME notation [24, 38], which we use to present algorithms hand-
in-hand with theory. For example, in Figure 1 (left), we present a commonly encountered LU factorization
algorithm, which we will see performs exactly the same computations as does Gaussian elimination. By
abstracting away from the detailed indexing that are required to implement an algorithm in, for example,
Matlab’s M-script language, the reader can focus on the mathematics that justifies the algorithm rather
than the indices used to express the algorithm. The algorithms can be easily translated into code with
the help of a FLAME Application Programming Interface (API). Such interfaces have been created for
C, M-script, and Python, to name a few [24, 5, 29]. In Figure 1 (right), we show the LU factorization
algorithm implemented with the FLAME@lab API for M-script. The C API is used extensively in our
implementation of the libflame dense linear algebra library [39, 40] for sequential and shared-memory
architectures and the notation also inspired the API used to implement the Elemental dense linear algebra
library [30] that targets distributed memory architectures. Thus, the reader is exposed to the abstractions
that experts use to translate algorithms to high-performance software.
These notes may at times appear to be a vanity project, since I often point the reader to our research papers
for a glipse at the cutting edge of the field. The fact is that over the last two decades, we have helped
further the understanding of many of the topics discussed in a typical introductory course on numerical
linear algebra. Since we use the FLAME notation in many of our papers, they should be relatively easy to
read once one familiarizes oneself with these notes. Let’s be blunt: these notes do not do the field justice
when it comes to also giving a historic perspective. For that, we recommend any of the above mentioned
texts, or the wonderful books by G.W. Stewart [34, 35]. This is yet another reason why they should be
used to supplement other texts.
ix
Algorithm: A := L\U = LU(A) function [ A_out ] = LU_unb_var4( A )
[ ATL, ATR, ...
AT L AT R ABL, ABR ] = FLA_Part_2x2( A, ...
Partition A →
ABL ABR 0, 0, ’FLA_TL’ );
where AT L is 0 × 0 while ( size( ATL, 1 ) < size( A, 1 ) )
[ A00, a01, A02, ...
while n(AT L ) < n(A) do
a10t, alpha11, a12t, ...
Repartition A20, a21, A22 ] = ...
FLA_Repart_2x2_to_3x3( ...
A00 a01 A02 ATL, ATR, ...
AT L AT R ABL, ABR, 1, 1, ’FLA_BR’ );
→ aT α11 aT12
10 %------------------------------------------%
ABL ABR
A20 a21 A22 a21 = a21 / alpha11;
A22 = A22 - a21 * a12t;
a21 := a21 /α11 %------------------------------------------%
[ ATL, ATR, ...
A22 := A22 − a21 aT12
ABL, ABR ] = ...
FLA_Cont_with_3x3_to_2x2( ...
Continue with A00, a01, A02, ...
a10t, alpha11, a12t, ...
A00 a01 A02
AT L AT R A20, a21, A22, ’FLA_TL’ );
← aT α11 aT12 end
10
ABL ABR
A_out = [ ATL, ATR
A20 a21 A22
ABL, ABR ];
endwhile return
Figure 1: LU factorization represented with the FLAME notation and the FLAME@lab API.
The order of the chapters should not be taken too seriously. They were initially written as separate,
relatively self-contained notes. The sequence on which I settled roughly follows the order that the topics
are encountered in Numerical Linear Algebra by Trefethen and Bau [36]. The reason is the same as the
one they give: It introduces orthogonality and the Singular Value Decomposition early on, leading with
important material that many students will not yet have seen in the undergraduate linear algebra classes
they took. However, one could just as easily rearrange the chapters so that one starts with a more traditional
topic: solving dense linear systems.
The notes frequently refer the reader to another resource of ours titled Linear Algebra: Foundations to
Frontiers - Notes to LAFF With (LAFF Notes) [29]. This is a 900+ page document with more than 270
videos that was created for the Massive Open Online Course (MOOC) Linear Algebra: Foundations
to Frontiers (LAFF), offered by the edX platform. That course provides an appropriate undergraduate
background for these notes.
I (tried to) video tape my lectures during Fall 2014. Unlike the many short videos that we created for the
Massive Open Online Course (MOOC) titled “Linear Algebra: Foundations to Frontiers” that are now part
of the notes for that course, I simply set up a camera, taped the entire lecture, spent minimal time editing,
and uploaded the result for the world to see. Worse, I did not prepare particularly well for the lectures,
other than feverishly writing these notes in the days prior to the presentation. Sometimes, I forgot to turn
on the microphone and/or the camera. Sometimes the memory of the camcorder was full. Sometimes I
forgot to shave. Often I forgot to comb my hair. You are welcome to watch, but don’t expect too much!
One should consider this a living document. As time goes on, I will be adding more material. Ideally,
people with more expertise than I have on, for example, solving sparse linear systems will contributed
notes of their own.
Acknowledgments
These notes use notation and tools developed by the FLAME project at The University of Texas at Austin
(USA), Universidad Jaume I (Spain), and RWTH Aachen University (Germany). This project involves
a large and ever expanding number of very talented people, to whom I am indepted. Over the years, it
has been supported by a number of grants from the National Science Foundation and industry. The most
recent and most relevant funding came from NSF Award ACI-1148125 titled “SI2-SSI: A Linear Algebra
Software Infrastructure for Sustained Innovation in Computational Chemistry and other Sciences”1
In Texas, behind every successful man there is a woman who really pulls the strings. For more than thirty
years, my research, teaching, and other pedagogical activities have been greatly influenced by my wife,
Dr. Maggie Myers. For parts of these notes that are particularly successful, the credit goes to her. Where
they fall short, the blame is all mine!
1 Any opinions, findings and conclusions or recommendations expressed in this mate- rial are those of the author(s) and do
not necessarily reflect the views of the National Science Foundation (NSF).
xiii
Chapter 1
Notes on Simple Vector and Matrix Operations
We assume that the reader is quite familiar with vectors, linear transformations, and matrices. If not, we
suggest the reader reviews the first five weeks of
Since undergraduate courses tend to focus on real valued matrices and vectors, we mostly focus on the
case where they are complex valued as we review.
Video
Read disclaimer regarding the videos in the preface!
The below first video is actually for the first lecture of the semester.
* YouTube
* Download from UT Box
* View After Local Download
1
Chapter 1. Notes on Simple Vector and Matrix Operations 2
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1. Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2. (Hermitian) Transposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.1. Conjugating a complex scalar . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.2. Conjugate of a vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.3. Conjugate of a matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.4. Transpose of a vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.5. Hermitian transpose of a vector . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.6. Transpose of a matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.7. Hermitian transpose (adjoint) of a matrix . . . . . . . . . . . . . . . . . . . . . 5
1.2.8. Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3. Vector-vector Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3.1. Scaling a vector (scal) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3.2. Scaled vector addition (axpy) . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3.3. Dot (inner) product (dot) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4. Matrix-vector Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.4.1. Matrix-vector multiplication (product) . . . . . . . . . . . . . . . . . . . . . . 11
1.4.2. Rank-1 update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5. Matrix-matrix multiplication (product) . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.5.1. Element-by-element computation . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.5.2. Via matrix-vector multiplications . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.5.3. Via row-vector times matrix multiplications . . . . . . . . . . . . . . . . . . . 18
1.5.4. Via rank-1 updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.5.5. Cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.6. Summarizing All . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.1. Notation 3
1.1 Notation
Throughout our notes we will adopt notation popularized by Alston Householder. As a rule, we will use
lower case Greek letters (α, β, etc.) to denote scalars. For vectors, we will use lower case Roman letters
(a, b, etc.). Matrices are denoted by upper case Roman letters (A, B, etc.).
If x ∈ Cn , and A ∈ Cm×n then we expose the elements of x and A as
χ0 α0,0 α0,1 · · · α0,n−1
χ
1
α
1,0 α 1,1 · · · α1,n−1
x = . and A = .
.. .. .. ..
. . · · · .
χn−1 αm−1,0 αm−1,1 · · · αm−1,n−1
It is possible for a subvector to be of size zero (no elements) or one (a scalar). If we want to emphasize
that a specific subvector is a scalar, then we may choose to use a lower case Greek letter for that scalar, as
in
x0
x= χ1 .
x2
We will see frequent examples where a matrix, A ∈ Cm×n , is partitioned into columns or rows:
abT0
abT
1
A = a0 a1 · · · an−1 = . .
..
abTm−1
Here we add the b to be able to distinguish between the identifiers for the columns and rows. When from
context it is obvious whether we refer to a row or column, we may choose to skip the b. Sometimes, we
partition matrices into submatrices:
Ab0 A0,0 A0,1 · · · A0,N−1
A b1 A1,0 A1,1 · · · A1,N−1
A = A0 A1 · · · AN−1 = . = .
.. .
.. .
.. .
..
AM−1
b AM−1,0 AM−1,1 · · · AM−1,N−1
Chapter 1. Notes on Simple Vector and Matrix Operations 4
α = αr − iαc
Notice that transposing a (column) vector rearranges its elements to make a row vector.
1.2. (Hermitian) Transposition 5
1.2.8 Exercises
Homework 1.1 Partition A
abT0
abT
1
A= a0 a1 · · · an−1 = . .
..
abTm−1
Convince yourself that the following hold:
aT
0
T aT
1
• a0 a1 · · · an−1 = . .
..
aTm−1
Chapter 1. Notes on Simple Vector and Matrix Operations 6
T
abT0
abT
1
• . = ab0 ab1 · · · abn−1 .
..
abTm−1
aH
0
H aH
1
• a0 a1 · · · an−1 = . .
..
aH
m−1
H
abT0
abT
1
• . = ab0 ab1 · · · abn−1 .
..
abTm−1
* SEE ANSWER
• xH = x0H x1H ··· H
xN−1 .
* SEE ANSWER
1.3. Vector-vector Operations 7
* SEE ANSWER
If y := αx with
ψ0
ψ
1
y= . ,
..
ψn−1
then the following loop computes y:
for i := 0, . . . , n − 1
ψi := αχi
endfor
• (αx)T = αxT .
• (αx)H = αxH .
x0 αx0
x1 αx1
• α . =
.. ..
.
xN−1 αxN−1
* SEE ANSWER
Cost
Scaling a vector of size n requires, approximately, n multiplications. Each of these becomes a floating
point operation (flop) when the computation is performed as part of an algorithm executed on a computer
that performs floating point computation. We will thus say that scaling a vector costs n flops.
It should be noted that arithmetic with complex numbers is roughly 4 times as expensive as is arithmetic
with real numbers. In the chapter “Notes on Performance” (page ??) we also discuss that the cost of
moving data impacts the cost of a flop. Thus, not all flops are created equal!
This operation is known as the axpy operation: scalar α times x plus y. Typically, the vector y is overwritten
with the result:
χ0 ψ0 αχ0 αψ0
χ ψ αχ αψ
1 1 1 1
y := αx + y = α . + . = +
.. .. .. ..
.
.
χn−1 ψn−1 αχn−1 αψn−1
for i := 0, . . . , n − 1
ψi := αχi + ψ
endfor
* SEE ANSWER
Cost
The axpy with two vectors of size n requires, approximately, n multiplies and n additions or 2n flops.
α := 0
for i := 0, . . . , n − 1
α := χi ψ + α
endfor
* SEE ANSWER
As we discuss matrix-vector multiplication and matrix-matrix multiplication, the closely related oper-
ation xT y is also useful:
T
χ0 ψ0 ψ0
χ ψ ψ1
T 1 1
x y = . = χ0 χ1 · · · χn−1 .
.
.. .. ..
χn−1 ψn−1 ψn−1
n−1
= χ0 ψ0 + χ1 ψ1 + · · · + χn−1 ψn−1 = ∑ χi ψi .
i=0
We will sometimes refer to this operation as a “dot” product since it is like the dot product xH y, but without
conjugation. In the case of real valued vectors, it is the dot product.
1.4. Matrix-vector Operations 11
Cost
The dot product of two vectors of size n requires, approximately, n multiplies and n additions. Thus, a dot
product cost, approximately, 2n flops.
This is the definition of the matrix-vector product Ax, sometimes referred to as a general matrix-vector
multiplication (gemv) when no special structure or properties of A are assumed.
Now, partition
abT0
abT
1
A = a0 a1 · · · an−1 = . .
..
T
abm−1
Chapter 1. Notes on Simple Vector and Matrix Operations 12
y := 0
for j := 0, . . . , n − 1
y := χ j a j + y (axpy)
endfor
In Figure 1.1 (left), we present this algorithm using the FLAME notation (LAFF Notes Week 3 [29]).
Focusing on how A can be partitioned by rows, we find that
ψ0 abT0 abT0 x
ψ abT abT x
1 1 1
y = . = Ax = . x = .
.. .. .
..
ψn−1 T
abm−1 T
abm−1 x
This suggests the following loop for computing y := Ax:
for i := 0, . . . , m − 1
ψi := abTi x + ψi (‘‘dot’’)
endfor
Here we use the term “dot” because for complex valued matrices it is not really a dot product. In Figure 1.1
(right), we present this algorithm using the FLAME notation (LAFF Notes Week 3 [29]).
It is important to notice that this first “matrix-vector” operation (matrix-vector multiplication) can be
“layered” upon vector-vector operations (axpy or ‘‘dot’’).
Cost
Matrix-vector multiplication with a m × n matrix costs, approximately, 2mn flops. This can be easily
argued in three different ways:
• The computation requires a multiply and an add with each element of the matrix. There are mn such
elements.
• The operation can be computed via n axpy operations, each of which requires 2m flops.
• The operation can be computed via m dot operations, each of which requires 2n flops.
1.4. Matrix-vector Operations 13
Algorithm: [y] := M VMULT UNB VAR 1(A, x, y) Algorithm: [y] := M VMULT UNB VAR 2(A, x, y)
xT AT yT
Partition A → AL AR , x → Partition A → , y →
xB AB yB
where AL is 0 columns, xT has 0 elements where AT has 0 rows, yT has 0 elements
while n(AL ) < n(A) do while m(AT ) < m(A) do
Repartition Repartition
x A y
0 0
xT 0 AT yT
AL AR → A0 a1 A2 , → χ1
→ aT , → ψ1
1
xB AB yB
x2 A2 y2
y := χ1 a1 + y ψ1 := aT1 x + ψ1
Figure 1.1: Matrix-vector multiplication algorithms for y := Ax + y. Left: via axpy operations (by
columns). Right: via “dot products” (by rows).
ψ0 χ0 ψ0 χ1 ··· ψ0 χn−1
ψ χ
1 0 ψ1 χ1 · · · ψ1 χn−1
= .
.
.. .. ..
. .
ψm−1 χ0 ψm−1 χ1 · · · ψm−1 χn−1
Also,
T
yx = y χ0 χ1 · · · χn−1 = χ0 y χ1 y · · · χn−1 y .
This shows that all columns are a multiple of vector y. Finally,
ψ0 ψ0 xT
ψ ψ xT
1 1
yxT = . xT = ,
.. ..
.
ψm−1 ψm−1 xT
which shows that all columns are a multiple of row vector xT . This motivates the observation that the
matrix yxT has rank at most equal to one (LAFF Notes Week 10 [29]).
The operation A := yxT + A is called a rank-1 update to matrix A and is often referred to as underline-
general rank-1 update (ger):
α0,0 α0,1 · · · α0,n−1
α
1,0 α1,1 · · · α1,n−1
:=
.
.. .
.. .
..
αm−1,0 αm−1,1 · · · αm−1,n−1
ψ0 χ0 + α0,0 ψ0 χ1 + α0,1 ··· ψ0 χn−1 + α0,n−1
ψ1 χ0 + α 1,0 ψ 1 χ1 + α1,1 · · · ψ 1 χ n−1 + α1,n−1
.
.. .. ..
. . .
ψm−1 χ0 + αm−1,0 ψm−1 χ1 + αm−1,1 · · · ψm−1 χn−1 + αm−1,n−1
Now, partition
abT0
abT
1
A= a0 a1 · · · an−1 = . .
..
abTm−1
Focusing on how A can be partitioned by columns, we find that
T
yx + A = χ0 y χ1 y · · · χn−1 y + a0 a1 · · · an−1
= χ0 y + a0 χ1 y + a1 · · · χn−1 y + an−1 .
1.4. Matrix-vector Operations 15
Algorithm: [A] := R ANK 1 UNB VAR 1(y, x, A) Algorithm: [A] := R ANK 1 UNB VAR 2(y, x, A)
xT yT AT
Partition x → , A → AL AR Partition y → , A →
xB yB AB
where xT has 0 elements, AL has 0 columns where yT has 0 elements, AT has 0 rows
while m(xT ) < m(x) do while m(yT ) < m(y) do
Repartition Repartition
x y A
0 0
xT 0 yT AT
→ χ1
, AL AR → A0 a1 A2 → ψ1 , → aT
1
xB yB AB
x2 y2 A2
Figure 1.2: Rank-1 update algorithms for computing A := yxT + A. Left: by columns. Right: by rows.
Notice that each column is updated with an axpy operation. This suggests the following loop for comput-
ing A := yxT + A:
for j := 0, . . . , n − 1
a j := χ j y + a j (axpy)
endfor
In Figure 1.2 (left), we present this algorithm using the FLAME notation (LAFF Notes Week 3).
Focusing on how A can be partitioned by rows, we find that
ψ0 xT abT0
ψ1 xT abT
1
yxT + A = + .
.. ..
.
ψm−1 xT abTm−1
Chapter 1. Notes on Simple Vector and Matrix Operations 16
ψ0 xT + abT0
ψ1 xT + abT1
= .
..
.
ψm−1 xT + abTm−1
Notice that each row is updated with an axpy operation. This suggests the following loop for computing
A := yxT + A:
for i := 0, . . . , m − 1
abTj := ψi xT + abTj (axpy)
endfor
In Figure 1.2 (right), we present this algorithm using the FLAME notation (LAFF Notes Week 3).
Again, it is important to notice that this “matrix-vector” operation (rank-1 update) can be “layered”
upon the axpy vector-vector operation.
Cost
A rank-1 update of a m × n matrix costs, approximately, 2mn flops. This can be easily argued in three
different ways:
• The computation requires a multiply and an add with each element of the matrix. There are mn such
elements.
• The operation can be computed one column at a time via n axpy operations, each of which requires
2m flops.
• The operation can be computed one row at a time via m axpy operations, each of which requires 2n
flops.
Be sure to understand the relation between linear transformations and matrix-matrix multiplication (LAFF
Notes Weeks 3 and 4 [29]).
We will now discuss the computation of C := AB + C, where C ∈ Cm×n , A ∈ Cm×k , and B ∈ Ck×n .
(If one wishes to compute C := AB, one can always start by setting C := 0, the zero matrix.) This is the
definition of the matrix-matrix product AB, sometimes referred to as a general matrix-matrix multiplication
(gemm) when no special structure or properties of A and B are assumed.
1.5. Matrix-matrix multiplication (product) 17
C := AB +C
∑k−1
p=0 α0,p β p,0 + γ0,0 ∑k−1
p=0 α0,p β p,1 + γ0,1 ··· ∑k−1
p=0 α0,p β p,n−1 + γ0,n−1
∑k−1
p=0 α1,p β p,0 + γ1,0 ∑k−1
p=0 α1,p β p,1 + γ1,1 ··· ∑k−1
p=0 α1,p β p,n−1 + γ1,n−1
= .
.. .. ..
. . ··· .
k−1 k−1
∑ p=0 αm−1,p β p,0 + γm−1,0 ∑ p=0 αm−1,p β p,1 + γm−1,1 · · · ∑k−1
p=0 αm−1,p β p,n−1 + γm−1,n−1
Then
abT0
abT
1
C := AB +C = . b0 b1 · · · bn−1
..
T
abm−1
abT0 b0 + γ0,0 abT0 b1 + γ0,1 ··· abT0 bn−1 + γ0,n−1
abT b + γ abT1 b1 + γ1,1 ··· abT1 bn−1 + γ1,n−1
1 0 1,0
= .
.. .. ..
. . ··· .
abTm−1 b0 + γm−1,0 abTm−1 b1 + γm−1,1 · · · abTm−1 bn−1 + γm−1,n−1
Chapter 1. Notes on Simple Vector and Matrix Operations 18
for j := 0, . . . , n − 1
c j := Ab j + c j (matrix-vector multiplication)
endfor
for i := 0, . . . , m − 1
cbTi := abTi B + cbTi (row-vector times matrix-vector multiplication)
endfor
The
bT0
b
bT1
b
C := AB +C = a0 a1 · · · ak−1 +C
..
.
bT
b
k−1
bT0 + a1b
= a0 b bT1 + · · · + ak−1bbTk−1 +C
= ak−1b bTk−1 + (· · · (a1b
bT1 + (a0bbT0 +C)) · · ·)
which shows that C can be updated with a sequence of rank-1 update, suggesting the loop
for p := 0, . . . , k − 1
C := a pbbTp +C (rank-1 update)
endfor
1.5.5 Cost
A matrix-matrix multiplication C := AB, where C is m × n, A is m × k, and B is k × n, costs approximately
2mnk flops. This can be easily argued in four different ways:
• The computation requires a dot product for each element in C, at a cost of 2k flops per dot product.
There are mn such elements.
• The operation can be computed one column at a time via n gemv operations, each of which requires
2mk flops.
• The operation can be computed one row at a time via m gemv operations (row-vector times matrix),
each of which requires 2nk flops.
m n k Illustration Label
:= +
large large large gemm
:= +
large large 1 ger
:= +
large 1 large gemv
:= +
1 large large gemv
:= +
1 large 1 axpy
:= +
large 1 1 axpy
:= +
1 1 large dot
:= +
1 1 1 MAC
Figure 1.3: Special shapes of gemm C := AB +C. Here C, A, and B are m × n, m × k, and k × n matrices,
respectively.
Observations made about operations with partitioned matrices and vectors can be summarized by par-
titioning matrices into blocks: Let
C0,0 C0,1 ··· C0,N−1 A0,0 A0,1 ··· A0,K−1
C
1,0 C1,1 · · · C1,N−1 A1,0 A1,1 ··· A1,K−1
C= ,A =
.
.. .. .. .. .. ..
. ··· .
. . ··· .
CM−1,0 CM−1,1 · · · CM−1,N−1 AM−1,0 AM−1,1 · · · AM−1,K−1
1.6. Summarizing All 21
B0,1 B0,1 ··· B0,N−1
B
1,0 B1,1 · · · B1,N−1
B= .
.
.. .. ..
. ··· .
BK−1,0 BK−1,1 · · · BK−1,N−1
Then
C := AB +C =
∑K−1
p=0 A0,p B p,0 +C0,0 ∑K−1
p=0 A0,p B p,1 +C0,1 ··· ∑K−1
p=0 A0,p B p,N−1 +C0,N−1
∑K−1
p=0 A1,p B p,0 +C1,0 ∑K−1
p=0 A1,p B p,1 +C1,1 ··· ∑K−1
p=0 A1,p B p,N−1 +C1,N−1
.
.
.. .. ..
. ··· .
∑K−1 k−1
p=0 AM−1,p B p,0 +CM−1,0 ∑ p=0 AM−1,p B p,1 +CM−1,1 · · · ∑k−1
p=0 AM−1,p B p,N−1 +CM−1,N−1
(Provided the partitionings of C, A, and B are “conformal.) Notice that multiplication with partitioned ma-
trices is exactly like regular matrix-matrix multiplication with scalar elements, except that multiplication
of two blocks does not necessarily commute.
Chapter 1. Notes on Simple Vector and Matrix Operations 22
Chapter 2
Notes on Vector and Matrix Norms
Video
Read disclaimer regarding the videos in the preface!
* YouTube
* Download from UT Box
* View After Local Download
23
Chapter 2. Notes on Vector and Matrix Norms 24
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.1. Absolute Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2. Vector Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2.1. Vector 2-norm (length) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2.2. Vector 1-norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.2.3. Vector ∞-norm (infinity norm) . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.2.4. Vector p-norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3. Matrix Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3.1. Frobenius norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3.2. Induced matrix norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.3.3. Special cases used in practice . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.3.4. Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.3.5. Submultiplicative norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.4. An Application to Conditioning of Linear Systems . . . . . . . . . . . . . . . . . . . 32
2.5. Equivalence of Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.1. Absolute Value 25
Homework 2.2 Prove that if ν : Cn → R is a norm, then ν(0) = 0 (where the first 0 denotes the zero vector
in Cn ).
* SEE ANSWER
To show that the vector 2-norm is a norm, we will need the following theorem:
Proof: Assume that x 6= 0 and y 6= 0, since otherwise the inequality is trivially true. We can then choose
xH yb| ≤ 1, with kb
xb = x/kxk2 and yb = y/kyk2 . This leaves us to prove that |b xk2 = kb
yk2 = 1.
Pick α ∈ C with |α| = 1 s that αbH xH yb = αb
x yb is real and nonnegative. Note that since it is real, αb xH yb =
αb H
y xb.
Chapter 2. Notes on Vector and Matrix Norms 26
Now,
0 ≤ kb yk22
x − αb
y)H (b
= (x − αb x − αb
y) (kzk22 = zH z)
= xbH xb− αb xH yb+ ααb
yH xb− αb yH yb (multiplying out)
xH yb+ |α|2
= 1 − 2αb xk2 = kb
(kb xH yb = αb
yk2 = 1 and αb yH xb)
xH yb = αb
xH yb
= 2 − 2αb (|α| = 1).
kx + yk22 = (x + y)H (x + y)
= xH x + yH x + xH y + yH y
≤ kxk22 + 2kxk2 kyk2 + kyk22
= (kxk2 + kyk2 )2 .
Taking the square root of both sides yields the desired result.
QED
2.3. Matrix Norms 27
The vector 1-norm is sometimes referred to as the “taxi-cab norm”. It is the distance that a taxi travels
along the streets of a city that has square blocks.
Proving that the p-norm is a norm is a little tricky and not particularly relevant to this course. To prove
the triangle inequality requires the following classical result:
Theorem 2.11 (Hölder inequality) Let x, y ∈ Cn and 1p + q1 = 1 with 1 ≤ p, q ≤ ∞. Then |xH y| ≤ kxk p kykq .
Clearly, the 1-norm and 2 norms are special cases of the p-norm. Also, kxk∞ = lim p→∞ kxk p .
Notice that one can think of the Frobenius norm as taking the columns of the matrix, stacking them on
top of each other to create a vector of size m × n, and then taking the vector 2-norm of the result.
Chapter 2. Notes on Vector and Matrix Norms 28
Similarly, other matrix norms can be created from vector norms by viewing the matrix as a vector. It
turns out that other than the Frobenius norm, these aren’t particularly interesting in practice.
kAxkµ
kAkµ,ν = sup .
x ∈ Cn kxkν
x 6= 0
Let us start by interpreting this. How “big” A is, as measured by kAkµ,ν , is defined as the most that A
magnifies the length of nonzero vectors, where the length of the vectors (x) is measured with norm k · kν
and the length of the transformed vector (Ax) is measured with norm k · kµ .
Two comments are in order. First,
kAxkµ
sup = sup kAxkµ .
x ∈ Cn kxkν kxkν =1
x 6= 0
kAxkµ Ax x
sup = sup k kµ = sup kA kµ = sup kAykµ = sup kAykµ = sup kAxkµ .
x ∈ Cn kxkν x ∈ Cn kxkν x ∈ Cn kxkν x ∈ Cn kykν =1 kxkν =1
x 6= 0 x 6= 0 x 6= 0 x 6= 0
x
y = kxk ν
Also the “sup” (which stands for supremum) is used because we can’t claim yet that there is a vector x
with kxkν = 1 for which
kAkµ,ν = kAxkµ .
The fact is that there is always such a vector x. The proof depends on a result from real analysis (sometimes
called “advanced calculus”) that states that supx∈S f (x) is attained for some vector x ∈ S as long as f is
continuous and S is a compact set. Since real analysis is not a prerequisite for this course, the reader may
have to take this on faith!
We conclude that the following two definitions are equivalent definitions to the one we already gave:
kAxkµ
kAkµ,ν = maxn .
x ∈ C kxkν
x 6= 0
and
2.3. Matrix Norms 29
Proof: To prove this, we merely check whether the three conditions are met:
Let A, B ∈ Cm×n and α ∈ C be arbitrarily chosen. Then
Notice that A 6= 0 means that at least one of its columns is not a zero vector (since at least
one element). Let us assume it is the jth column, a j , that is nonzero. Then
kAxkµ kAe j kµ ka j kµ
kAkµ,ν = maxn ≥ = > 0.
x ∈ C kxkν ke j kν ke j kν
x 6= 0
QED
kAxk p
kAk p = maxn = max kAxk p .
x ∈ C kxk p kxk p =1
x 6= 0
Chapter 2. Notes on Vector and Matrix Norms 30
Theorem 2.19 Let A ∈ Cm×n and partition A = a0 a1 · · · an−1 . Show that
kAk1 = max ka j k1 .
0≤ j<n
Hence
ka k1 ≤ max kAxk1 ≤ ka k1
kxk1 =1
which implies that
max kAxk1 = ka k1 = max ka j k.
kxk1 =1 0≤ j<n
QED
abT0
abT
m×n 1
Homework 2.20 Let A ∈ C and partition A = . . Show that
..
abTm−1
kAk∞ = max kb
ai k1 = max (|αi,0 | + |αi,1 | + · · · + |αi,n−1 |)
0≤i<m 0≤i<m
* SEE ANSWER
aTi )T since abTi is the label for the ith row of matrix A.
Notice that in the above exercise abi is really (b
Homework 2.21 Let y ∈ Cm and x ∈ Cn . Show that kyxH k2 = kyk2 kxk2 .
* SEE ANSWER
2.3. Matrix Norms 31
2.3.4 Discussion
While k · k2 is a very important matrix norm, it is in practice often difficult to compute. The matrix norms,
k · kF , k · k1 , and k · k∞ are more easily computed and hence more practical in many instances.
Theorem 2.23 Let k · kν : Cn → R be a vector norm and given any matrix C ∈ Cm×n define the corre-
sponding induced matrix norm as
kCxkν
kCkν = max = max kCxkν .
x6=0 kxkν kxkν =1
Then for any A ∈ Cm×k and B ∈ Ck×n the inequality kABkν ≤ kAkν kBkν holds.
Lemma 2.24 Let k · kν : Cn → R be a vector norm and given any matrix C ∈ Cm×n define the induced
matrix norm as
kCxkν
kCkν = max = max kCxkν .
x6=0 kxkν kxkν =1
Then for any A ∈ Cm×n and y ∈ Cn the inequality kAykν ≤ kAkν kykν holds.
Proof: If y = 0, the result obviously holds since then kAykν = 0 and kykν = 0. Let y 6= 0. Then
kAxkν kAykν
kAkν = max ≥ .
x6=0 kxkν kykν
Rearranging this yields kAykν ≤ kAkν kykν . QED
We can now prove the theorem:
Proof:
kABkν = max kABxkν = max kA(Bx)kν ≤ max kAkν kBxkν ≤ max kAkν kBkν kxkν = kAkν kBkν .
kxkν =1 kxkν =1 kxkν =1 kxkν =1
QED
Ax = b Exact equation
A(x + δx) = b + δb Perturbed equation
We would like to determine a formula, κ(A, b, δb), that tells us how much a relative error in b is potentially
amplified into an error in the solution b:
kδxk kδbk
≤ κ(A, b, δb) .
kxk kbk
We will assume that A has an inverse. To find an expression for κ(A, b, δb), we notice that
Ax + Aδx = b + δb
Ax = b −
Aδx = δb
b = Ab
namely the x for which the maximum is attained. Pick b x.
• There is an δb
b for which
kA−1 xk kA−1 δbk
b
kA−1 k = max = ,
kxk6=0 kxk kδbk
b
again, the x for which the maximum is attained.
It is when solving the perturbed system
A(x + δx) = b
b + δb
b
Homework 2.28 Let k · k be a matrix norm induced by the k · · · k vector norm. Show that κ(A) =
kAkkA−1 k ≥ 1.
* SEE ANSWER
This last exercise shows that there will always be choices for b and δb for which the relative error is at
best directly translated into an equal relative error in the solution (if κ(A) = 1).
Theorem 2.29 Let k · kµ : Cn → R and k · kν : Cn → R be vector norms. Then there exist constants αµ,ν
and βµ,ν such that for all x ∈ Cn
αµ,ν kxkµ ≤ kxkν ≤ βµ,ν kxkµ .
Theorem 2.30 Let k · kµ : Cm×n → R and k · kν : Cm×n → R be matrix norms. Then there exist constants
αµ,ν and βµ,ν such that for all A ∈ Cm×n
Video
Read disclaimer regarding the videos in the preface!
35
Chapter 3. Notes on Orthogonality and the Singular Value Decomposition 36
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.1. Orthogonality and Unitary Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.2. Toward the SVD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.3. The Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.4. Geometric Interpretation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.5. Consequences of the SVD Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.6. Projection onto the Column Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.7. Low-rank Approximation of a Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.8. An Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.9. SVD and the Condition Number of a Matrix . . . . . . . . . . . . . . . . . . . . . . 54
3.10. An Algorithm for Computing the SVD? . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.1. Orthogonality and Unitary Matrices 37
Definition 3.2 Let q0 , q1 , . . . , qn−1 ∈ Cm . These vectors are said to be mutually orthonormal if for all
0 ≤ i, j < n
1 if i = j
qH q
i j = .
0 otherwise
Notice that for n vectors of length m to be mutually orthonormal, n must be less than or equal to
m. This is because n mutually orthonormal vectors are linearly independent and there can be at most m
linearly independent vectors of length m.
Definition 3.3 Let Q ∈ Cm×n (with n ≤ m). Then Q is said to be an orthonormal matrix if QH Q = I (the
identity).
Homework 3.4 Let Q ∈ C m×n (with n ≤ m). Partition Q = q0 q1 · · · qn−1 . Show that Q is an
orthonormal matrix if and only if q0 , q1 , . . . , qn−1 are mutually orthonormal.
* SEE ANSWER
Definition 3.5 Let Q ∈ Cm×m . Then Q is said to be a unitary matrix if QH Q = I (the identity).
Notice that unitary matrices are always square and only square matrices can be unitary. Sometimes the
term orthogonal matrix is used instead of unitary matrix, especially if the matrix is real valued.
Homework 3.6 Let Q ∈ Cm×m . Show that if Q is unitary then Q−1 = QH and QQH = I.
* SEE ANSWER
Homework 3.7 Let Q0 , Q1 ∈ Cm×m both be unitary. Show that their product, Q0 Q1 , is unitary.
* SEE ANSWER
Homework 3.8 Let Q0 , Q1 , . . . , Qk−1 ∈ Cm×m all be unitary. Show that their product, Q0 Q1 · · · Qk−1 , is
unitary.
* SEE ANSWER
Let x ∈ Cm . Then
H
H
x = QQ x = q0 q1 · · · qm−1 q0 q1 · · · qm−1 x
qH
0
qH
1
= · · · qm−1 . x
q0 q1
..
qH
m−1
Chapter 3. Notes on Orthogonality and the Singular Value Decomposition 38
qH
0x
qH x
1
= q0 q1 · · · qm−1
..
.
qH
m−1 x
= (qH H H
0 x)q0 + (q1 x)q1 + · · · + (qm−1 x)qm−1 .
• The vector
qH
0x
qH x
1
QH x =
..
.
qH
m−1 x
gives the coefficients when the vector x is written as a linear combination of the orthonormal vectors
q0 , q1 , . . . , qm−1 :
x = (qH H H
0 x)q0 + (q1 x)q1 + · · · + (qm−1 x)qm−1 .
Another way of looking at this is that if q0 , q1 , . . . , qm−1 is an orthonormal basis for Cm , then any x ∈ Cm
can be written as a linear combination of these vectors:
x = α0 q0 + α1 q1 + · · · + αm−1 qm−1 .
Now,
qH H
i x = qi (α0 q0 + α1 q1 + · · · + αi−1 qi−1 + αi qi + αi+1 qi+1 + · · · + αm−1 qm−1 )
= α0 q H q + α1 qH q + · · · + αi−1 qH q
| i{z }0 | i{z }1 | i {zi−1}
0 0 0
+ αi qH H H
i qi + αi+1 qi qi+1 + · · · + αm−1 qi qm−1
|{z} | {z } | {z }
1 0 0
= αi .
Thus qH
i x = αi , the coefficient that multiplies qi .
3.2. Toward the SVD 39
Homework 3.10 Let U ∈ Cm×m and V ∈ Cn×n be unitary matrices and A ∈ Cm×n . Then
* SEE ANSWER
Homework 3.11 Let U ∈ Cm×m and V ∈ Cn×n be unitary matrices and A ∈ Cm×n . Then kUAkF =
kAV kF = kAkF .
* SEE ANSWER
DT L 0
such that A = UDV H where D = with DT L = diag(δ0 , · · · , δr−1 ) and δi > 0 for 0 ≤ i < r.
0 0
• Inductive step: Assume the result is true for all matrices with 1 ≤ k < n columns. Show that it is
true for matrices with n columns.
Let A ∈ Cm×n with n ≥ 2. W.l.o.g., A 6= 0 so that kAk2 6= 0. Let δ0 and v0 ∈ Cn have the prop-
erty that kv0 k2 = 1 and δ0 = kAv0 k2 = kAk2 . (In other words, v0 is the vector that maximizes
Chapter 3. Notes on Orthogonality and the Singular Value Decomposition 40
maxkxk2 =1 kAxk2 .) Let u0 = Av0 /δ0 . Note that ku0 k2 = 1. Choose U1 ∈ Cm×(m−1) and V1 ∈ Cn×(n−1)
so that Ũ = u0 U1 and Ṽ = v0 V1 are unitary. Then
H
Ũ H AṼ = u0 U1 A v0 V1
H H
u Av0 u0 AV1 H H
δ u u u0 AV1 δ wH
= 0 = 0 0 0 = 0 ,
U1H Av0 U1H AV1 δU1H u0 U1H AV1 0 B
where w = V1H AH u0 and B = U1H AV1 . Now, we will argue that w = 0, the zero vector of appropriate
size:
2
δ0 wH
x
0 B
2 2 H 2 kU H AV xk22
2
δ0 = kAk2 = kU AV k2 = max 2
= max 2
x6=0 kxk2 x6=0 kxk2
2
2
δ0 w H δ0
2
δ0 + w w
H
0 B w
Bw
2 2
≥
2 =
2
δ0
δ0
w
w
2 2
(δ20 + wH w)2
≥ = δ20 + wH w.
δ20 + wH w
δ0 0
Thus δ20 ≥ δ20 + wH h which means that w = 0 and Ũ H AṼ = .
0 B
ĎT L 0
Ď ∈ R(m−1)×(n−1) such that B = Ǔ ĎV̌ H where Ď = with ĎT L = diag(δ1 , · · · , δr−1 ).
0 0
Now, let
1 0 1 0 δ0 0
U = Ũ ,V = Ṽ , and D = .
0 Ǔ 0 V̌ 0 Ď
(There are some really tough to see ”checks” in the definition of U, V , and D!!) Then A = UDV H
where U, V , and D have the desired properties.
• By the Principle of Mathematical Induction the result holds for all matrices A ∈ Cm×n with m ≥ n.
AT
Homework 3.14 Let A = . Use the SVD of A to show that kAk2 = kAT k2 .
0
* SEE ANSWER
Homework 3.15 Assume that U ∈ Cm×m and V ∈ Cn×n be unitary matrices. Let A, B ∈ Cm×n with B =
UAV H . Show that the singular values of A equal the singular values of B.
* SEE ANSWER
σ0 0
Homework 3.16 Let A ∈ Cm×n with A = and assume that kAk2 = σ0 . Show that kBk2 ≤
0 B
kAk2 . (Hint: Use the SVD of B.)
* SEE ANSWER
Proof: Notice that the proof of the above theorem is identical to that of Lemma 3.12. However, thanks
to the above exercises, we can conclude that kBk2 ≤ σ0 in the proof, which then can be used to show that
the singular values are found in order.
Proof: (Alternative) An alternative proof uses Lemma 3.12 to conclude that A = UDV H . If the entries on
the diagonal of D are not ordered from largest to smallest, then this can be fixed by permuting the rows
and columns of D, and correspondingly permuting the columns of U and V .
Since U and V are unitary matrices, {u0 , u1 } and {v0 , v1 } form orthonormal bases for the range and domain
of A, respectively:
Chapter 3. Notes on Orthogonality and the Singular Value Decomposition 42
χ0
Now let us look at how A transforms any vector with (Euclidean) unit length. Notice that x =
χ1
means that
x = χ0 e0 + χ1 e1 ,
where e0 and e1 are the unit basis vectors. Thus, χ0 and χ1 are the coefficients when x is expressed using
e0 and e1 as basis. However, we can also express x in the basis given by v0 and v1 :
T vT x
x = VV T
|{z} x = v0 v1 v0 v1 x = v0 v1 0
vT1 x
I
α
0
= vT0 x v0 + vT1 x v1 = α0 v0 + α0 v1 = v0 v1 .
|{z} |{z} α1
α0 α1
Thus, in the basis formed by v0 and v1 , its coefficients are α0 and α1 . Now,
T T α0
Ax = σ0 u0 σ1 u1 v0 v1 x= σ0 u0 σ1 u1 v0 v1 v0 v1
α1
α0
= σ0 u0 σ1 u1 = α 0 σ0 u 0 + α 1 σ1 u 1 .
α1
This is illustrated by the following picture, which also captures the fact that the unit ball is mapped to an
“ellipse”1 with major axis equal to σ0 = kAk2 and minor axis equal to σ1 :
1 It is not clear that it is actually an ellipse and this is not important to our observations.
Chapter 3. Notes on Orthogonality and the Singular Value Decomposition 44
Finally, we show the same insights for general vector x (not necessarily of unit length).
Another observation is that if one picks the right basis for the domain and codomain, then the com-
putation Ax simplifies to a matrix multiplication with a diagonal matrix. Let us again illustrate this for
nonsingular A ∈ R2×2 with
σ0 0 T
A= u0 u1 v0 v1 .
| {z } 0 σ1 | {z }
U V
| {z }
Σ
Now, if we chose to express y using u0 and u1 as the basis and express x using v0 and v1 as the basis, then
ψ
T T T 0
b
yb = UU | {z } y = (u0 y)u0 + (u1 y)u1 =
ψb1
I
χ
T T T 0 .
b
xb = VV |{z} x = (v0 x)v0 + (v1 x)v1 ==
χ1 .
b
I
If y = Ax then
U U T y = UΣV T
| {z }x = UΣb
x
|{z}
yb Ax
so that yb = Σb
x and
ψ
b0 σ0 b
χ0
= .
b 1.
ψ χ1 .
σ1 b
These observation generalize to A ∈ Cm×m .
3.5. Consequences of the SVD Theorem 45
We first generalize the observations we made for A ∈ R2×2 . Let us track what the effect of Ax = UΣV H x
is on vector x. We assume that m ≥ n.
• Let U = u0 · · · um−1 and V = v0 · · · vn−1 .
• Let
vH x
H 0
..
x = VV H x = v0 · · · vn−1 v0 · · · vn−1 x= v0 · · · vn−1 .
H
vn−1 x
= vH H
0 xv0 + · · · + vn−1 xvn−1 .
This can be interpreted as follows: vector x can be written in terms of the usual basis of Cn as χ0 e0 +
· · · + χ1 en−1 or in the orthonormal basis formed by the columns of V as vH H
0 xv0 + · · · + vn−1 xvn−1 .
Ax = vH H
0 xAv0 + · · · + vn−1 xAvn−1
= vH H
0 xσ0 u0 + · · · + vn−1 xσn−1 un−1
= σ0 u0 vH H
0 x + · · · + σn−1 un−1 vn−1 x
= σ0 u0 vH H
0 + · · · + σn−1 un−1 vn−1 x.
Proof:
ΣT L 0 H
A = UΣV H = UL UR VL VR = UL ΣT LVLH .
0 0
Chapter 3. Notes on Orthogonality and the Singular Value Decomposition 46
(Each term nonzero and an outer product, and hence a rank-1 matrix.)
Proof: We leave the proof as an exercise.
Corollary 3.21 C (A) = C (UL ).
Proof:
• Let y ∈ C (A). Then there exists x ∈ Cn such that y = Ax (by the definition of y ∈ C (A)). But then
y = Ax = UL ΣT LVLH x = UL z,
| {z }
z
i.e., there exists z ∈ Cr such that y = UL z. This means y ∈ C (UL ).
• Let y ∈ C (UL ). Then there exists z ∈ Cr such that y = UL z. But then
y = UL z = UL ΣT L Σ−1
T L z = UL ΣT L VLH VL Σ−1
T L z = A VL Σ−1 z = Ax
| {z } | {z } | {zT L}
I I x
so that there exists x ∈ Cn such that y = Ax, i.e., y ∈ C (A).
Corollary 3.22 Let A = UL ΣT LVLH be the reduced SVD of A where UL and VL have r columns. Then the
rank of A is r.
Proof: The rank of A equals the dimension of C (A) = C (UL ). But the dimension of C (UL ) is clearly r.
Corollary 3.23 N (A) = C (VR ).
Proof:
• Let x ∈ N (A). Then
H
H VLH
x = | {z } x =
VV VL VR VL VR x= VL VR x
VRH
I
VLH x
= VL VR = VLVLH x +VRVRH x.
VRH x
If we can show that VLH x = 0 then x = VR z where z = VRH x. Assume that VLH x 6= 0. Then ΣT L (VLH x) 6=
0 (since ΣT L is nonsingular) and UL (ΣT L (VLH x)) 6= 0 (since UL has linearly independent columns).
But that contradicts the fact that Ax = UL ΣT LVLH x = 0.
3.5. Consequences of the SVD Theorem 47
Corollary 3.24 For all x ∈ Cn there exists z ∈ C (VL ) such that Ax = Az.
Proof:
H
H
Ax = A VV
| {z } x = A VL VR VL VR x
I
= A VLVLH x +VRVRH x = AVLVLH x + AVRVRH x
Cn Cm
xn
N (A) = C (VR )
N (AH ) = C (UR )
dim n − r dim m − r
4. kA−1 k2 = 1/σn−1 .
Proof: The only item that is less than totally obvious is (3). Clearly A−1 = V Σ−1U H . The problem is that
in Σ−1 the diagonal entries are not ordered from largest to smallest. The permutation fixes this.
Corollary 3.28 If A ∈ Cm×n has linearly independent columns then AH A is invertible (nonsingular) and
−1 H
(AH A)−1 = VL Σ2T L VL .
Proof: Since A has linearly independent columns, A = UL ΣT LVLH is the reduced SVD where UL has n
columns and VL is unitary. Hence
2
AH A = (UL ΣT LVLH )H UL ΣT LVLH = VL ΣH H H H H
T LUL UL ΣT LVL = VL ΣT L ΣT LVL = VL ΣT LVL .
Since VL is unitary and ΣT L is diagonal with nonzero diagonal entries, tey are both nonsingular. Thus
−1 H
VL Σ2T LVLH VL Σ2T L VL ) = I.
This is minimized when w = ULH y. Thus, the vector that is closest to y in the space spanned by UL is given
by x = ULULH y.
Chapter 3. Notes on Orthogonality and the Singular Value Decomposition 50
Corollary 3.31 Let A ∈ Cm×n and A = UL ΣT LVLH be its reduced SVD. Then the projection of y ∈ Cm onto
C (A) is given by ULULH y.
Proof: This follows immediately from the fact that C (A) = C (UL ).
Corollary 3.32 Let A ∈ Cm×n have linearly independent columns. Then the projection of y ∈ Cm onto
C (A) is given by A(AH A)−1 AH y.
−1 H
Proof: From Corrolary 3.28, we know that AH A is nonsingular and that (AH A)−1 = VL Σ2T L VL . Now,
−1
A(AH A)−1 AH y = (UL ΣT LVLH )(VL Σ2T L VLH )(UL ΣT LVLH )H y
= UL ΣT L VLH VL Σ−1 Σ−1 V H V Σ U H y = ULULH y.
| {z } T L T L | L{z L} T L L
I I
Definition 3.33 Let A have linearly independent columns. Then (AH A)−1 AH is called the pseudo-inverse
or Moore-Penrose generalized inverse of matrix A.
where UL ∈ Cm×k , VL ∈ Cn×k , and ΣT L ∈ Rk×k with k ≤ r. Then B = UL ΣT LVLH is the matrix in Cm×n
closest to A in the following sense:
kA − Bk2 = kU H (A − B)V k2 = kU H AV −U H BV k2
0 0
H
ΣT L ΣT L
Σ − UL UR
=
−
B VL VR
=
2
0 ΣBR 0 0
2
0 0
=
= kΣBR k2 = σk
0 ΣBR
2
Next, assume that C has rank t ≤ k and kA − Ck2 < kA − Bk2 . We will show that this leads to a
contradiction.
3.8. An Application 51
• The null space of C has dimension at least n − k since dim(N (C)) + rank(C) = n.
• If x ∈ N (C) then
kAxk2 = k(A −C)xk2 ≤ kA −Ck2 kxk2 < σk kxk2 .
• Partition U = u0 · · · um−1 and V = v0 · · · vn−1 . Then kAv j k2 = kσ j u j k2 = σ j ≥ σs
for j = 0, . . . , k. Now, let x be any linear combination of v0 , . . . , vk : x = α0 v0 + · · · + αk vk . Notice
that
kxk22 = kα0 v0 + · · · + αk vk k22 ≤ |α0 |2 + · · · |αk |2 .
Then
so that kAxk2 ≥ σk kxk2 . In other words, vectors in the subspace of all linear combinations of
{v0 , . . . , vk } satisfy kAxk2 ≥ σk kxk2 . The dimension of this subspace is k + 1 (since {v0 , · · · , vk }
form an orthonormal basis).
• Both these subspaces are subspaces of Cn . Since their dimensions add up to more than n there must
be at least one nonzero vector z that satisfies both kAzk2 < σk kzk2 and kAzk2 ≥ σk kzk2 , which is a
contradiction.
The above theorem tells us how to pick the best approximation with given rank to a given matrix.
3.8 An Application
Let Y ∈ Rm×n be a matrix that, for example, stores a picture. In this case, the (i, j) entry in Y is, for
example, a number that represents the grayscale value of pixel (i, j). The following instructions, executed
in octave or matlab, generate the picture of Mexican artist Frida Kahlo in Figure 3.2(top-left). The file
FridaPNG.png can be found at http://www.cs.utexas.edu/users/flame/Notes/FridaPNG.png.
Although the picture is black and white, it was read as if it is a color image, which means a m × n × 3 array
of pixel information is stored. Setting Y = IMG( :,:,1 ) extracts a single matrix of pixel information.
(If you start with a color picture, you will want to approximate IMG( :,:,1), IMG( :,:,2), and IMG(
:,:,3) separately.)
Now, let Y = UΣV T be the SVD of matrix Y . Partition, conformally,
ΣT L 0
U = UL UR , V = VL VR , and Σ = ,
0 ΣBR
Chapter 3. Notes on Orthogonality and the Singular Value Decomposition 52
k=2 k=5
k = 10 k = 25
In this case, the ratio σ0 /σn−1 represents the ratio between the major and minor axes of the “ellipse” on
the right.
3.10. An Algorithm for Computing the SVD? 55
• Given a vector q0 computing vectors q0 , . . . , qm−1 is expensive (as we will see when we discuss the
QR factorization).
Towards the end of the course we will discuss algorithms for computing the eigenvalues and eigenvectors
of a matrix, and related algorithms for computing the SVD.
Chapter 3. Notes on Orthogonality and the Singular Value Decomposition 56
Chapter 4
Notes on Gram-Schmidt QR Factorization
A classic problem in linear algebra is the computation of an orthonormal basis for the space spanned by a
given set of linearly independent vectors: Given a linearly independent set of vectors {a0 , . . . , an−1 } ⊂ Cm
we would like to find a set of mutually orthonormal vectors {q0 , . . . , qn−1 } ⊂ Cm so that
Video
Read disclaimer regarding the videos in the preface!
* YouTube
* Download from UT Box
* View After Local Download
57
Chapter 4. Notes on Gram-Schmidt QR Factorization 58
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.1. Classical Gram-Schmidt (CGS) Process . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.2. Modified Gram-Schmidt (MGS) Process . . . . . . . . . . . . . . . . . . . . . . . . 64
4.3. In Practice, MGS is More Accurate . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.4. Cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.4.1. Cost of CGS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.4.2. Cost of MGS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.1. Classical Gram-Schmidt (CGS) Process 59
* SEE ANSWER
Thus, this relationship between the linearly independent vectors {a j } and the orthonormal vectors {q j }
can be concisely stated as
A = QR,
where A and Q are m × n matrices (m ≥ n), QH Q = I, and R is an n × n upper triangular matrix.
Theorem 4.4 Let A have linearly independent columns, A = QR where A, Q ∈ Cm×n with n ≤ m, R ∈ Cn×n ,
QH Q = I, and R is an upper triangular matrix with nonzero diagonal entries. Then, for 0 < k < n, the first
k columns of A span the same space as the first k columns of Q.
Proof: Partition
RT L RT R
A→ AL AR , Q→ QL QR , and R → ,
0 RBR
where AL , QL ∈ Cm×k and RT L ∈ Ck×k . Then RT L is nonsingular (since it is upper triangular and has no
zero on its diagonal), QH
L QL = I, and AL = QL RT L . We want to show that C (AL ) = C (QL ):
Chapter 4. Notes on Gram-Schmidt QR Factorization 60
Steps Comment
ρ0,0 := ka0 k2 Compute the length of vector a0 , ρ0,0 := ka0 k2 .
q0 =: a0 /ρ0,0 Set q0 := a0 /ρ0,0 , creating a unit vector in the direction of
a0 .
Clearly, Span({a0 }) = Span({q0 }). (Why?)
ρ0,1 = qH
0 a1
a⊥
1 = a1 − ρ0,1 q0 Compute a⊥
1 , the component of vector a1 orthogonal to q0 .
ρ1,1 = ka⊥
1 k2 Compute ρ1,1 , the length of a⊥
1.
q1 = a⊥
1 /ρ1,1 Set q1 = a⊥
1 /ρ1,1 , creating a unit vector in the direction of
a⊥
1 .
Now, q0 and q1 are mutually orthonormal and
Span({a0 , a1 }) = Span({q0 , q1 }). (Why?)
ρ0,2 = qH
0 a2
ρ1,2 = qH
1 a2
a⊥ ⊥
2 = a2 − ρ0,2 q0 − ρ1,2 q1 Compute a2 , the component of vector a2 orthogonal to q0
ρ = ka⊥ k and q1 .
2,2 2 2
⊥
q2 = a2 /ρ2,2 Compute ρ2,2 , the length of a⊥
2.
Set q2 = a⊥
2 /ρ2,2 , creating a unit vector in the direction of
⊥
a2 .
for j = 0, . . . , n − 1 for j = 0, . . . , n − 1 , n − 1
j = 0, . . .
for
for k = 0, . . . , j − 1 ρ0, j qH a
ρk, j := qH 0 j
k aj
H
.. ..
end . := . = q0 · · · q j−1 aj
ρ j−1, j qHj−1 a j
a⊥j := a j a⊥j := a j
for k = 0, . . . , j − 1 for k = 0, . . . , j − 1 ρ
0, j
.
ρk, j := qH
k ja a⊥j := a j − q0 · · · q j−1 ..
a⊥j := a⊥j − ρk, j qk a⊥j := a⊥j − ρk, j qk
ρ j−1, j
end end
⊥
ρ j, j := ka j k2 ρ j, j := ka⊥j k2
⊥
q j := a j /ρ j, j q j := a⊥j /ρ j, j ρ j, j := ka⊥j k2
end end q j := a⊥j /ρ j, j
end
• We first show that C (AL ) ⊆ C (QL ). Let y ∈ C (AL ). Then there exists x ∈ Ck such that y = AL x. But
then y = QL z, where z = RT L x 6= 0, which means that y ∈ C (QL ). Hence C (AL ) ⊆ C (QL ).
• We next show that C (QL ) ⊆ C (AL ). Let y ∈ C (QL ). Then there exists z ∈ Ck such that y = QL z. But
then y = AL x, where x = R−1
T L z, from which we conclude that y ∈ C (AL ). Hence C (QL ) ⊆ C (AL ).
Since C (AL ) ⊆ C (QL ) and C (QL ) ⊆ C (AL ), we conclude that C (QL ) = C (AL ).
Theorem 4.5 Let A ∈ Cm×n have linearly independent columns. Then there exist Q ∈ Cm×n with QH Q = I
and upper triangular R with no zeroes on the diagonal such that A = QR. This is known as the QR
factorization. If the diagonal elements of R are chosen to be real and positive, th QR factorization is
unique.
Proof: (By induction). Note that n ≤ m since A has linearly independent columns.
• Base case: n = 1. In this case A = a0 where a0 is its only column. Since A has linearly
independent columns, a0 6= 0. Then
A = a0 = (q0 ) (ρ00 ) ,
• Inductive step: Assume that the result is true for all A with n − 1 linearly independent columns. We
will show it is true for A ∈ Cm×n with linearly independent columns.
Let A ∈ Cm×n . Partition A → A0 a1 . By the induction hypothesis, there exist Q0 and R00
such that QH
0 Q0 = I, R00 is upper triangular with nonzero diagonal entries and A0 = Q0 R00 . Now,
Chapter 4. Notes on Gram-Schmidt QR Factorization 62
Figure 4.3: (Classical) Gram-Schmidt algorithm for computing the QR factorization of a matrix A.
compute r01 = QH ⊥
0 a1 and a1 = a1 − Q0 r01 , the component of a1 orthogonal to C (Q0 ). Because the
columns of A are linearly independent, a⊥ ⊥ ⊥
1 6= 0. Let ρ11 = ka1 k2 and q1 = a1 /ρ11 . Then
R00 r01
Q0 q1 = Q0 R00 Q0 r01 + q1 ρ11
0 ρ11
= A0 Q0 r01 + a⊥
1
= A0 a1 = A.
4.1. Classical Gram-Schmidt (CGS) Process 63
R00 r01
Hence Q = Q0 q1 and R = .
0 ρ11
• By the Principle of Mathematical Induction the result holds for all matrices A ∈ Cm×n with m ≥ n.
The proof motivates the algorithm in Figure 4.3 (left) in FLAME notation1 .
An alternative for motivating that algorithm is as follows: Consider A = QR. Partition A, Q, and R to
yield
R r R02
00 01
A0 a1 A2 = Q0 q1
T
Q2 0 ρ11 r12 .
0 0 R22
Assume that Q0 and R00 have already been computed. Since corresponding columns of both sides must be
equal, we find that
a1 = Q0 r01 + q1 ρ11 . (4.1)
Also, QH H
0 Q0 = I and Q0 q1 = 0, since the columns of Q are mutually orthonormal. Hence Q0 a1 =
H
H H
Q0 Q0 r01 + Q0 q1 ρ11 = r01 . This shows how r01 can be computed from Q0 and a1 , which are already
known. Next, a⊥1 = a1 − Q0 r01 is computed from (4.1). This is the component of a1 that is perpendicular
to the columns of Q0 . We know it is nonzero since the columns of A are linearly independent. Since
ρ11 q1 = a⊥ ⊥ ⊥
1 and we know that q1 has unit length, we now compute ρ11 = ka1 k2 and q1 = a1 /ρ11 , which
completes a derivation of the algorithm in Figure 4.3.
Homework 4.6 Homework 4.7 Let A have linearly independent columns and let A = QR be a QR fac-
torization of A. Partition
RT L RT R
A → AL AR , Q → QL QR , and R → ,
0 RBR
2. C (AL ) = C (QL ): the first k columns of Q form an orthonormal basis for the space spanned by the
first k columns of A.
3. RT R = QH
L AR ,
4. (AR − QL RT R )H QL = 0,
5. AR − QL RT R = QR RBR , and
6. C (AR − QL RT R ) = C (QR ).
* SEE ANSWER
1The FLAME notation should be intuitively obvious. If it is not, you may want to review the earlier weeks in Linear
Algebra: Foundations to Frontiers - Notes to LAFF With.
Chapter 4. Notes on Gram-Schmidt QR Factorization 64
[y⊥ , r] = Proj orthog to QCGS (Q, y) [y⊥ , r] = Proj orthog to QMGS (Q, y)
(used by classical Gram-Schmidt) (used by modified Gram-Schmidt)
y⊥ = y y⊥ = y
for i = 0, . . . , k − 1 for i = 0, . . . , k − 1
ρi := qH ρi := qH ⊥
i y i y
y⊥ := y⊥ − ρi qi y⊥ := y⊥ − ρi qi
endfor endfor
Figure 4.4: Two different ways of computing y⊥ = (I − QQH )y, the component of y orthogonal to C (Q),
where Q has k orthonormal columns.
This can be computed by the algorithm in Figure 4.4 (left) and is used by what is often called the Classical
Gram-Schmidt (CGS) algorithm given in Figure 4.3.
An alternative algorithm for computing y⊥ is given in Figure 4.4 (right) and is used by the Modified
Gram-Schmidt (MGS) algorithm also given in Figure 4.5. This approach is mathematically equivalent to
4.2. Modified Gram-Schmidt (MGS) Process 65
Repartition
R00 r01 R02
RT L RT R
→ , → T
AL AR A0 a1 A2 0 ρ11 r12
0 RBR
0 0 R22
wherea1 and q1 are columns, ρ11 is a scalar
Continue with
R r R02
RT L RT R 00 01
AL AR ← A0 a1 A2 , ← 0 ρ11 rT
12
0 RBR
0 0 R22
endwhile
Figure 4.5: Left: Classical Gram-Schmidt algorithm. Middle: Modified Gram-Schmidt algorithm. Right:
Modified Gram-Schmidt algorithm where every time a new column of Q, q1 is computed the component
of all future columns in the direction of this new vector are subtracted out.
for j = 0, . . . , n − 1 for j = 0, . . . , n − 1
a⊥j := a j
for k = 0, . . . , j − 1 for k = 0, . . . , j − 1
ρk, j := qH ⊥
k aj
ρk, j := aHk aj
a⊥j := a⊥j − ρk, j qk a j := a j − ρk, j ak
end end
ρ j, j := ka⊥j k2 ρ j, j := ka j k2
q j := a⊥j /ρ j, j a j := a j /ρ j, j
end
end
(a) MGS algorithm that computes Q and R from (b) MGS algorithm that computes Q and R from
A. A, overwriting A with Q.
for j = 0, . . . , n − 1 for j = 0, . . . , n − 1
ρ j, j := ka j k2 ρ j, j := ka j k2
a j := a j /ρ j, j a j := a j /ρ j, j
for k = j + 1, . . . , n − 1 for k = j + 1, . . . , n − 1
ρ j,k := aHj ak ρ j,k := aHj ak
end
for k = j + 1, . . . , n − 1
ak := ak − ρ j, j a j ak := ak − ρ j,k a j
end end
end end
(c) MGS algorithm that normalizes the jth col- (d) Slight modification of the algorithm in (c) that
umn to have unit length to compute q j (overwrit- computes ρ j,k in a separate loop.
ing a j with the result) and then subtracts the com-
ponent in the direction of q j off the rest of the
columns (a j+1 , . . . , an−1 ).
for j = 0, . . . , n − 1 for j = 0, . . . , n − 1
ρ j, j := ka j k2 ρ j, j := ka j k2
a j := a j /ρ j, j
aj := a j /ρ j, j
ρ j, j+1 · · · ρ j,n−1 := aHj a j+1 · · · aHj an−1 ρ j, j+1 · · · ρ j,n−1 := aHj a j+1 · · · an−1
a j+1 · · · an−1 := a j+1 · · · an−1 := a j+1 · · · an−1 −
a j+1 − ρ j, j+1 a j · · · an−1 − ρ j,n−1 a j a j ρ j, j+1 · · · ρ j,n−1
end end
(e) Algorithm in (d) rewritten without loops. (f) Algorithm in (e) rewritten to expose
the row-vector-times
matrix multiplica-
H
tion a j a j+1 · · · an−1 and rank-1 update
a j+1 · · · an−1 − a j ρ j, j+1 · · · ρ j,n−1 .
Figure 4.7: Modified Gram-Schmidt algorithm for computing the QR factorization of a matrix A.
y⊥ = y − (qH H
0 y)q0 − · · · − (qi−1 y)qi−1 ,
leaving us with
y⊥ = y − (qH H H
0 y)q0 − · · · − (qi−1 y)qi−1 − (qi y)qi .
Now, notice that
qH H H
= qH H H H H
i y − (q0 y)q0 − · · · − (qi−1 y)qi−1 i y − qi (q0 y)q0 − · · · − qi (qi−1 y)qi−1
= qH H H H H
i y − (q0 y) qi q0 − · · · − (qi−1 y) qi qi−1
| {z } | {z }
0 0
= qH
i y.
Chapter 4. Notes on Gram-Schmidt QR Factorization 68
If we now ask the question “Are the columns of Q orthonormal?” we can check this by computing QH Q,
which should equal I, the identity. But
H
1 0 0 1 0 0 √ √
2 2
√ √
ε − 2 − 2
√ √
ε − 2 − 2
1 + εmach − 2 ε − 2 ε
√
QH Q = √2 2 √2 2
= − 22 ε 1 .
2
2
1 2
0 0 0 0 √
2 2 2 1
√
2
√
2
− 2 ε 2 1
0 0 2 0 0 2
Figure 4.8: Execution of the CGS algorith (left) and MGS algorithm (right) on the example in Eqn. (4.2).
Chapter 4. Notes on Gram-Schmidt QR Factorization 70
Similarly, in Figure 4.8 (right) we execute the MGS algorithm. It yields the approximate matrix
1 0 0
√ √
ε − 2 6
Q≈ √2 6√
.
2 6
0
2 −
√6
2 6
0 0 6
If we now ask the question “Are the columns of Q orthonormal?” we can check if QH Q = I. The answer:
H
1 0 0 1 0 0 √ √
2 6
√ √
ε − 2 − 6 ε − 2 − 6
√ √ 1 + εmach − 2 ε − 6 ε
√
H 2 6 2 6
Q Q= √ = 2 ,
√ √ √ −
2 6 2 6
2 ε 1 0
0 − 6 0 − 6 √
2 2 6
√
2 6
√
2 6
− 6 ε 0 1
0 0 6 0 0 6
which shows that for this example MGS yields better orthogonality than does CGS. What is going on?
The answer lies with how a⊥2 is computed in the last step of each of the algorithms.
• In the CGS algorithm, we find that
a⊥ H H
2 := a2 − (q0 a2 )q0 − (q1 a2 )q1 .
Now, q0 has a relatively small error in it and hence qH 0 a2 q0 has a relatively) small error in it. It is
likely that a part of that error is in the direction of q1 . Relative to qH0 a2 q0 , that error in the direction
of q1 is small, but relative to a2 − q0 a2 q0 it is not. The point is that then a2 − qH
H
0 a2 q0 has a relatively
large error in it in the direction of q1 . Subtracting qH a
1 2 1q does not fix this and since in the end
⊥
a2 is small, it has a relatively large error in the direction of q1 . This error is amplified when q2 is
computed by normalizing a⊥ 2.
4.4 Cost
Let us examine the cost of computing the QR factorization of an m × n matrix A. We will count multiplies
and an adds as each as one floating point operation.
We start by reviewing the cost, in floating point operations (flops), of various vector-vector and matrix-
vector operations:
4.4. Cost 71
Now, consider the algorithms in Figure 4.5. Notice that the columns of A are of size m. During the kth
iteration (0 ≤ k < n), A0 has k columns and A2 has n − k − 1 columns.
∑n−1
k=0 [2mk + 2mk + 2m + m]
= ∑n−1
k=0 [3m + 4mk]
= 3mn + 4m ∑n−1
k=0 k
2
≈ 3mn + 4m n2 (∑n−1 2
k=0 k = n(n − 1)/2 ≈ n /2
= 3mn + 2mn2
≈ 2mn2 (3mn is of lower order).
Chapter 4. Notes on Gram-Schmidt QR Factorization 72
∑n−1
k=0 [2m + m + 2m(n − k − 1) + 2m(n − k − 1)]
= ∑n−1
k=0 [3m + 4m(n − k − 1)]
= 3mn + 4m ∑n−1
k=0 (n − k − 1)
= 3mn + 4m ∑n−1
i=0 i (Change of variable: i = n − k − 1)
n2
≈ 3mn + 4m 2 (∑n−1 2
i=0 i = n(n − 1)/2 ≈ n /2
= 3mn + 2mn2
≈ 2mn2 (3mn is of lower order).
Chapter 5
Notes on the FLAME APIs
Video
Read disclaimer regarding the videos in the preface!
No video.
73
Chapter 5. Notes on the FLAME APIs 74
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.2. Install FLAME@lab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.3. An Example: Gram-Schmidt Orthogonalization . . . . . . . . . . . . . . . . . . . . 75
5.3.1. The Spark Webpage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.3.2. Implementing CGS with FLAME@lab . . . . . . . . . . . . . . . . . . . . . . 76
5.3.3. Editing the code skeleton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.3.4. Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.4. Implementing the Other Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
5.1. Motivation 75
[y⊥ , r] = Proj orthog to QCGS (Q, y) [y⊥ , r] = Proj orthog to QMGS (Q, y)
(used by classical Gram-Schmidt) (used by modified Gram-Schmidt)
y⊥ = y y⊥ = y
for i = 0, . . . , k − 1 for i = 0, . . . , k − 1
ρi := qH ρi := qH ⊥
i y i y
y⊥ := y⊥ − ρi qi y⊥ := y⊥ − ρi qi
endfor endfor
Figure 5.1: Two different ways of computing y⊥ = (I − QQH )y, the component of y orthogonal to C (Q),
where Q has k orthonormal columns.
5.1 Motivation
In the course so far, we have frequently used the “FLAME Notation” to express linear algebra algorithms.
In this note we show how to translate such algorithms into code, using various QR factorization algorithms
as examples.
http://www.cs.utexas.edu/users/flame/Spark/.
Chapter 5. Notes on the FLAME APIs 76
Repartition
R00 r01 R02
RT L RT R
→ , → T
AL AR A0 a1 A2 0 ρ11 r12
0 RBR
0 0 R22
wherea1 and q1 are columns, ρ11 is a scalar
Continue with
R r R02
RT L RT R 00 01
AL AR ← A0 a1 A2 , ← 0 ρ11 rT
12
0 RBR
0 0 R22
endwhile
Figure 5.2: Left: Classical Gram-Schmidt algorithm. Middle: Modified Gram-Schmidt algorithm. Right:
Modified Gram-Schmidt algorithm where every time a new column of Q, q1 is computed the component
of all future columns in the direction of this new vector are subtracted out.
When you open the link, you will get a page that looks something like the picture in Figure 5.3.
We will focus on the Classical Gram-Schmidt algorithm on the left, which we show by itself in Fig-
ure 5.4 (left). To its right, we show how the menu on the left side of the Spark webpage needs to be filled
out.
Some comments:
Type of function: Later you will learn about “blocked” algorithms. For now, we implement “unblocked”
algorithms.
Variant number: Notice that there are a number of algorithmic variants for implementing the Gram-
Schmidt algorithm. We choose to call the first one “Variant 1”.
Number of operands: This routine requires two operands: one each for matrices A and R. (A will be
overwritten by the matrix Q.)
Operand 1: We indicate that A is a matrix through which we “march” from left to right (L->R) and it is
both input and output.
Operand 2: We indicate that R is a matrix through which we “march” from to-left to bottom-right
(TL->BR) and it is both input and output. Our API requires you to pass in the array in which to put
an output, so an appropriately sized R must be passed in.
Pick and output language: A number of different representations are supported, including APIs for M-
script (FLAME@lab), C (FLAMEC), LATEX(FLaTeX), and Python (FlamePy). Pick FLAME@lab.
To the left of the menu, you now find what we call a code skeleton for the implementation, as shown in
Figure 5.5. In Figure 5.6 we show the algorithm and generated code skeleton side-by-side.
Chapter 5. Notes on the FLAME APIs 78
r01 := AH
0 a1
a1 := a1 − A0 r01
ρ11 := ka1 k2
a1 := a1 /ρ11
Continue with
AL AR ← A0 a1 A2 ,
R00 r01 R02
RT L RT R
← 0 ρ11 rT
12
0 RBR
0 0 R22
endwhile
Figure 5.4: Left: Classical Gram-Schmidt algorithm. Right: Generated code-skeleton for CGS.
which happens to be correct. (When you implement the Householder QR factorization, you may not
be so lucky...)
The “update” statements: The Spark webpage can’t guess what the actual updates to the various parts
of matrices A and R should be. It fills in
5.3. An Example: Gram-Schmidt Orthogonalization 79
Figure 5.5: The Spark webpage filled out for CGS Variant 1.
% update line 1 %
% : %
% update line n %
r01 := AH
0 a1 r01 = A0’ * a1;
a1 := a1 − A0 r01 a1 = a1 - A0 * r01;
into appropriate M-script code:
ρ11 := ka1 k2 rho11 = norm( a1 );
a1 = a1 / rho11;
a1 := a1 /ρ11
(Notice: if one forgets the “;”, when executed the results of the assignment will be printed by
Matlab/Octave.)
At this point, one saves the resulting code in the file CGS unb var1.m. The “.m” ending is important
since the name of the file is used to find the routine when using Matlab/Octave.
5.3.4 Testing
To now test the routine, one starts octave and, for example, executes the commands
Chapter 5. Notes on the FLAME APIs 80
r01 := AH
0 a1
a1 := a1 − A0 r01
ρ11 := ka1 k2
a1 := a1 /ρ11
Continue with
AL AR ← A0 a1 A2 ,
R00 r01 R02
RT L RT R
← 0 ρ11 rT
12
0 RBR
0 0 R22
endwhile
Figure 5.6: Left: Classical Gram-Schmidt algorithm. Right: Generated code-skeleton for CGS.
> A = rand( 5, 4 )
> R = zeros( 4, 4 )
> [ Q, R ] = CGS_unb_var1( A, R )
> A - Q * triu( R )
• Modified Gram Schmidt algorithm, (MGS unb var1, corresponding to the right-most algorithm in
Figure 5.2), respectively.
5.4. Implementing the Other Algorithms 81
• The Householder QR factorization algorithm and algorithm to form Q from “Notes on Householder
QR Factorization”.
The routine for computing a Householder transformation (similar to Figure 5.1) can be found at
http://www.cs.utexas.edu/users/flame/Notes/FLAMEatlab/Housev.m
That routine implements the algorithm on the left in Figure 5.1). Try and see what happens if you
replace it with the algorithm to its right.
Note: For the Householder QR factorization and “form Q” algorithm how to start the algorithm when the
matrix is not square is a bit tricky. Thus, you may assume that the matrix is square.
Chapter 5. Notes on the FLAME APIs 82
Chapter 6
Notes on Householder QR Factorization
Video
Read disclaimer regarding the videos in the preface!
* YouTube
* Download from UT Box
* View After Local Download
83
Chapter 6. Notes on Householder QR Factorization 84
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.2. Householder Transformations (Reflectors) . . . . . . . . . . . . . . . . . . . . . . . 85
6.2.1. The general case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.2.2. As implemented for the Householder QR factorization (real case) . . . . . . . . 87
6.2.3. The complex case (optional) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.2.4. A routine for computing the Householder vector . . . . . . . . . . . . . . . . . 88
6.3. Householder QR Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
6.4. Forming Q . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
6.5. Applying QH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
6.6. Blocked Householder QR Factorization . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.6.1. The UT transform: Accumulating Householder transformations . . . . . . . . . 99
6.6.2. A blocked algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
6.6.3. Variations on a theme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
6.1. Motivation 85
6.1 Motivation
A fundamental problem to avoid in numerical codes is the situation where one starts with large values and
one ends up with small values with large relative errors in them. This is known as catastrophic cancellation.
The Gram-Schmidt algorithms can inherently fall victim to this: column a j is successively reduced in
length as components in the directions of {q0 , . . . , q j−1 } are subtracted, leaving a small vector if a j was
almost in the span of the first j columns of A. Application of a unitary transformation to a matrix or vector
inherently preserves length. Thus, it would be beneficial if the QR factorization can be implementated
as the successive application of unitary transformations. The Householder QR factorization accomplishes
this.
The first fundamental insight is that the product of unitary matrices is itself unitary. If, given A ∈ Cm×n
(with m ≥ n), one could find a sequence of unitary matrices, {H0 , . . . , Hn−1 }, such that
R
Hn−1 · · · H0 A = ,
0
where R ∈ Cm×n is upper triangular, then
R R R
Hn−1 · · · H0 A = H0 · · · Hn−1 = Q = QL QR = QL R,
| {z } 0 0 0
Q
where QL equals the first n columns of A. Then A = QL R is the QR factorization of A. The second
fundamental insight will be that the desired unitary transformations {H0 , . . . , Hn−1 } can be computed and
applied cheaply.
= z + uH xu − 2uH x |{z}
uH u u = z − uH xu.
1
Chapter 6. Notes on Householder QR Factorization 86
x
H
x=z+u xu
H
u xu
v=x−y
z
H
u xu u
u
H H u
(I − 2 u u )x (I − 2 u u )x
y
Figure 6.1: Left: Illustration that shows how, given vectors x and unit length vector u, the subspace
orthogonal to u becomes a mirror for reflecting x represented by the transformation (I − 2uuH ). Right:
Illustration that shows how to compute u given vectors x and y with kxk2 = kyk2 .
This can be interpreted as follows: The space perpendicular to u acts as a “mirror”: any vector in that space
(along the mirror) is not reflected, while any other vector has the component that is orthogonal to the space
(the component outside, orthogonal to, the mirror) reversed in direction, as illustrated in Figure 6.1. Notice
that a reflection preserves the length of the vector.
• H = H H , and
* SEE ANSWER
Next, let us ask the question of how to reflect a given x ∈ Cn into another vector y ∈ Cn with kxk2 =
kyk2 . In other words, how do we compute vector u so that (I − 2uuH )x = y. From our discussion above,
we need to find a vector u that is perpendicular to the space with respect to which we will reflect. From
Figure 6.1(right) we notice that the vector from y to x, v = x − y, is perpendicular to the desired space.
Thus, u must equal a unit vector in the direction v: u = v/kvk2 .
Remark 6.3 In subsequent discussion we will prefer to give Householder transformations as I − uuH /τ,
where τ = uH u/2 so that u needs no longer be a unit vector, just a direction. The reason for this will
become obvious later.
In the next subsection, we will need to find a Householder transformation H that maps a vector x to a
multiple of the first unit basis vector (e0 ).
Let us first discuss how to find H in the case where x ∈ Rn . We seek v so that (I − vT2 v vvT )x = ±kxk2 e0 .
Since the resulting vector that we want is y = ±kxk2 e0 , we must choose v = x − y = x ∓ kxk2 e0 .
6.2. Householder Transformations (Reflectors) 87
Homework 6.4 Show that if x ∈ Rn , v = x ∓ kxk2 e0 , and τ = vT v/2 then (I − 1τ vvT )x = ±kxk2 e0 .
* SEE ANSWER
In practice, we choose v = x + sign(χ1 )kxk2 e0 where χ1 denotes the first element of x. The reason is as
follows: the first element of v, ν1 , will be ν1 = χ1 ∓ kxk2 . If χ1 is positive and kxk2 is almost equal to χ1 ,
then χ1 − kxk2 is a small number and if there is error in χ1 and/or kxk2 , this error becomes large relative
to the result χ1 − kxk2 , due to catastrophic cancellation. Regardless of whether χ1 is positive or negative,
we can avoid this by choosing x = χ1 + sign(χ1 )kxk2 e0 .
where χ1 equals
the
first element of x and x2 is the rest of x. Then we will wish to find a Householder
1
vector u = so that
u2
T
1 1 ±kxk2
I − 1
χ
1 = .
τ u2 u2 x2 0
±kxk2
Notice that y in the previous discussion equals the vector , so the direction of u is given by
0
χ1 ∓ kxk2
v= .
x2
We now wish to normalize this vector so its first entry equals “1”:
v 1 χ ∓ kxk2 1
u= = 1 = .
ν1 χ1 ∓ kxk2 x2 x2 /ν1
where ν1 = χ1 ∓ kxk2 equals the first element of v. (Note that if ν1 = 0 then u2 can be set to 0.)
where χ1 equals
the
first element of x and x2 is the rest of x. Then we will wish to find a Householder
1
vector u = so that
u2
H
1 1
±kxk2
I − 1
χ
1 = .
τ u2 u2 x2 0
Here
± denotes a complex scalar on the complex unit circle. By the same argument as before
χ1 −
±kxk2
v= .
x2
We now wish to normalize this vector so its first entry equals “1”:
v 1 χ −
±kxk2 1
u= = 1 = .
kvk2 χ1 −
±kxk2 x2 x2 /ν1
where ν1 = χ1 −
±kxk2 . (If ν1 = 0 then we set u2 to 0.)
where τ = uH u/2 = (1 + uH
2 u2 )/2 and ρ =
±kxk2 .
q
z z
Hint: ρρ = |ρ|2 = kxk22 since H preserves the norm. Also, kxk22 = |χ1 |2 + kx2 k22 and = |z|
z .
* SEE ANSWER
χ1
Again, the choice
± is important. For the complex case we choose
± = −sign(χ1 ) = |χ1 |
as the computation of the above mentioned vector u2 , and scalars ρ and τ, from vector x. We will use the
notation H(x) for the transformation I − 1τ uuH where u and τ are computed by Housev(x).
6.3. Householder QR Factorization 89
ρ χ1
Algorithm: , τ = Housev
u2 x2
χ2 := kx2 k2
χ1
α :=
(= kxk2 )
χ2
2
ρ = −sign(χ1 )kxk2 ρ := −sign(χ1 )α
ν1 = χ1 + sign(χ1 )kxk2 ν1 := χ1 − ρ
u2 = x2 /ν1 u2 := x2 /ν1
χ2 = χ2 /|ν1 |(= ku2 k2 )
τ = (1 + uH
2 u2 )/2 τ = (1 + χ22 )/2
Figure 6.2: Computing the Householder transformation. Left: simple formulation. Right: efficient com-
putation. Note: I have not completely double-checked these formulas for the complex case. They
work for the real case.
ρ11 α11 aT12
, τ1 = :=
u21 a21 A22
Original matrix “Move forward”
α11 ρ11 aT12 − wT12
Housev
a21 0 A22 − u21 wT12
× × × × × × × × × × × × × × × ×
× × × × × × × × 0 × × × 0 × × ×
× × × × × × × × 0 × × × 0 × × ×
× × × × × × × × 0 × × × 0 × × ×
× × × × × × × × 0 × × × 0 × × ×
× × × × × × × × × × × ×
0 × × × 0 × × × 0 × × ×
0 × × × 0 0 × × 0 0 × ×
0 × × × 0 0 × × 0 0 × ×
0 × × × 0 0 × × 0 0 × ×
× × × × × × × × × × × ×
0 × × × 0 × × × 0 × × ×
0 0 × × 0 0 × × 0 0 × ×
0 0 × × 0 0 0 × 0 0 0 ×
0 0 × × 0 0 0 × 0 0 0 ×
× × × × × × × × × × × ×
0 × × × 0 × × × 0 × × ×
0 0 × × 0 0 × × 0 0 × ×
0 0 0 × 0 0 0 × 0 0 0 ×
0 0 0 × 0 0 0 0 0 0 0 0
Now let us assume that after k iterations of the algorithm matrix A contains
R r01 R02
RT L RT R 00
A→ = 0 α11 a12 , T
0 ABR
0 a21 A22
and update
I 0 R00 r01 R02
H
A := aT12
0
0 I − 1 1 1
α11
τ1
u2 u2 0 a21 A22
H
0 0 R r01 R02
1 00
= I − 1 1 0 α11 aT12
τ1
u2 u2 0 a21 A22
R r R02
00 01
= 0 ρ11
T T
a12 − w12 ,
0 0 A22 − u21 wT12
where  denotes the original contents of A and RT L is an upper triangular matrix. Rearranging this we find
that
 = H0 H1 · · · Hn−1 R
which shows that if Q = H0 H1 · · · Hn−1 then  = QR.
Chapter 6. Notes on Householder QR Factorization 92
* SEE ANSWER
Typically, the algorithm overwrites the original matrix A with the upper triangular matrix, and at each
step u21 is stored over the elements that become zero, thus overwriting a21 . (It is for this reason that the
first element of u was normalized to equal “1”.) In this case Q is usually not explicitly formed as it can be
stored as the separate Householder vectors below the diagonal of the overwritten matrix. The algorithm
that overwrites A in this manner is given in Fig. 6.4.
We will let
[{U\R},t] = HouseholderQR(A)
denote the operation that computes the QR factorization of m × n matrix A, with m ≥ n, via Householder
transformations. It returns the Householder vectors and matrix R in the first argument and the vector of
scalars “τi ” that are computed as part of the Householder transformations in t.
Theorem 6.7 Given A ∈ Cm×n the cost of the algorithm in Figure 6.4 is given by
2
CHQR (m, n) ≈ 2mn2 − n3 flops.
3
6.4 Forming Q
Given A ∈ Cm×n , let [A,t] = HouseholderQR(A) yield the matrix A with the Householder vectors stored
below the diagonal, R stored on and above the diagonal, and the τi stored in vector t. We now discuss how
to form the first n columns of Q = H0 H1 · · · Hn−1 . The computation is illustrated in Figure 6.5.
6.4. Forming Q 93
Repartition
A a01 A02 t
AT L AT R 00 tT 0
→ aT α11 aT
and
→ τ1
10 12
ABL ABR tB
A20 a21 A22 t2
whereα11 and τ1 are scalars
α11 ρ11 α11
, τ1 := , τ1 = Housev
a21 u21 a21
aT12 1 aT
Update := I − 1 1 uH 12
τ1 21
A22 u21 A22
via the steps
• wT12 := (aT12 + aH
21 A22 )/τ1
a T T T
a12 − w12
• 12 :=
A22 A22 − a21 wT12
Continue with
A a A02 t
AT L AT R 00 01 tT 0
← aT α11
aT12 and
← τ1
10
ABL ABR tB
A20 a21 A22 t2
endwhile
α11 aT12
:=
a21 A22
Original matrix “Move forward”
1 − 1/τ1 −(uH
21 A22 )/τ1
−u21 /τ1 A22 + u21 aT12
1 0 0 0 1 0 0 0 1 0 0 0
0 1 0 0 0 1 0 0 0 1 0 0
0 0 1 0 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 × 0 0 0 ×
0 0 0 0 0 0 0 × 0 0 0 ×
1 0 0 0 1 0 0 0
0 1 0 0 0 1 0 0
0 0 × × 0 0 × ×
0 0 × × 0 0 × ×
0 0 × × 0 0 × ×
1 0 0 0 1 0 0 0
0 × × × 0 × × ×
0 × × × 0 × × ×
0 × × × 0 × × ×
0 × × × 0 × × ×
× × × × × × × ×
× × × × × × × ×
× × × × × × × ×
× × × × × × × ×
× × × × × × × ×
• Inductive step: Assume the result is true for Bk . We show it is true for Bk−1 :
In×n I 0
Bk−1 = Hk−1 Hk · · · Hn−1 = Hk−1 Bk = Hk−1 k×k .
0 0 B̃k
I(k−1)×(k−1) 0 I(k−1)×(k−1) 0 0
= 1 0 1 0
1
0 I − τk 1 uk H
uk 0 0 B̃k
I(k−1)×(k−1) 0
= 1 1 0
1
0 I − 1 u H
τk k
uk 0 B̃k
I 0
(k−1)×(k−1)
= 1 0 1 where yTk = uH
k B̃k /τk
0 − 1/τk yT
k
0 B̃k uk
I 0
(k−1)×(k−1)
=
1 − 1/τk −yk T
0
−uk /τk Bk − uk yTk
I 0 0
(k−1)×(k−1) 0
I(k−1)×(k−1)
= 0 1 − 1/τk −yTk = .
0 B̃k−1
0 −uk /τk Bk − uk yTk
Theorem 6.9 Given [A,t] = HouseholderQR(A) from Figure 6.4, the algorithm in Figure 6.6 overwrites
A with the first n = n(A) columns of Q as defined by the Householder transformations stored below the
diagonal of A and in the vector t.
Chapter 6. Notes on Householder QR Factorization 96
Repartition
A a A02 t
AT L AT R 00 01 tT 0
→ aT α11 aT
and
→ τ1
10 12
ABL ABR tB
A20 a21 A22 t2
whereα11 and τ1 are scalars
α11 aT12 1
1 1 0
Update := I −
τ1
1 uH
21
a21 A22 u21 0 A22
via the steps
• α11 := 1 − 1/τ1
• aT12 := −(aH
21 A22 )/τ1
Continue with
A a01 A02 t
AT L AT R 00 tT 0
← aT
α11 aT12 and
← τ1
10
ABL ABR tB
A20 a21 A22 t2
endwhile
Figure 6.6: Algorithm for overwriting A with Q from the Householder transformations stored as House-
holder vectors below the diagonal of A (as produced by [A,t] = HouseholderQR(A) ).
6.5. Applying QH 97
Theorem 6.10 Given A ∈ Cm×n the cost of the algorithm in Figure 6.6 is given by
2
CFormQ (m, n) ≈ 2mn2 − n3 flops.
3
Proof: Hence the proof for Theorem 6.7 can be easily modified to establish this result.
Give a high-level reason why this would be (much) more expensive than the algorithm in Figure 6.6.
* SEE ANSWER
6.5 Applying QH
In a future Note, we will see that the QR factorization is used to solve the linear least-squares problem. To
do so, we need to be able to compute ŷ = QH y where QH = Hn−1 · · · H0 .
Let us start by computing H0 y:
H H
1 1 1 1
I − 1
ψ ψ ψ
1 = 1 − 1 /τ1
τ1 u2 u2 y2 y2 u2 u2 y2
| {z }
ω1
ψ1 1 ψ − ω1
= − ω1 = 1 .
y2 u2 y2 − ω1 u2
where ω1 = (ψ1 + uH 2 y2 )/τ1 . This motivates the algorithm in Figure 6.7 for computing y := Hn−1 · · · H0 y
given the output matrix A and vector t from routine HouseholderQR.
The cost of this algorithm can be analyzed as follows: When yT is of length k, the bulk of the com-
putation is in an inner product with vectors of length m − k (to compute ω1 ) and an axpy operation with
vectors of length m − k to subsequently update ψ1 and y2 . Thus, the cost is approximately given by
n−1
∑ 4(m − k) ≈ 4mn − 2n2.
k=0
Notice that this is much cheaper than forming Q and then multiplying.
Chapter 6. Notes on Householder QR Factorization 98
Repartition
A00 a01 A02 t0 y0
AT L AT R
tT
yT
→ aT10 α11 aT12 , → τ1 , and
→
ψ1
ABL ABR tB yB
A20 a21 A22 t2 y2
whereα11 , τ1 , and ψ1 are scalars
ψ1 1 ψ
Update := I − 1 1 uH 1
τ1 21
y2 u21 y2
via the steps
• ω1 := (ψ1 + aH
21 y2 )/τ1
ψ1 ψ − ω1
• := 1
y2 y2 − ω1 u2
Continue with
A a A02 t y
AT L AT R 00 01 0 0
tT yT
← aT α11
aT12 , ← τ1 , and
← ψ1
10
ABL ABR tB yB
A20 a21 A22 t2 y2
endwhile
Figure 6.7: Algorithm for computing y := Hn−1 · · · H0 y given the output from routine HouseholderQR.
6.6. Blocked Householder QR Factorization 99
* SEE ANSWER
An algorithm that computes the inverse of an upper triangular matrix T based on the above exercise is
given in Figure 6.8.
Homework 6.13 Homework 6.14 Consider u1 ∈ Cm with u1 6= 0 (the zero vector), U0 ∈ Cm×k , and non-
singular T00 ∈ Ck×k . Define τ1 = (uH
1 u1 )/2, so that
1
H1 = I − u1 uH
1
τ1
equals a Householder transformation, and let
−1 H
Q0 = I −U0 T00 U0 .
Show that
−1
−1 H 1 T00 t01 H
Q0 H1 = (I −U0 T00 U0 )(I − u1 uH
1 )=I− U0 u1 U0 u1 ,
τ1 0 τ1
where t01 = QH
0 u1 .
* SEE ANSWER
Homework 6.15 Homework 6.16 Consider ui ∈ Cm with ui 6= 0 (the zero vector). Define τi = (uH
i ui )/2,
so that
1
Hi = I − ui uH
τi i
equals a Householder transformation, and let
U = u0 u1 · · · uk−1 .
Show that
H0 H1 · · · Hk−1 = I −UT −1U H ,
where T is an upper triangular matrix.
* SEE ANSWER
Chapter 6. Notes on Householder QR Factorization 100
Repartition
T t T
TT L TT R 00 01 02
→ t T τ11 t T
10 12
TBL TBR
T20 t21 T22
whereτ11 is 1 × 1
Continue with
T00 t01 T02
TT L TT R
T T
←
t10 τ11 t12
TBL TBR
T20 t21 T22
endwhile
Figure 6.8: Unblocked algorithm for inverting an upper triangular matrix. The algorithm assumes that T00
has already been inverted, and computes the next column of T in the current iteration.
6.6. Blocked Householder QR Factorization 101
Repartition
U u01 U02 t
UT L UT R 00 tT 0
→ uT υ11 uT ,
→ τ1
,
10 12
UBL UBR tB
U20 u21 U22 t2
T t T
TT L TT R 00 01 02
→ t T τ11 t T
10 12
TBL TBR
T20 t21 T22
whereυ11 is 1 × 1, τ1 has 1 row, τ11 is 1 × 1
t01 := U0H u1
τ11 := τ1
Continue with
U u01 U02 t
UT L UT R 00 tT
0
uT10
← uT12 , ←
τ1 ,
υ11
UBL UBR tB
U u21 U22 t2
20
T t01 T02
TT L TT R 00
! ← T
t10 τ11 T
t12
TBL TBR
T20 t21 T22
endwhile
Figure 6.9: Algorithm that computes T from U and the vector t so that I −UTU H equals the UT transform.
Here U is assumed to the output of, for example, an unblocked Householder based QR algorithm. This
means that it is a lower trapezoidal matrix, with ones on the diagonal.
Chapter 6. Notes on Householder QR Factorization 102
The above exercises can be summarized in the algorithm for computing T from U in Figure 6.9.
In [27] we call the transformation I −UT −1U H that equals the accumulated Householder transforma-
tions the UT transform and prove that T can instead by computed as
T = triu UH U
(the upper triangular part of U H U) followed by either dividing the diagonal elements by two or setting
them to τ0 , . . . , τk−1 (in order). In that paper, we point out similar published results [9, 33, 44, 31].
• Now we need to also apply the Householder transformations to the rest of the columns:
H H
A12 U11 U11 A12
:= I − T −1
11
A22 U21 U21 A22
A12 U11 H
= − W21
A22 U21
H
A12 −U11W21
= ,
H
A22 −U21W21
6.6. Blocked Householder QR Factorization 103
A11 A11
[ ,t1 ] := H OUSE QR UNB VAR 1( )
A21 A21
A11
T11 := F ORM T( ,t1 )
A21
H := T −H (U H A +U H A )
W21
11 11 12 21 22
A A −U11W21 H
12 := 12
A22 H
A22 −U21W21
Continue with
A00 A01 A02 t0
AT L AT R
tT
←
A10 A11 A12 , ← t1
ABL ABR tB
A20 A21 A22 t2
endwhile
where
H −H H H
W21 = T11 (U11 A12 +U21 A22 ).
This motivates the blocked algorithm in Figure 6.10.
There are many possible algorithms for computing the QR factorization. For example, the unblocked
algorithm from Figure 6.4 can be merged with the unblocked algorithm for forming T in Figure 6.9 to
yield the algorithm in Figure 6.11.
Let us now again compute the QR factorization of A simultaneous with the forming of T , but now taking
advantage of the fact that T is partically computed to change the algorithm into what some would consider
a “left-looking” algorithm.
Partition
A a01 A02 T t T
00 00 01 02
A → a10 α11 aT12 and T → 0 τ11 t12
T T .
A20 a21 A22 0 0 T22
A U
00 00
T T
Assume that a10 has been factored and overwritten with u10 and R00 while also computing
A20 U20
T00 . In the next step, we need to apply previous Householder transformations to the next column of A and
then update that column with the next column of R and U. In addition, the next column of T must be
computing. This means:
• Update
H H
a U U a
01 00 00 01
−1 T
:= I − u10
T
T00 u10
α11 α11
a21 U20 U20 a21
Repartition
A a01 A02 T t01 T02
AT L AT R 00 00
TT L TT R
→ aT α11 aT
, → tT
τ11 T
t12
10 12 10
ABL ABR TBL TBR
A20 a21 A22 T20 t21 T22
whereα11 is 1 × 1, τ11 is 1 × 1
α11 ρ11 α11
, τ11 := , τ11 = Housev
a21 u21 a
21
aT12 1
1 aT12
Update := I −
τ11
1 uH
21
A22 u21 A22
via the steps
• wT12 := (aT12 + aH
21 A22 )/τ11
a T T
a12 − w12T
• 12 :=
A22 A22 − a21 wT12
t01 := AH
20 a21
Continue with
A a A02 T t T02
AT L AT R 00 01 00 01
TT L TT R
← aT α11 aT
, ← t T τ11
T
t12
10 12 10
ABL ABR TBL TBR
A20 a21 A22 T20 t21 T22
endwhile
Figure 6.11: Unblocked Householder transformation based QR factorization merged with the computation
of T for the UT transform.
Chapter 6. Notes on Householder QR Factorization 106
Repartition
A a01 A02 T t01 T02
AT L AT R 00 00
TT L TT R
→ aT α11 aT
, → tT
τ11 T
t12
10 12 10
ABL ABR TBL TBR
A20 a21 A22 T20 t21 T22
whereα11 is 1 × 1, τ11 is 1 × 1
H H
a U U a
01 00 00 01
−1 T
α11 := I − u10
T
T00 u10
α11
a02 U20 U20 a21
via the steps
−H H a + α (uT )H +U H a )
• w01 := T00 (U00 01 11 10 20 21
a a U
01 01 00
• α11 := α11 − u10 w01
T
a02 a02 U20
α ρ α
11 , τ11 := 11 , τ11 = Housev 11
a21 u21 a21
t01 := AH
20 a21
Continue with
A a A02 T t T02
AT L AT R 00 01 00 01
TT L TT R
← aT α11 aT
, ← t T τ11
T
t12
10 12 10
ABL ABR TBL TBR
A20 a21 A22 T20 t21 T22
endwhile
Figure 6.12: Alternative unblocked Householder transformation based QR factorization merged with the
computation of T for the UT transform.
6.6. Blocked Householder QR Factorization 107
An alternative blocked variant that uses either of the unblocked factorization routines that merges the
formation of T is given in Figure 6.13.
Chapter 6. Notes on Householder QR Factorization 108
A11 A11
[ , T11 ] := H OUSE QR F ORM T UNB VAR X( )
A21 A21
H := T −H (U H A +U H A )
W21
11 11 12 21 22
A A −U11W21 H
12 := 12
A22 H
A22 −U21W21
Continue with
A A01 A02 t
AT L AT R 00 0
tT
← A10 A11
A12 , ← t1
ABL ABR tB
A20 A21 A22 t2
endwhile
For a motivation of the linear least-squares problem, read Week 10 (Sections 10.3-10.5) of
Video
Read disclaimer regarding the videos in the preface!
109
Chapter 7. Notes on Solving Linear Least-Squares Problems 110
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
7.1. The Linear Least-Squares Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
7.2. Method of Normal Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
7.3. Solving the LLS Problem Via the QR Factorization . . . . . . . . . . . . . . . . . . 112
7.3.1. Simple derivation of the solution . . . . . . . . . . . . . . . . . . . . . . . . . . 112
7.3.2. Alternative derivation of the solution . . . . . . . . . . . . . . . . . . . . . . . . 113
7.4. Via Householder QR Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
7.5. Via the Singular Value Decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . 115
7.5.1. Simple derivation of the solution . . . . . . . . . . . . . . . . . . . . . . . . . . 115
7.5.2. Alternative derivation of the solution . . . . . . . . . . . . . . . . . . . . . . . . 116
7.6. What If A Does Not Have Linearly Independent Columns? . . . . . . . . . . . . . . 116
7.7. Exercise: Using the the LQ factorization to solve underdetermined systems . . . . . 123
7.1. The Linear Least-Squares Problem 111
In other words, x is the vector that minimizes the expression kAx − yk2 . Equivalently, we can solve
If x solves the linear least-squares problem, then Ax is the vector in C (A) (the column space of A) closest
to the vector y.
If A has linearly independent columns then AT A is nonsingular. Hence, the x that minimizes kAx − yk2
solves AT Ax = AT y. This is known as the method of normal equations. Notice that then
x = (AT A)−1 AT y,
| {z }
A†
• Compute ŷ = AT y.
Cost: 2mn flops.
• Solve Lz = ŷ and LT x = z.
Cost: n2 flops each.
Chapter 7. Notes on Solving Linear Least-Squares Problems 112
Thus, the total cost of solving the LLS problem via normal equations is approximately mn2 + 13 n3 flops.
Remark 7.1 We will later discuss that if A is not well-conditioned (its columns are nearly linearly depen-
dent), the Method of Normal Equations is numerically unstable because AT A is ill-conditioned.
The above discussion can be generalized to the case where A ∈ Cm×n . In that case, x must solve AH Ax =
AH y.
A geometric explanation of the method of normal equations (for the case where A is real valued) can
be found in Week 10 (Sections 10.3-10.5) of Linear Algebra: Foundations to Frontiers - Notes to LAFF
With.
Assume A ∈ Cm×n has linearly independent columns and let A = QL RT L be its QR factorization. We wish
to compute the solution to the LLS problem: Find x ∈ Cn such that
Notice that we know that, if A has linearly independent columns, the solution is given by x = (AH A)−1 AH y
(the solution to the normal equations). Now,
Thus, the desired x that minimizes the linear least-squares problem solves RT L x = QH
L y. The solution is
unique because RT L is nonsingular (because A has linearly independent columns).
In practice, one performs the following steps:
• Compute the QR factorization A = QL RT L .
If Gram-Schmidt or Modified Gram-Schmidt are used, this costs 2mn2 flops.
• Form ŷ = QH
L y.
Cost: 2mn flops.
• Solve RT L x = ŷ (triangular solve).
Cost: n2 flops.
Thus, the total cost of solving the LLS problem via (Modified) Gram-Schmidt QR factorization is approx-
imately 2mn2 flops.
Notice that the solution computed by the Method of Normal Equations (generalized to the complex
case) is given by
(AH A)−1 AH y = ((QL RT L )H (QL RT L ))−1 (QL RT L )H y = (RH H −1 H H
T L QL QL RT L ) RT L QL y
−1 H −1 −H H −1 H −1
= (RH H H
T L RT L ) RT L QL y = RT L RT L RT L QL y = RT L QL y = RT L ŷ = x
where RT L x = ŷ. This shows that the two approaches compute the same solution, generalizes the Method of
Normal Equations to complex valued problems, and shows that the Method of Normal Equations computes
the desired result without requiring multivariate calculus.
Chapter 7. Notes on Solving Linear Least-Squares Problems 114
Given A ∈ Cm×n with linearly independent columns, the Householder QR factorization yields n House-
holder transformations, H0 , . . . , Hn−1 , so that
RT L
Hn−1 · · · H0 A = .
| {z }
H 0
Q = QL QR
QH
L
H
ŷ = QH
L y = I 0 y = I 0 QL QR y= I 0 QH y
QH
R
= I 0 (Hn−1 · · · H0 )y. = I 0 ( Hn−1 · · · H0 y ) = wT .
| {z }
wT
w=
wB
Form w= (Hn−1 (· · · (H0 y) · · ·)) (see “Notes on Householder QR Factorization”). Partition w =
•
w
T where wT ∈ Cn . Then ŷ = wT .
wB
Cost: 4m2 − 2n2 flops. (See “Notes on Householder QR Factorization” regarding this.)
• Solve RT L x = ŷ.
Cost: n2 flops.
Thus, the total cost of solving the LLS problem via Householder QR factorization is approximately 2mn2 −
2 3
3 n flops. This is cheaper than using (Modified) Gram-Schmidt QR factorization, and hence preferred
(because it is also numerically more stable, as we will discuss later in the course).
7.5. Via the Singular Value Decomposition 115
Given A ∈ Cm×n with linearly independent columns, let A = UΣV H be its SVD decomposition. Partition
ΣT L
U= UL UR and Σ= ,
0
ΣT L
A= UL UR V H = UL ΣT LV H .
0
We wish to compute the solution to the LLS problem: Find x ∈ Cn such that
Notice that we know that, if A has linearly independent columns, the solution is given by x = (AH A)−1 AH y
(the solution to the normal equations). Now,
= V Σ−1 −1 H H
T L ΣT LV V ΣT LUL y V −1 = V H and (BCD)−1 = D−1C−1 B−1
= V Σ−1 H
T LUL y V H V = I and Σ−1
T L ΣT L = I
Chapter 7. Notes on Solving Linear Least-Squares Problems 116
The x that solves ΣT LV H x = ULH y minimizes the expression. That x is given by x = V Σ−1 H
T LUL y.
This suggests the following approach:
• Form ŷ = Σ−1 H
T LUL y.
Cost: approx. 2mn flops.
• Compute z = V ŷ.
Cost: approx. 2mn flops.
Now,
characterizes all solutions to the linear least-squares problem, where wB can be chosen to be any vector of
size n − r. By choosing wB = 0 and hence x = VL Σ−1 H
T LUL y we choose the vector x that itself has minimal
2-norm.
Chapter 7. Notes on Solving Linear Least-Squares Problems 118
The sequence of pictures on the following pages reasons through the insights that we gained so far
(in “Notes on the Singular Value Decomposition” and this note). These pictures can be downloaded as a
PowerPoint presentation from
http://www.cs.utexas.edu/users/flame/Notes/Spaces.pptx
7.6. What If A Does Not Have Linearly Independent Columns? 119
A
C(VL ) C(U L )
Row
space
Column
space
dim = r ŷ dim = r
Ax = ŷ
0 x = xr + x n 0
dim = n − r dim = m − r
C(U R )
Le1
null
Null
space
space
C(VR )
If A ∈ Cm×n and
ΣT L 0 H
A= UL UR VL VR = UL ΣT LVLH
0 0
Also, given a vector x ∈ Cn , the matrix A maps x to yb = Ax, which must be in C (A) = C (UL ).
Chapter 7. Notes on Solving Linear Least-Squares Problems 120
A
C(VL ) C(U L )
Row
space
Column
space
dim = r
dim = r
Ax = y??
y
0
x 0
dim = n − r dim = m − r
C(U R )
Le1
null
Null
space
space
C(VR )
Given an arbitrary y ∈ Cm not in C (A) = C (UL ), there cannot exist a vector x ∈ Cn such
that Ax = y.
7.6. What If A Does Not Have Linearly Independent Columns? 121
A
C(VL ) C(U L )
Row
space
Column
−1
xr = VL Σ TLU L y H
space
Axr = U L ΣTLVLH xr = ŷ ŷ = U LU LH y
dim = r
dim = r
Ax = ŷ
y
0
x = xr + x n 0
xn = VR wB C(U R )
Le1
null
Null
space
space
C(VR )
The solution to the Linear Least-Squares problem, x, equals any vector that is mapped by
A to the projection of y onto the column space of A: yb = A(AH A)−1 AH y = QQH y. This
solution can be written as the sum of a (unique) vector in the row space of A and any vector
in the null space of A. The vector in the row space of A is given by
xr = VL Σ−1 H −1 H
T LUL y == VL ΣT LUL y
b.
Chapter 7. Notes on Solving Linear Least-Squares Problems 122
The sequence of pictures, and their explanations, suggest a much simply path towards the formula for
solving the LLS problem.
Ax = ULULH y.
• We know that there must be a solution xr in the row space of A. It suffices to find wT such that
xr = VL wT .
AVL wT = ULULH y.
• Since there is a one-to-one mapping by A from the row space of A to the column space of A, we
know that wT is unique. Thus, if we find a solution to the above, we have found the solution.
• Since A = UL Σ−1 H
T LVL , we can rewrite the above equation as
ΣT L wT = ULH y
so that wT = Σ−1 H
T LUL y.
• Hence
xr = VL Σ−1 H
T LUL y.
• Adding any vector in the null space of A to xr also yields a solution. Hence all solutions to the LLS
problem can be characterized by
x = VL Σ−1 H
T LUL y +VR wR .
ΣT L wL = vT
• Thus, by expressing x in the right basis (the columns of VL ) and the projection of y in the right
basis (the columns of UL ), the problem became trivial, since the matrix that related the solution
to the right-hand side became diagonal.
7.7. Exercise: Using the the LQ factorization to solve underdetermined systems 123
You may want to review “Notes on the QR Factorization” as you do this exercise.
Homework 7.2 Let A ∈ Cm×n with m < n have linearly independent rows. Show that there exist a lower
triangular matrix LL ∈ Cm×m and a matrix QT ∈ Cm×n with orthonormal rows such that A = LL QT ,
noting that LL does not have any zeroes on the diagonal. Letting L = LL 0 be Cm×n and unitary
QT
Q= , reason that A = LQ.
QB
Don’t overthink the problem: use results you have seen before.
* SEE ANSWER
Homework 7.3 Let A ∈ Cm×n with m < n have linearly independent rows. Consider
Use the fact that A = LL QT , where LL ∈ Cm×m is lower triangular and QT has orthonormal rows, to argue
−1
that any vector of the
form QH H
T LL y + QB wB (where wB is any vector in C
n−m ) is a solution to the LLS
QT
problem. Here Q = .
QB
* SEE ANSWER
Homework 7.4 Continuing Exercise 7.2, use Figure 7.1 to give a Classical Gram-Schmidt inspired al-
gorithm for computing LL and QT . (The best way to check you got the algorithm right is to implement
it!)
* SEE ANSWER
Homework 7.5 Continuing Exercise 7.2, use Figure 7.2 to give a Householder QR factorization inspired
algorithm for computing L and Q, leaving L in the lower triangular part of A and Q stored as Householder
vectors above the diagonal of A. (The best way to check you got the algorithm right is to implement it!)
* SEE ANSWER
Chapter 7. Notes on Solving Linear Least-Squares Problems 124
Repartition
A0 L00 l01 L02 Q0
AT LT L LT R
QT T
→ aT1 ,
→ T
l10 λ11 T
l12 , → q1
AB LBL LBR QB
A2 L20 l21 L22 Q2
wherea1 has 1 row, λ11 is 1 × 1, q1 has 1 row
Continue with
A L l L02 Q
AT 0 L LT R 00 01 0
QT T
← aT
, TL ← l T λ11
T
l12 , ← q1
1 10
AB LBL LBR QB
A2 L20 l21 L22 Q2
endwhile
Repartition
A a01 A02 t
AT L AT R 00 0
tT
→ aT α11 aT
, → τ1
ABL ABR 10 12 tB
A20 a21 A22 t2
whereα11 is 1 × 1, τ1 has 1 row
Continue with
A a A02 t
AT L AT R 00 01 0
tT
← aT α11
aT12 , ← τ1
ABL ABR 10 tB
A20 a21 A22 t2
endwhile
Correctness in the presence of error (e.g., when floating point computations are performed) takes on a
different meaning. For many problems for which computers are used, there is one correct answer, and
we expect that answer to be computed by our program. The problem is that, as we will see later, most
real numbers cannot be stored exactly in a computer memory. They are stored as approximations, floating
point numbers, instead. Hence storing them and/or computing with them inherently incurs error.
Naively, we would like to be able to define a program that computes with floating point numbers as
being “correct” if it computes an answer that is close to the exact answer. Unfortunately, some problems
that are computed this way have the property that a small change in the input yields a large change in the
output. Surely we can’t blame the program for not computing an answer close to the exact answer in this
case. The mere act of storing the input data as a floating point number may cause a completely different
output, even if all computation is exact. We will later define stability to be a property of a program. It
is what takes the place of correctness. In this note, we instead will focus on when a problem is a “good”
problem, meaning that in exact arithmetic a ”small” change in the input will always cause at most a “small”
change in the output, or a “bad” problem if a “small” change may yield a “large” A good problems will be
called well-conditioned. A bad problem will be called ill-conditioned.
Notice that “small” and “large” are vague. To some degree, norms help us measure size. To some
degree, “small” and “large” will be in the eyes of the beholder (in other words, situation dependent).
Video
Read disclaimer regarding the videos in the preface!
127
Chapter 8. Notes on the Condition of a Problem 128
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
8.1. Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
8.2. The Prototypical Example: Solving a Linear System . . . . . . . . . . . . . . . . . . 129
8.3. Condition Number of a Rectangular Matrix . . . . . . . . . . . . . . . . . . . . . . . 133
8.4. Why Using the Method of Normal Equations Could be Bad . . . . . . . . . . . . . . 134
8.5. Why Multiplication with Unitary Matrices is a Good Thing . . . . . . . . . . . . . . 135
8.1. Notation 129
8.1 Notation
Throughout this note, we will talk about small changes (perturbations) to scalars, vectors, and matrices.
To denote these, we attach a “delta” to the symbol for a scalar, vector, or matrix.
Notice that the “delta” touches the α, x, and A, so that, for example, δx is not mistaken for δ · x.
1 1
kyk = kAxk ≤ kAkkxk or, equivalently, ≤ kAk . (8.1)
kxk kyk
Also,
A(x + δx) = y + δy
implies that Aδx = δy so that δx = A−1 δy.
Ax = y
Hence
kδxk = kA−1 δyk ≤ kA−1 kkδyk. (8.2)
Combining (8.1) and (8.2) we conclude that
kδxk kδyk
≤ kAkkA−1 k .
kxk kyk
What does this mean? It means that the relative error in the solution is at worst the relative error in
the right-hand side, amplified by kAkkA−1 k. So, if that quantity is “small” and the relative error in the
right-hand size is “small” and exact arithmetic is used, then one is guaranteed a solution with a relatively
“small” error.
The quantity κk·k (A) = kAkkA−1 k is called the condition number of nonsingular matrix A (associated
with norm k · k).
Chapter 8. Notes on the Condition of a Problem 130
Are we overestimating by how much the relative error can be amplified? The answer to this is
no. For every nonsingular matrix A, there exists a right-hand side y and perturbation δy such that, if
A(x + δx) = y + δy,
kδxk kδyk
= kAkkA−1 k .
kxk kyk
In order for this equality to hold, we need to find y and δy such that
kAxk
kyk = kAxk = kAkkxk or, equivalently, kAk =
kxk
and
kA−1 δyk
kδxk = kA−1 δyk = kA−1 kkδyk. or, equivalently, kA−1 k = .
kδyk
In other words, x can be chosen as a vector that maximizes kAxk/kxk and δy should maximize kA−1 δyk/kδyk.
The vector y is then chosen as y = Ax.
What if we use the 2-norm? For this norm, κ2 (A) = kAk2 kA−1 k2 = σ0 /σn−1 . So, the ratio between the
largest and smallest singular value determines whether a matrix is well-conditioned or ill-conditioned.
To show for what vectors the maximal magnification is attained, consider the SVD
σ0
σ1 H
A = UΣV T = u0 u1 · · · un−1 v0 v1 · · · vn−1 .
..
.
σn−1
Recall that
• kA−1 k2 = 1/σn−1 , un−1 is the vector that maximizes maxkzk2 =1 kA−1 zk2 , and Avn−1 = σn−1 un−1 .
R2 : Domain of A. R2 : Codomain of A.
Figure 8.1: Illustration for choices of vectors y and δy that result in kδxk 2 σ0 kδyk2
kxk2 = σn−1 kyk2 . Because of the
eccentricity of the ellipse, the relatively small change δy relative to y is amplified into a relatively large
change δx relative to x. On the right, we see that kδyk2 /kyk2 = βσ1 /σ0 (since ku0 k2 = ku1 k2 = 1). On the
left, we see that kδxk2 /kxk = β (since kv0 k2 = kv1 k2 = 1).
Homework 8.1 Show that, if A is a nonsingular matrix, for a consistent matrix norm, κ(A) ≥ 1.
* SEE ANSWER
We conclude from this that we can generally only expect as much relative accuracy in the solution as
we had in the right-hand side.
Chapter 8. Notes on the Condition of a Problem 132
Alternative exposition Note: the below links conditioning of matrices to the relative condition number
of a more general function. For a more thorough treatment, you may want to read Lecture 12 of “Trefethen
and Bau”. That book discusses the subject in much more generality than is needed for our discussion of
linear algebra. Thus, if this alternative exposition baffles you, just skip it!
Let f : Rn → Rm be a continuous function such that f (y) = x. Let k · k be a vector norm. Consider for
y 6= 0
f k f (y + δy) − f (y)k kδyk
κ (y) = lim sup / .
δ→0 k f (y)k kyk
kδyk ≤ δ
(Obviously, if δy = 0 or y = 0 or f (y) = 0 , things get a bit hairy, so let’s not allow that.)
Roughly speaking, κ f (y) equals the maximum that a(n infitessimally) small relative error in y is mag-
nified into a relative error in f (y). This can be considered the relative condition number of function f . A
large relative condition number means a small relative error in the input (y) can be magnified into a large
relative error in the output (x = f (y)). This is bad, since small errors will invariable occur.
Now, if f (y) = x is the function that returns x where Ax = y for a nonsingular matrix A ∈ Cn×n , then
via an argument similar to what we did earlier in this section we find that κ f (y) ≤ κ(A) = kAkkA−1 k, the
condition number of matrix A:
k f (y + δy) − f (y)k kδyk
lim sup /
δ→0 k f (y)k kyk
kδyk ≤ δ
kA−1 (y + δy) − A−1 (y)k
kδyk
= lim sup /
δ→0 kA−1 yk kyk
kδyk ≤ δ
kA−1 (y + δy) − A−1 (y)k
kδyk
= lim max /
δ→0 kA−1 yk kyk
kzk = 1
δy = δ · z
kA−1 δyk
−1
kA yk
= lim max /
δ→0 kδyk kyk
kzk = 1
δy = δ · z
kA−1 δyk
kyk
= lim max
δ→0 kδyk kA−1 yk
kzk = 1
δy = δ · z
8.3. Condition Number of a Rectangular Matrix 133
kA −1 δyk kyk
= lim max
kδyk kA−1 yk
δ→0
kzk = 1
δy = δ · z
−1
kA (δ · z)k kyk
= lim max
δ→0 kδ · zk kA−1 yk
kzk = 1
δy = δ · z
−1
kA zk kyk
= max
kzk kA−1 yk
kzk = 1
−1
kA zk kAxk
= max
kzk kxk
kzk = 1
−1
kA zk kAxk
≤ max max
kzk kxk
kzk = 1 x 6= 0
= kAkkA−1 k,
where k · k is the matrix norm induced by vector norm k · k.
Figure 8.2: Linear least-squares problem kAx − yk2 = minv kAv − yk2 . Vector z is the projection of y onto
C (A).
and hence
1 kAk2
≤
kxk2 cos θkyk2
We conclude that
kδxk2 kAk2 k(AH A)−1 AH k2 kδyk2 1 σ0 kδyk2
≤ =
kxk2 cos θ kyk2 cos θ σn−1 kyk2
where σ0 and σn−1 are (respectively) the largest and smallest singular values of A, because of the following
result:
Homework 8.2 If A has linearly independent columns, show that k(AH A)−1 AH k2 = 1/σn−1 , where σn−1
equals the smallest singular value of A. Hint: Use the SVD of A.
* SEE ANSWER
The condition number of A ∈ Cm×n with linearly independent columns is κ2 (A) = σ0 /σn−1 .
Notice the effect of the cos θ. When y is almost perpendicular to C (A), then its projection z is small
and cos θ is small. Hence a small relative change in y can be greatly amplified. This makes sense: if y is
almost perpendical to C (A), then x ≈ 0, and any small δy ∈ C (A) can yield a relatively large change δx.
• Reason that using the method of normal equations to solve Ax = y has a condition number of κ2 (A)2 .
8.5. Why Multiplication with Unitary Matrices is a Good Thing 135
* SEE ANSWER
Let A ∈ Cm×n have linearly independent columns. If one uses the Method of Normal Equations to solve
the linear least-squares problem minx kAx−yk2 , one ends up solving the square linear system AH Ax = AH y.
Now, κ2 (AH A) = κ2 (A)2 . Hence, using this method squares the condition number of the matrix being used.
Thus,
k∆Ck2 = kA∆Bk2 ≤ kAk2 k∆Bk2 .
Also, B = A−1C so that
kBk2 = kA−1Ck2 ≤ kA−1 k2 kCk2
and hence
1 1
≤ kA−1 k2 .
kCk2 kBk2
Thus,
k∆Ck2 k∆Bk2 k∆Bk2
≤ kAk2 kA−1 k2 = κ2 (A) .
kCk2 kBk2 kBk2
This means that the relative error in matrix C = AB is at most κ2 (A) greater than the relative error in B.
The following exercise gives us a hint as to why algorithms that cast computation in terms of multipli-
cation by unitary matrices avoid the buildup of error:
This means is that the relative error in matrix C = UB is no greater than the relative error in B when U is
unitary.
Homework 8.6 Characterize the set of all square matrices A with κ2 (A) = 1.
* SEE ANSWER
Chapter 8. Notes on the Condition of a Problem 136
Chapter 9
Notes on the Stability of an Algorithm
Based on “Goal-Oriented and Modular Stability Analysis” [6, 7] by Paolo Bientinesi and Robert van de
Geijn.
Video
Read disclaimer regarding the videos in the preface!
* YouTube
* Download from UT Box
* View After Local Download
137
Chapter 9. Notes on the Stability of an Algorithm 138
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
9.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
9.2. Floating Point Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
9.3. Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
9.4. Floating Point Computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
9.4.1. Model of floating point computation . . . . . . . . . . . . . . . . . . . . . . . . 142
9.4.2. Stability of a numerical algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 143
9.4.3. Absolute value of vectors and matrices . . . . . . . . . . . . . . . . . . . . . . 143
9.5. Stability of the Dot Product Operation . . . . . . . . . . . . . . . . . . . . . . . . . . 144
9.5.1. An algorithm for computing D OT . . . . . . . . . . . . . . . . . . . . . . . . . 144
9.5.2. A simple start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
9.5.3. Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
9.5.4. Target result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
9.5.5. A proof in traditional format . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
9.5.6. A weapon of math induction for the war on error (optional) . . . . . . . . . . . . 149
9.5.7. Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.6. Stability of a Matrix-Vector Multiplication Algorithm . . . . . . . . . . . . . . . . . 152
9.6.1. An algorithm for computing G EMV . . . . . . . . . . . . . . . . . . . . . . . . 152
9.6.2. Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.7. Stability of a Matrix-Matrix Multiplication Algorithm . . . . . . . . . . . . . . . . . 154
9.7.1. An algorithm for computing G EMM . . . . . . . . . . . . . . . . . . . . . . . . 154
9.7.2. Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
9.7.3. An application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
9.1. Motivation 139
Figure 9.1: In this illustation, f : D → R is a function to be evaluated. The function fˇ represents the
implementation of the function that uses floating point arithmetic, thus incurring errors. The fact that
for a nearby value x̌ the computed value equals the exact function applied to the slightly perturbed x,
f (x̌) = fˇ(x), means that the error in the computation can be attributed to a small change in the input. If
this is true, then fˇ is said to be a (numerically) stable implementation of f for input x.
9.1 Motivation
Correctness in the presence of error (e.g., when floating point computations are performed) takes on a
different meaning. For many problems for which computers are used, there is one correct answer and we
expect that answer to be computed by our program. The problem is that most real numbers cannot be stored
exactly in a computer memory. They are stored as approximations, floating point numbers, instead. Hence
storing them and/or computing with them inherently incurs error. The question thus becomes “When is a
program correct in the presense of such errors?”
Let us assume that we wish to evaluate the mapping f : D → R where D ⊂ Rn is the domain and
R ⊂ Rm is the range (codomain). Now, we will let fˆ : D → R denote a computer implementation of this
function. Generally, for x ∈ D it is the case that f (x) 6= fˆ(x). Thus, the computed value is not “correct”.
From the Notes on Conditioning, we know that it may not be the case that fˆ(x) is “close to” f (x). After
all, even if fˆ is an exact implementation of f , the mere act of storing x may introduce a small error δx and
f (x + δx) may be far from f (x) if f is ill-conditioned.
The following defines a property that captures correctness in the presense of the kinds of errors that
are introduced by computer arithmetic:
Definition 9.1 Let given the mapping f : D → R, where D ⊂ Rn is the domain and R ⊂ Rm is the range
(codomain), let fˆ : D → R be a computer implementation of this function. We will call fˆ a (numerically)
stable implementation of f on domain D if for all x ∈ D there exists a x̂ “close” to x such that fˆ(x) = f (x̂).
Chapter 9. Notes on the Stability of an Algorithm 140
In other words, fˆ is a stable implementation if the error that is introduced is similar to that introduced
when f is evaluated with a slightly changed input. This is illustrated in Figure 9.1 for a specific input x. If
an implemention is not stable, it is numerically unstable.
• There is a largest number (in absolute value) that can be stored. Any number that is larger “over-
flows”. Typically, this causes a value that denotes a NaN (Not-a-Number) to be stored.
• There is a smallest number (in absolute value) that can be stored. Any number that is smaller
“underflows”. Typically, this causes a zero to be stored.
Notice that
√ n−1
kxk2 ≤ n max |χi |
i=0
and hence unless some χi is close to overflowing, the result will not overflow. The problem is that if
some element χi has the property that χ2i overflows, intermediate results in the computation in (9.1) will
overflow. The solution is to determine k such that
n−1
|χk | = maxi=0 |χi |
It can be argued that the same approach also avoids underflow if underflow can be avoided..
Now, in practice any base β can be used and floating point computation uses rounding rather than
truncating. A similar analysis can be used to show that then
|δχ| ≤ u|χ|
where u = 12 β1−t is known as the machine epsilon or unit roundoff. When using single precision or dou-
ble precision real arithmetic, u ≈ 10−8 or 10−16 , respectively. The quantity u is machine dependent; it is a
function of the parameters characterizing the machine arithmetic. The unit roundoff is often alternatively
defined as the maximum positive floating point number which can be added to the number stored as 1
without changing the number stored as 1. In the notation introduced below, fl(1 + u) = 1.
Homework 9.3 Assume a floating point number system with β = 2 and a mantissa with t digits so that a
typical positive number is written as .d0 d1 . . . dt−1 × 2e , with di ∈ {0, 1}.
• What is the largest positive real number u (represented as a binary fraction) such that the float-
ing point representation of 1 + u equals the floating point representation of 1? (Assume rounded
arithmetic.)
* SEE ANSWER
Chapter 9. Notes on the Stability of an Algorithm 142
9.3 Notation
When discussing error analyses, we will distinguish between exact and computed quantities. The function
fl(expression) returns the result of the evaluation of expression, where every operation is executed in
floating point arithmetic. For example, assuming that the expressions are evaluated from left to right,
fl(χ + ψ + ζ/ω) is equivalent to fl(fl(fl(χ) + fl(ψ)) + fl(fl(ζ)/fl(ω))). Equality between the quantities lhs
and rhs is denoted by lhs = rhs. Assignment of rhs to lhs is denoted by lhs := rhs (lhs becomes rhs). In
the context of a program, the statements lhs := rhs and lhs := fl(rhs) are equivalent. Given an assignment
κ := expression, we use the notation κ̌ (pronounced “check kappa”) to denote the quantity resulting from
fl(expression), which is actually stored in the variable κ.
The fact that the bounds that we establish can be easily converted into bounds involving norms is a
consequence of the following theorem, where k kF indicates the Frobenius matrix norm.
Theorem 9.11 Let A, B ∈ Rm×n . If |A| ≤ |B| then kAk1 ≤ kBk1 , kAk∞ ≤ kBk∞ , and kAkF ≤ kBkF .
κ := χ0 ψ0 + χ1 ψ1 .
Then, under the computational model given in Section 9.4, if κ := χ0 ψ0 + χ1 ψ1 is executed, the computed
result, κ̌, satisfies
T
χ0 ψ
κ̌ = 0
χ1 ψ1
= [χ0 ψ0 + χ1 ψ1 ]
= [[χ0 ψ0 ] + [χ1 ψ1 ]]
(0) (1)
= [χ0 ψ0 (1 + ε∗ ) + χ1 ψ1 (1 + ε∗ )]
(0) (1) (1)
= (χ0 ψ0 (1 + ε∗ ) + χ1 ψ1 (1 + ε∗ ))(1 + ε+ )
(0) (1) (1) (1)
= χ0 ψ0 (1 + ε∗ )(1 + ε+ ) + χ1 ψ1 (1 + ε∗ )(1 + ε+ )
9.5. Stability of the Dot Product Operation 145
κ := κ + χ1 ψ1
x y
xT 0 yT 0
← χ1 ,
← ψ1
xB yB
x2 y2
endwhile
T
(0) (1)
χ0 ψ0 (1 + ε∗ )(1 + ε+ )
=
(1) (1)
χ1 ψ1 (1 + ε∗ )(1 + ε+ )
T
(0) (1)
χ0 (1 + ε∗ )(1 + ε+ ) 0 ψ0
=
(1) (1)
χ1 0 (1 + ε∗ )(1 + ε+ ) ψ1
T
(0) (1)
χ0 (1 + ε∗ )(1 + ε+ ) ψ0
= (1) (1)
,
χ1 (1 + ε∗ )(1 + ε+ ) ψ1
κ := ((χ0 ψ0 + χ1 ψ1 ) + χ2 ψ2 ),
9.5.3 Preparation
Under the computational model given in Section 9.4, the computed result of (9.2), κ̌, satisfies
(0) (1) (1) (n−2)
κ̌ = (χ0 ψ0 (1 + ε∗ ) + χ1 ψ1 (1 + ε∗ ))(1 + ε+ ) + · · · (1 + ε+ )
(n−1) (n−1)
+ χn−1 ψn−1 (1 + ε∗ ) (1 + ε+ )
!
n−1 n−1
(i) ( j)
= ∑ χi ψi (1 + ε∗ ) ∏ (1 + ε+ ) , (9.3)
i=0 j=i
(0) (0) ( j) ( j)
where ε+ = 0 and |ε∗ |, |ε∗ |, |ε+ | ≤ u for j = 1, . . . , n − 1.
Clearly, a notation to keep expressions from becoming unreadable is desirable. For this reason we
introduce the symbol θ j :
Lemma 9.14 Let εi ∈ R, 0 ≤ i ≤ n − 1, nu < 1, and |εi | ≤ u. Then ∃ θn ∈ R such that
n−1
∏ (1 + εi)±1 = 1 + θn,
i=0
with |θn | ≤ nu/(1 − nu).
Proof: By Mathematical Induction.
Base case. n = 1. Trivial.
Inductive Step. The Inductive Hypothesis (I.H.) tells us that for all εi ∈ R, 0 ≤ i ≤ n − 1, nu < 1, and
|εi | ≤ u, there exists a θn ∈ R such that
n−1
∏ (1 + εi)±1 = 1 + θn, with |θn| ≤ nu/(1 − nu).
i=0
We will show that if εi ∈ R, 0 ≤ i ≤ n, (n + 1)u < 1, and |εi | ≤ u, then there exists a θn+1 ∈ R such
that
n
∏(1 + εi)±1 = 1 + θn+1, with |θn+1| ≤ (n + 1)u/(1 − (n + 1)u).
i=0
The quantity θn will be used throughout this note. It is not intended to be a specific number. Instead,
it is an order of magnitude identified by the subscript n, which indicates the number of error factors of the
form (1 + εi ) and/or (1 + εi )−1 that are grouped together to form (1 + θn ). Since the bound on |θn | occurs
often, we assign it a symbol as follows:
where |θ j | ≤ γ j , j = 2, . . . , n.
Two instances of the symbol θn , appearing even in the same expression, typically do not represent the
same number. For example, in (9.4) a (1 + θn ) multiplies each of the terms χ0 ψ0 and χ1 ψ1 , but these
two instances of θn , as a rule, do not denote the same quantity. In particular, One should be careful when
factoring out such quantities.
As part of the analyses the following bounds will be useful to bound error that accumulates:
The first two are backward error results (error is accumulated onto input parameters, showing that the
algorithm is numerically stable since it yields the exact output for a slightly perturbed input) while the last
one is a forward error result (error is accumulated onto the answer). We will see that in different situations,
a different error result may be needed by analyses of operations that require a dot product.
Let us focus on the second result. Ideally one would show that each of the entries of y is slightly
perturbed relative to that entry:
σ0 ψ0 σ0 · · · 0 ψ0
.. . .
= .. .. .. ..
δy =
. . . = Σy,
σn−1 ψn−1 0 · · · σn−1 ψn−1
where each σi is “small” and Σ = diag(()σ0 , . . . , σn−1 ). The following special structure of Σ, inspired
by (9.5) will be used in the remainder of this note:
0 × 0 matrix if n = 0
(n)
Σ = θ1 if n = 1 (9.6)
diag(()θn , θn , θn−1 , . . . , θ2 ) otherwise.
Homework 9.19 Let k ≥ 0 and assume that |ε1 |, |ε2 | ≤ u, with ε1 = 0 if k = 0. Show that
I +Σ (k) 0
(1 + ε2 ) = (I + Σ(k+1) ).
0 (1 + ε1 )
Hint: reason the case where k = 0 separately from the case where k > 0.
* SEE ANSWER
Theorem 9.20 Let x, y ∈ Rn and let κ := xT y be computed by executing the algorithm in Figure 9.2. Then
T
x0 y0
fl( ) = fl(fl(xT y0 ) + fl(χ1 ψ1 )) (definition)
0
χ1 ψ1
= fl(xT0 (I + Σ0 )y0 + fl(χ1 ψ1 )) (I.H. with xT = x0 ,
yT = y0 , and Σ0 = Σ(k) )
= x0T (I + Σ0 )y0 + χ1 ψ1 (1 + ε∗ ) (1 + ε+ )
(SCM, twice)
T
x0 (I + Σ0 ) 0 y
= (1 + ε+ ) 0 (rearrangement)
χ1 0 (1 + ε∗ ) ψ1
= xTT (I + ΣT )yT (renaming),
(I + Σ0 ) 0
where |ε∗ |, |ε+ | ≤ u, ε+ = 0 if k = 0, and (I + ΣT ) = (1 + ε+ ) so that ΣT =
0 (1 + ε∗ )
Σ(k+1) .
κ̌i+1 = κ̌i + χ1 ψ1 (1 + ε∗ ) (1 + ε+ )
SCM, twice
(ε+ = 0 if k = 0)
(k)
= x0T (I + Σ0 )y0 + χ1 ψ1 (1 + ε∗ ) (1 + ε+ )
Step 6: I.H.
T
(k)
κ := κ + χ1 ψ1 x0 I + Σ0 0 y0 8
= (1 + ε+ ) Rearrange
χ1 0 1 + ε∗ ψ1
T
x0 y0
= I + Σ(k+1) Exercise 9.19
χ1 ψ1
T
i+1
x
i+1 = 0 I + 0
Σ 0 y0
κ̌
i+1
χ1 0 σ1 ψ1
7
i+1
Σ0
0 x
(k+1) ∧ m 0 = (k + 1)
∧ = Σ
i+1
0 σ1 χ1
Continue
with
! x0 ! y0 ! Σi+1
0 0 0
xT yT ΣT 0 5b
← 1 , ← ψ1 , ← 0 σi+1
χ 1 0
xB yB 0 ΣB
x2 y 0 0 Σ
n 2 2
o
T (k)
κ̌ = xT (I + ΣT )yT ∧ ΣT = Σ ∧ m(xT ) = k 2c
endwhile
n o
κ̌ = xTT (I + ΣT )yT ∧ ΣT = Σ(k) ∧ m(xT ) = k ∧ m(xT ) = m(x) 2d
n o
κ̌ = xT (I + Σ(n) )y ∧ m(x) = n 1b
Figure 9.3: Error worksheet completed to establish the backward error result for the given algorithm that
computes the D OT operation.
9.5. Stability of the Dot Product Operation 151
The proof presented in Figure 9.3 goes hand in hand with the algorithm, as it shows that before and
after each iteration of the loop that computes κ := xT y, the variables κ̌, xT , yT , ΣT are such that the predicate
holds true. This relation is satisfied at each iteration of the loop, so it is also satisfied when the loop
completes. Upon completion, the loop guard is m(xT ) = m(x) = n, which implies that κ̌ = xT (I + Σ(n) )y,
i.e., the thesis of the theorem, is satisfied too.
In details, the inductive proof of Theorem 9.20 is captured by the error worksheet as follows:
Base case. In Step 2a, i.e. before the execution of the loop, predicate (9.7) is satisfied, as k = m(xT ) = 0.
Inductive step. Assume that the predicate (9.7) holds true at Step 2b, i.e., at the top of the loop. Then
Steps 6, 7, and 8 in Figure 9.3 prove that the predicate is satisfied again at Step 2c, i.e., the bottom
of the loop. Specifically,
By the Principle of Mathematical Induction, the predicate (9.7) holds for all iterations. In particular,
when the loop terminates, the predicate becomes
κ̌ = xT (I + Σ(n) )y ∧ n = m(xT ).
Definition 9.21 We call the predicate involving the operands and error operands in Steps 2a–d the error-
invariant for the analysis. This predicate is true before and after each iteration of the loop.
For any algorithm, the loop-invariant and the error-invariant are related in that the former describes the
status of the computation at the beginning and the end of each iteration, while the latter captures an error
result for the computation indicated by the loop-invariant.
The reader will likely think that the error worksheet is an overkill when proving the error result for the
dot product. We agree. However, it links a proof by induction to the execution of a loop, which we believe
is useful. Elsewhere, as more complex operations are analyzed, the benefits of the structure that the error
worksheet provides will become more obvious. (We will analyze more complex algorithms as the course
proceeds.)
Chapter 9. Notes on the Stability of an Algorithm 152
9.5.7 Results
A number of useful consequences of Theorem 9.20 follow. These will be used later as an inventory
(library) of error results from which to draw when analyzing operations and algorithms that utilize D OT.
Corollary 9.22 Under the assumptions of Theorem 9.20 the following relations hold:
R1-B: (Backward analysis) κ̌ = (x + δx)T y, where |δx| ≤ γn |x|, and κ̌ = xT (y + δy), where |δy| ≤ γn |y|;
Proof: We leave the proof of R1-B as an exercise. For R1-F, let δκ = xT Σ(n) y, where Σ(n) is as in
Theorem 9.20. Then
9.6.2 Analysis
Assume A ∈ Rm×n and partition
aT0 ψ0
aT ψ
1 1
A= . and .
.
.. .
.
aTm−1 ψm−1
9.6. Stability of a Matrix-Vector Multiplication Algorithm 153
ψ1 := aT1 x
x
y
xT 0 yT 0
← χ1 ,
← ψ1
xB yB
x2 y2
endwhile
Then
ψ0 aT0 x
ψ aT x
1 1
:= .
. ..
.. .
ψm−1 aTm−1 x
From Corollary 9.22 R1-B regarding the dot product we know that
ψ̌0 (a0 + δa0 )T x aT0 δaT0
ψ̌
1
(a1 + δa1 )T x aT
1
δaT
1
y̌ = . = = . + x = (A + ∆A)x,
.. .. .. .
..
.
ψ̌m−1 T
(am−1 + δam−1 ) x aTm−1 δaTm−1
Also, from Corollary 9.22 R1-F regarding the dot product we know that
ψ̌0 aT0 x + δψ0 aT0 δψ0
ψ̌ aT x + δψ aT δψ
1 1 1 1 1
y̌ = . = = . x+ = Ax + δy.
.. .
.. .. .
..
ψ̌m−1 aTm−1 x + δψm−1 aTm−1 δψm−1
9.7.2 Analysis
Partition
C= c0 c1 · · · cn−1 and B = b0 b1 · · · bn−1 .
Then
c0 c1 · · · cn−1 := Ab0 Ab1 · · · Abn−1 .
From Corollary 9.22 R1-B regarding the dot product we know that
č0 č1 · · · čn−1 = Ab0 + δc0 Ab1 + δc1 · · · Abn−1 + δcn−1
= Ab0 Ab1 · · · Abn−1 + δc0 δc1 · · · δcn−1
= AB + ∆C.
9.7. Stability of a Matrix-Matrix Multiplication Algorithm 155
c1 := Ab1
CL CR ← C0 c1 C2 , BL BR ← B0 b1 B2
endwhile
Theorem 9.26 (Forward) error results for matrix-matrix multiplication. Let C ∈ Rm×n , A ∈ Rm×k ,
and B ∈ Rk×n and consider the assignment C := AB implemented via the algorithm in Figure 9.5. Then
the following equality holds:
Homework 9.27 In the above theorem, could one instead prove the result
Č = (A + ∆A)(B + ∆B),
9.7.3 An application
A collaborator of ours recently implemented a matrix-matrix multiplication algorithm and wanted to check
if it gave the correct answer. To do so, he followed the following steps:
• He created random matrices A ∈ Rm×k , and C ∈ Rm×n , with positive entries in the range (0, 1).
• He computed C = AB with an implementation that was known to be “correct” and assumed it yields
the exact solution. (Of course, it has error in it as well. We discuss how he compensated for that,
below.)
• He computed ∆C = Č −C and checked that each of its entries satisfied δγi, j ≤ 2kuγi, j .
Chapter 9. Notes on the Stability of an Algorithm 156
• In the above, he took advantage of the fact that A and B had positive entries so that |A||B| = AB = C.
ku
He also approximated γk = 1−ku with ku, and introduced the factor 2 to compensate for the fact that
C itself was inexactly computed.
Chapter 10
Notes on Performance
How to attain high performance on modern architectures is of importance: linear algebra is fundamental
to scientific computing. Scientific computing often involves very large problems that require the fastest
computers in the world to be employed. One wants to use such computers efficiently.
For now, we suggest the reader become familiar with the following resources:
A similar exercise:
Michael Lehn
GEMM: From Pure C to SSE Optimized Micro Kernels
http://apfel.mathematik.uni-ulm.de/ lehn/sghpc/gemm/index.html.
157
Chapter 10. Notes on Performance 158
Chapter 11
Notes on Gaussian Elimination and LU
Factorization
The LU factorization is also known as the LU decomposition and the operations it performs are equivalent
to those performed by Gaussian elimination. For details, we recommend that the reader consult Weeks 6
and 7 of
Video
Read disclaimer regarding the videos in the preface!
Lecture on Gaussian Elimination and LU factorization:
* YouTube
* Download from UT Box
* View After Local Download
* YouTube
* Download from UT Box
* View After Local Download
* Slides
159
Chapter 11. Notes on Gaussian Elimination and LU Factorization 160
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
11.1. Definition and Existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
11.2. LU Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
11.2.1. First derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
11.2.2. Gauss transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
11.2.3. Cost of LU factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
11.3. LU Factorization with Partial Pivoting . . . . . . . . . . . . . . . . . . . . . . . . . . 165
11.3.1. Permutation matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
11.3.2. The algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
11.4. Proof of Theorem 11.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
11.5. LU with Complete Pivoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
11.6. Solving Ax = y Via the LU Factorization with Pivoting . . . . . . . . . . . . . . . . . 175
11.7. Solving Triangular Systems of Equations . . . . . . . . . . . . . . . . . . . . . . . . 175
11.7.1. Lz = y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
11.7.2. Ux = z . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
11.8. Other LU Factorization Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
11.8.1. Variant 1: Bordered algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
11.8.2. Variant 2: Left-looking algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 183
11.8.3. Variant 3: Up-looking variant . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
11.8.4. Variant 4: Crout variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
11.8.5. Variant 5: Classical LU factorization . . . . . . . . . . . . . . . . . . . . . . . . 185
11.8.6. All algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
11.8.7. Formal derivation of algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 185
11.9. Numerical Stability Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
11.10.Is LU with Partial Pivoting Stable? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
11.11.Blocked Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
11.11.1.Blocked classical LU factorization (Variant 5) . . . . . . . . . . . . . . . . . . . 188
11.11.2.Blocked classical LU factorization with pivoting (Variant 5) . . . . . . . . . . . 191
11.12.Variations on a Triple-Nested Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
11.1. Definition and Existence 161
The first question we will ask is when the LU factorization exists. For this, we need a definition.
Theorem 11.3 Existence Let A ∈ Cm×n and m ≤ n have linearly independent columns. Then A has a
unique LU factorization if and only if all its principle leading submatrices are nonsingular.
The proof of this theorem is a bit involved and can be found in Section 11.4.
11.2 LU Factorization
We are going to present two different ways of deriving the most commonly known algorithm. The first is
a straight forward derivation. The second presents the operation as the application of a sequence of Gauss
transforms.
• a21 = 0.
Example 11.5 Gauss transforms can be used to take multiples of a row and subtract these multiples from
other rows:
T a T T
1 0 0 0 ab0 b 0 a
b 0
0 T
a T T
1 0 0 a
1
b b 1 a
b 1
= = .
0 −λ 1 0 a T a T λ
T
a − λ a T
21 2 2 − 21 abT 2
b b b 21 1
b
1
0 −λ31 0 1 abT3 abT3 λ31 abT3 − λ31 abT1
Notice the similarity with what one does in Gaussian Elimination: take a multiples of one row and subtract
these from other rows.
Now assume that the LU factorization in the previous subsection has proceeded to where A contains
A a01 A02
00
0 α11 a12 T
0 a21 A22
Repartition
A a01 A02 L 0 0
AT L AT R 00 00
LT L LT R
→ aT α11 aT
, → l T λ11 0
10 12 10
ABL ABR LBL LBR
A20 a21 A22 L20 l21 L22
whereα11 , λ11 are 1 × 1
l21 := a21 /α11
A22 := A22 − l21 aT12
(a21 := 0)
or, alternatively,
l21 := a21 /α11
A a01 A02 I 0 0 A00 a01 A02
00
0 α11 aT12 := 0 0 α11 aT12
0 1
0 a21 A22 0 −l21 0 0 a21 A22
A00 a01 A02
= 0 α11
T
a12
0 0 A22 − l21 aT12
Continue with
A a A02 L 0 0
AT L AT R 00 01 0 00
LT L
← aT α11 aT
, ← l T λ11 0
10 12 10
ABL ABR LBL LBR
A20 a21 A22 L20 l21 L22
endwhile
Figure 11.1: Most commonly known algorithm for overwriting a matrix with its LU factorization.
Chapter 11. Notes on Gaussian Elimination and LU Factorization 164
The resulting algorithm is summarized in Figure 11.1 under “or, alternatively,”. Notice that this algorithm
is identical to the algorithm for computing LU factorization discussed before!
How can this be? The following set of exercises explains it.
* SEE ANSWER
Now, clearly, what the algorithm does is to compute a sequence of n Gauss transforms L b0 , . . . , L
bn−1
−1
such that Ln−1 Ln−2 · · · L1 L0 A = U. Or, equivalently, A = L0 L1 · · · Ln−2 Ln−1U, where Lk = Lk . What
b b b b b
will show next is that L = L0 L1 · · · Ln−2 Ln−1 is the unit lower triangular matrix computed by the LU
factorization.
L 0 0
00
T
Homework 11.7 Let L̃k = L0 L1 . . . Lk . Assume that L̃k has the form L̃k−1 = l10 1 0 , where L̃00
L20 0 I
L00 0 0 I 0 0
is k × k. Show that L̃k is given by L̃k = l10 1 0 .. (Recall: Lk = 0
T
0 .)
b 1
L20 l21 I 0 −l21 I
* SEE ANSWER
What this exercise shows is that L = L0 L1 · · · Ln−2 Ln−1 is the triangular matrix that is created by simply
placing the computed vectors l21 below the diagonal of a unit lower triangular matrix.
• Assume A is n × n.
• Computing l21 := a21 /α11 is typically implemented as β := 1/α11 and then the scaling l21 := βa21 .
The reason is that divisions are expensive relative to multiplications. We will ignore the cost of the
division (which will be insignificant if n is large). Thus, we count this as n − k − 1 multiplies.
• The rank-1 update of A22 requires (n − k − 1)2 multiplications and (n − k − 1)2 additions.
n−1 n−1
2
j + 2 j2
∑ (n − k − 1) + 2(n − k − 1) = ∑ (Change of variable: j = n − k − 1)
k=0 j=0
n−1 n−1
= ∑ j + 2 ∑ j2
j=0 j=0
n(n − 1) n Z
≈ +2 x2 dx
2 0
n(n − 1) 2 3
= + n
2 3
2 3
≈ n
3
Notice that this involves roughly half the number of floating point operations as are required for a House-
holder transformation based QR factorization.
(This is the backward error result for the Crout variant for LU factorization, discussed later in this note.
Some of the other variants have an error result of (A + ∆A) = ĽǓ where |∆A| ≤ γn (|A| + |Ľ||Ǔ|).) Now, if
α is small in magnitude compared to the entries of a21 then not only will l21 have large entries, but the
update A22 − l21 aT12 will potentially introduce large entries in the updated A22 (in other words, the part of
matrix A from which the future matrix U will be computed), a phenomenon referred to as element growth.
To overcome this, we take will swap rows in A as the factorization proceeds, resulting in an algorithm
known as LU factorization with partial pivoting.
Repartition
A00 a01 A02 L00 0 0 p0
AT L AT R
LT L LT R T
pT
→ T T
a10 α11 a12 , → l10 λ11 0 , → π1
ABL ABR LBL LBR pB
A20 a21 A22 L20 l21 L22 p2
whereα11 , λ11 , π1 are 1 × 1
α11
π1 = maxi
a21
α aT α aT
11 12 := P(π1 ) 11 12
a21 A22 a21 A22
l21 := a21 /α11
A22 := A22 − l21 aT12
(a21 := 0)
Continue with
A a A L 0 0 p
AT L AT R 00 01 02 LT L 0 00 p T
0
← aT α11 aT ,
← l T λ11 0 , ← π1
10 12 10
ABL ABR LBL LBR pB
A20 a21 A22 L20 l21 L22 p2
endwhile
If P is a permutation matrix then PA rearranges the rows of A exactly as the elements of x are rearranged
by Px.
We will see that when discussing the LU factorization with partial pivoting, a permutation matrix that
swaps the first element of a vector with the π-th element of that vector is a fundamental tool. We will
denote that matrix by
In if π = 0
0 0 1 0
P(π) =
0 I 0 0
π−1
otherwise,
1 0 0 0
0 0 0 In−π−1
where n is the dimension of the permutation matrix. In the following we will use the notation Pn to indicate
that the matrix P is of size n. Let p be a vector of integers satisfying the conditions
Remark 11.9 In the algorithms, the subscript that indicates the matrix dimensions is omitted.
Example 11.10 Let aT0 , aT1 , . . . , aTn−1 be the rows of a matrix A. The application of P(p) to A yields a
matrix that results from swapping row aT0 with aTπ0 , then swapping aT1 with aTπ1 +1 , aT2 with aTπ2 +2 , until
finally aTk−1 is swapped with aTπk−1 +k−1 .
Remark 11.11 For those familiar with how pivot information is stored in LINPACK and LAPACK, notice
that those packages store the vector of pivot information (π0 + 1, π1 + 2, . . . , πk−1 + k)T .
[A, p] := LUpivA,
• Partition A, L as follows:
α11 aT12 1 0
A→ , and L → .
a21 A22 l21 L22
α11
• Compute π1 = maxi .
a21
α11 aT12 α11 aT12
• Permute the rows: := P(π1 ) .
a21 A22 a21 A22
Now, in general, assume that the computation has proceeded to the point where matrix A has been
overwritten by
A a01 A02
00
aT12
0 α11
0 a21 A22
where A00 is upper triangular. If no pivoting was added one would compute l21 := a21 /α11 followed by
the update
A00 a01 A02 I 0 0 A00 a01 A02 A00 a01 A02
aT12 := 0 aT12 = 0 aT12 .
0 α11 1 0 0 α11 α11
0 a21 A22 0 −l21 I 0 a21 A22 0 0 A22 − l21 aT12
• Update
A a01 A02 I 0 0 A a01 A02 A a01 A02
00 00 00
0 α11 aT12 := 0 0 0 α11 aT12 = 0 aT12 .
1 α11
0 a21 A22 0 −l21 I 0 a21 A22 0 0 A22 − l21 aT12
or, equivalently,
A = P0T L0 · · · Pbn−1
T
Ln−1U,
b−1 . What we will finally show is that there are Gauss transforms L0 , . . . Ln−1 (here the “bar”
where Lk = Lk
does NOT mean conjugation. It is just a symbol) such that
A = P0T · · · Pn−1
T
L0 · · · Ln−1 U
| {z }
L
or, equivalently,
P(p)A = Pn−1 · · · P0 A = L0 · · · Ln−1 U,
| {z }
L
which is what we set out to compute.
Here is the insight. Assume that after k steps of LU factorization we have computed pT , LT L , LBL , etc.
so that
LT L 0 A AT R
P(pT )A = TL ,
LBL I 0 ABR
where AT L is upper triangular and k × k.
AT L AT R
Now compute the next step of LU factorization with partial pivoting with :
0 ABR
• Partition
A00 a01 A02
AT L AT R
→
0 α11 aT12
0 ABR
0 a01 A02
α11
• Compute π1 = maxi
a21
Chapter 11. Notes on Gaussian Elimination and LU Factorization 170
Repartition
A00 a01 A02 L00 0 0 p0
AT L AT R LT L LT R
pT
→ aT10 α11 aT12 ,
→ T λ
l10 11 0 , → π1
ABL ABR LBL LBR pB
A20 a21 A22 L20 l21 L22 p2
whereα11 , λ11 , π1 are 1 × 1
α11
π1 = maxi
a21
A a A A a A
00 01 02 I 0 00 01 02
T
l10 α11 aT12 := l T α11 aT
10 12
0 P(π1 )
L20 a21 A22 L20 a21 A22
l21 := a21 /α11
A a A I 0 0 A a A A a A02
00 01 02 00 01 02 00 01
0 α11 aT12 := 0 1 0 0 α11 aT12 = 0 α11 aT12
0 a21 A22 0 −l21 0 0 a21 A22 T
0 0 A22 − l21 a12
Continue with
A00 a01 A02 L00 0 0 p0
AT L AT R LT L 0 T pT
← T T
a10 α11 a12 , ← l10 λ11 0 , ← π1
ABL ABR LBL LBR pB
A20 a21 A22 L20 l21 L22 p2
endwhile
Repartition
A a01 A02 p
AT L AT R 00 0
pT
→ aT α11 aT
, → π1
ABL ABR 10 12 pB
A20 a21 A22 p2
whereα11 , λ11 , π1 are 1 × 1
α11
π1 = maxi
a21
aT10 α11 aT12 aT10 α11 aT12
:= P(π1 )
A20 a21 A22 A20 a21 A22
a21 := a21 /α11
A22 := A22 − a21 aT12
Continue with
A00 a01 A02 p0
AT L AT R
pT
aT10 α11
← aT12 , ←
π1
ABL ABR pB
A20 a21 A22 p2
endwhile
Figure 11.4: LU factorization with partial pivoting, overwriting A with the factors.
A a01 A02 A a01 A02
00 0 00
I
• Permute 0 α11 aT12 := aT12
0
α11
0 P(π1 )
0 a21 A22 0 a21 A22
• Update
A a01 A02 A a01 A02
00 00
0 α11 aT12 := 0 aT12
α11
0 a21 A22 0 0 A22 − l21 aT12
After this,
I 0 0 A a01 A02
LT L 0 I 0 00
P(pT )A = aT12 (11.2)
0 1 0 0 α11
LBL I 0 P(π1 )
0 l21 I 0 0 A22 − l21 aT12
But
I 0 0
A a01 A02
LT L 0 I 0 00
aT12
0 1 0 0 α11
LBL I 0 P(π1 )
0 l21 I 0 0 A22 − l21 aT12
I 0 0 A a01 A02
I 0 LT L 0 00
= aT12
0 1 0 0 α11
0 P(π1 ) P(π1 )LBL I
0 l21 I 0 0 A22 − l21 aT12
I 0 0 A00 a01 A02
I 0 L 0
= TL 0 1 0
0 α11 T
a12 ,,
0 P(π1 ) LBL I
0 l21 I 0 0 A22 − l21 aT12
NOTE: There is a “bar” above some of L’s and l’s. Very hard to see!!! For this reason, these show
up in red as well. Here we use the fact that P(π1 ) = P(π1 )T because of its very special structure.
Bringing the permutation to the left of (11.2) and “repartitioning” we get
L 0 0 I 0 0 A a01 A02
I 0 00 00
P(p0 ) A = l T 1 0 0 1 0 0 α11
T
a12 .
10
0 P(π1 )
T
| {z } L 20 0 I 0 l21 I 0 0 A 22 − l a
21 12
p0
| {z }
P L 0 0
π1 00
T
l 10 1 0
L20 l21 I
This explains how the algorithm in Figure 11.3 compute p, L, and U (overwriting A with U) so that
P(p)A = LU.
Finally, we recognize that L can overwrite the entries of A below its diagonal, yielding the algorithm
in Figure 11.4.
11.4. Proof of Theorem 11.3 173
Now, by the Induction Hypothesis L11 , l10T , and L exist and are unique. So the question is whether
20
u01 , υ11 , and l21 exist and are unique:
• u01 exists and is unique. Since L00 is nonsingular (it has ones on its diagonal) L00 u01 = a01
has a solution that is unique.
• υ11 exists, is unique, and is nonzero. Since l10T and u exist and are unique, υ = α −l T u
01 11 11 10 01
exists and is unique. It is also nonzero since the principle leading submatrix of A given by
A a01 L 0 U u01
00 = 00 00 ,
T
a10 α11 T
l10 1 0 υ11
Homework 11.12 Implement LU factorization with partial pivoting with the FLAME@lab API, in M-
script.
* SEE ANSWER
Now, instead of finding the largest element in magnitude in the first column, find the largest element in
magnitude in the entire matrix. Let’s say it is element (π0 , ρ0 ). Then, one permutes
α11 aT12 α11 aT12
:= P(π0 ) P(ρ0 )T ,
a21 A22 a21 A22
making α11 the largest element in magnitude. This then reduces the magnitude of multipliers and element
growth.
11.6. Solving Ax = y Via the LU Factorization with Pivoting 175
It can be shown that the maximal element growth experienced when employing LU with complete
pivoting indeed reduces element growth. The problem is that it requires O(n2 ) comparisons per itera-
tion. Worse, it completely destroys the ability to utilize blocked algorithms, which attain much greater
performance.
In practice LU with complete pivoting is not used.
PAx = Py
|{z}
yb
Lz = yb
Ux = z.
11.7.1 Lz = y
First, we discuss solving Lz = y where L is a unit lower triangular matrix.
Variant 1
y2 := y2 − ψ1 l21 T y
ψ1 := ψ1 − l10 0
Figure 11.5: Algorithms for the solution of a unit lower triangular system Lz = y that overwrite y with z.
11.7. Solving Triangular Systems of Equations 177
Then
1 0 ζ1 ψ1
= .
l21 L22 z2 y2
| {z } | {z } | {z }
L z y
Multiplying out the left-hand side yields
ζ1 ψ1
=
ζ1 l21 + L22 z2 y2
Variant 2
Then
L00 0 z0 y0
= .
T
l10 1 ζ1 ψ1
| {z } | {z } | {z }
L z y
Multiplying out the left-hand side yields
L00 z0 y0
=
T z +ζ
l10 ψ1
0 1
Discussion
Notice that Variant 1 casts the computation in terms of an AXPY operation while Variant 2 casts it in terms
of DOT products.
11.7.2 Ux = z
Next, we discuss solving Ux = y where U is an upper triangular matrix (with no assumptions about its
diagonal entries).
Homework 11.13 Derive an algorithm for solving Ux = y, overwriting y with the solution, that casts
most computation in terms of DOT products. Hint: Partition
υ11 u12 T
U → .
0 U22
Call this Variant 1 and use Figure 11.6 to state the algorithm.
* SEE ANSWER
Homework 11.14 Derive an algorithm for solving Ux = y, overwriting y with the solution, that casts most
computation in terms of AXPY operations. Call this Variant 2 and use Figure 11.6 to state the algorithm.
* SEE ANSWER
A=A
b
• We wish to overwrite A with L and U. Thus, the postcondition for the algorithm (the state in which
we wish to exit the algorithm) is that
A = L\U ∧ LU = A
b
(A is overwritten by L below the diagonal and U on and above the diagonal, where multiplying L
and U yields the original matrix A.)
1 Fora thorough discussion of the different LU factorization algorithms that also gives a historic perspective, we recommend
“Matrix Algorithms Volume 1“ by G.W. Stewart [34]
11.8. Other LU Factorization Algorithms 179
Figure 11.6: Algorithms for the solution of an upper triangular system Ux = y that overwrite y with x.
Chapter 11. Notes on Gaussian Elimination and LU Factorization 180
• All the algorithms will march through the matrices from top-left to bottom-right. Thus, at a repre-
sentative point in the algorithm, the matrices are viewed as quadrants:
AT L AT R LT L 0 UT L UT R
A→ , L → , and U → .
ABL ABR LBL LBR 0 UBR
where AT L , LT L , and UT L are all square and equally sized.
• In terms of these exposed quadrants, in the end we wish for matrix A to contain
A AT R L\UT L UT R
TL =
ABL ABR L L\UBR
BL
LT L 0 UT L UT R AbT L AbT R
where =
LBL LBR 0 UBR ABL ABR
b b
• Manipulating this yields what we call the Partitioned Matrix Expression (PME), which can be
viewed as a recursive definition of the LU factorization:
A AT R L\UT L UT R
TL =
ABL ABR LBL L\UBR
LT LUT L = A
bT L LT LUT R = A
bT R
∧
LBLUT L = AbBL LBLUT R + LBRUBR = A bBR
Now, consider the code skeleton for the LU factorization in Figure 11.7. At the top of the loop
(right after the while), we want to maintain certain contents in matrix A. Since we are in a loop, we
haven’t yet overwritten A with the final result. Instead, some progress toward this final result have
been made. The way we can find what the state of A is that we would like to maintain is to take the
PME and delete subexpression. For example, consider the following condition on the contents of A:
AT L AT R L\UT L UT R
=
ABL ABR LBL ABR − LBLUT R
b
.
LT LUT L = A
bT L LT LUT R = AbT R
∧ ((
((((
LBLUT L = AbBL LBLU
(((T R
( +
( L
( (U
BR BR = A
b BR
What we are saying is that AT L , AT R , and ABL have been completely updated with the corresponding
parts of L and U, and ABR has been partially updated. This is exactly the state that the algorithm
that we discussed previously in this document maintains! What is left is to factor ABR , since it
contains AbBR − LBLUT R , and A
bBR − LBLUT R = LBRUBR .
• By carefully analyzing the order in which computation must occur (in compiler lingo: by performing
a dependence analysis), we can identify five states that can be maintained at the top of the loop, by
deleting subexpressions from the PME. These are called loop invariants and are listed in Figure 11.8.
• Key to figuring out what updates must occur in the loop for each of the variants is to look at how the
matrices are repartitioned at the top and bottom of the loop body.
11.8. Other LU Factorization Algorithms 181
Algorithm: A := LU(A)
AT L AT R LT L LT R UT L UT R
Partition A → ,L→ ,U →
ABL ABR LBL LBR UBL UBR
whereAT L is 0 × 0, LT L is 0 × 0, UT L is 0 × 0
while m(AT L ) < m(A) do
Repartition
A00 a01 A02 L00 l01 L02
AT L AT R LT L LT R
→ aT10 α11 aT12 ,
→ T
l10 T
λ11 l12 ,
ABL ABR LBL LBR
A20 a21 A22 L20 l21 L22
U00 u01 U02
U UT R
TL → T
u10 υ11 u12 T
UBL UBR
U20 u21 U22
• whereα11 is 1 × 1, λ11 is 1 × 1, υ11 is 1 × 1
Continue with
A a01 A02 L l L02
AT L AT R 00 00 01
LT L LT R
← aT
α11 aT12 , ← l T λ11
T
l12 ,
ABL ABR 10 LBL LBR 10
A a21 A22 L20 l21 L22
20
U u01 U02
UT L UT R 00
← uT
υ11 uT12
10
UBL UBR
U20 u21 U22
endwhile
L\U00 ab01 A
b02
abT10 b 11 abT12
α
Ab20 ab21 Ab22
L00U00 = A
b00 L00 u01 = ab01 L00U02 = A
b02
TU =a
l10 bT10 T u +υ = α
l10 T U + uT = a
l10 bT12
00 01 11 b 11 02 12
L20U00 = A
b20 L20 u01 + υ11 l21 = ab21 L20U02 + l21 uT12 + L22U22 = A
b22
where the entries in red are already known. The equalities in yellow can be used to compute the desired
parts of L and U:
• Solve L00 u01 = a01 for u01 , overwriting a01 with the result.
T U = aT (or, equivalently, U T (l T )T = (aT )T for l T ), overwriting aT with the result.
• Solve l10 00 10 00 10 10 10 10
T u , overwriting α with the result.
• Compute υ11 = α11 − l10 01 11
Homework 11.15 If A is an n × n matrix, show that the cost of Variant 1 is approximately 23 n3 flops.
* SEE ANSWER
L\U00 ab01 A
b02
T
l10 b 11 abT12
α
L20 ab21 Ab22
L00U00 = A
b00 L00 u01 = ab01 L00U02 = A
b02
TU =a
l10 bT10 T u +υ = α
l10 T U + uT = a
l10 bT12
00 01 11 b 11 02 12
L20U00 = A
b20 L20 u01 + υ11 l21 = ab21 L20U02 + l21 uT12 + L22U22 = A
b22
The equalities in yellow can be used to compute the desired parts of L and U:
• Solve L00 u01 = a01 for u01 , overwriting a01 with the result.
T u , overwriting α with the result.
• Compute υ11 = α11 − l10 01 11
• Compute l21 := (a21 − L20 u01 )/υ11 , overwriting a21 with the result.
L00U00 = A
b00 L00 u01 = ab01 L00U02 = A
b02
TU =a
l10 bT10 T u +υ = α
l10 T U + uT = a
l10 bT12
00 01 11 b 11 02 12
L20U00 = A
b20 L20 u01 + υ11 l21 = ab21 L20U02 + l21 uT12 + L22U22 = A
b22
The equalities in yellow can be used to compute the desired parts of L and U:
• Compute l21 := (α21 − L20 u01 )/υ11 , overwriting a21 with the result.
Homework 11.17 Implement all five LU factorization algorithms with the FLAME@lab API, in M-script.
* SEE ANSWER
Homework 11.18 Which of the five variants can be modified to incorporate partial pivoting?
* SEE ANSWER
Repartition
A a01 A02
AT L AT R 00
→ aT
α11 aT12
10
ABL ABR
A20 a21 A22
whereα11 is 1 × 1
A00 contains L00 and U00 in its strictly lower and upper triangular part, re-
spectively.
Variant 1 Variant 2 Variant 3 Variant 4 Variant 5
Bordered Left-looking Up-looking Crout variant Classical LU
−1 −1
a01 := L00 a01 a01 := L00 a01 Exercise in 11.16
−1
aT10 := aT10U00
α11 := α11 − aT21 a01 α11 := α11 − aT21 a01 α11 := α11 − aT21 a01
aT12 := aT12 − aT10 A02
a21 := a21 − A20 a01 a21 := a21 − A20 a01
a21 := a21 /α11 a21 := a21 /α11 a21 := a21 /α11
A22 := A22 − a21 aT12
Continue with
A00 a01 A02
AT L AT R
aT10 α11
← aT12
ABL ABR
A20 a21 A22
endwhile
Theorem 11.19 Let A ∈ Rn×n and let the LU factorization of A be computed via the Crout variant (Variant
4), yielding approximate factors Ľ and Ǔ. Then
Theorem 11.20 Let L ∈ Rn×n be lower triangular and y, z ∈ Rn with Lz = y. Let ž be the approximate
solution that is computed. Then
Theorem 11.21 Let U ∈ Rn×n be upper triangular and x, z ∈ Rn with Ux = z. Let x̌ be the approximate
solution that is computed. Then
Theorem 11.22 Let A ∈ Rn×n and x, y ∈ Rn with Ax = y. Let x̌ be the approximate solution computed via
the following steps:
The analysis of LU factorization without partial pivoting is related that of LU factorization with partial
pivoting. We have shown that LU with partial pivoting is equivalent to the LU factorization without partial
pivoting on a pre-permuted matrix: PA = LU, where P is a permutation matrix. The permutation doesnt
involve any floating point operations and therefore does not generate error. It can therefore be argued that,
as a result, the error that is accumulated is equivalent with or without partial pivoting
Chapter 11. Notes on Gaussian Elimination and LU Factorization 188
From this exercise we conclude that even LU factorization with partial pivoting can yield large (exponen-
tial) element growth in U. You may enjoy the collection of problems for which Gaussian elimination with
partial pivoting in unstable by Stephen Wright [46].
In practice, this does not seem to happen and LU factorization is considered to be stable.
Algorithm: A := LU(A)
AT L AT R
Partition A →
ABL ABR
whereAT L is 0 × 0
while m(AT L ) < m(A) do
Determine block size b
Repartition
A A01 A02
AT L AT R 00
→ A10
A11 A12
ABL ABR
A20 A21 A22
whereA11 is b × b
A00 contains L00 and U00 in its strictly lower and upper triangular part, re-
spectively.
Variant 1: Variant 2: Variant 3:
A01 := L00 −1 A01 A01 := L00 −1 A01 A10 := A10U00 −1
A10 := A10U00 −1 A11 := A11 − A10 A01 A11 := A11 − A10 A01
A11 := A11 − A10 A01 A11 := LUA11 A11 := LUA11
A11 := LUA11 A21 := (A21 − A20 A01 )U11 −1A12 := A12 − A10 A02
Variant 4: Variant 5:
A11 := A11 − A10 A01 A11 := LUA11
A11 := LUA11 A21 := A21U11 −1
−1
A21 := (A21 − A20 A01 )U11 A12 := L11 −1 A12
A12 := L11 −1 (A12 − A10 A02 )A22 := A22 − A21 A12
Continue with
A A01 A02
AT L AT R 00
←
A10 A11 A12
ABL ABR
A20 A21 A22
endwhile
Continue with
A00 A01 A02 p0
AT L AT R p
T ← p1
← A10 A11 ,
A12
ABL ABR pB
A20 A21 A22 p2
endwhile
Figure 11.11: Blocked algorithms for computing the LU factorization with partial pivoting.
.
11.11. Blocked Algorithms 191
or, equivalently,
A11 = L11U11 A12 = L11U12
.
A21 = L21U11 A22 − L21U12 = L22U22
If we let L and U overwrite the original matrix A this suggests the algorithm
• Compute the LU factorization A11 = L11U11 , overwriting A11 with L\U11 . Notice that any of the
“unblocked” algorithms previously discussed in this note can be used for this factorization.
−1
• Solve L11U12 = A12 , overwriting A12 with U12 . (This can also be expressed as A12 := L11 A12 .)
−1
• Solve L21U11 = A21 , overwiting A21 with U21 . (This can also be expressed as A21 := A21U11 .)
If b is small relative to n, then most computation is in the last step, which is a matrix-matrix multiplication.
Similarly, blocked algorithms for the other variants can be derived. All are given in Figure 11.10.
where A00 , L00 , and U00 are k × k, and A11 , L11 , and U11 are b × b.
Assume that the computation has proceeded to the point where A contains
A A01 A02 L\U00 U01 U02
00
A10 A11 A12 = L10 b11 − L10U01 A12 − L10U02 ,
A
A20 A21 A22 L20 b21 − L20U01 A22 − L20U02
A
where, as before, A
b denotes the original contents of A and
A A01 A02 L 0 0 U U01 U02
00 00 00
b b b
P(p0 ) A10 A b12 = L10 I 0 0 A11 A12 .
b b11 A
Ab20 A b21 A b22 L20 0 I 0 A21 A22
A11
• Compute the LU factorization with pivoting of the “current panel” :
A21
A11 L11
P(p1 ) = U11 ,
A21 L21
• Solve L11U12 = A12 , overwriting A12 with U12 . (This can also be more concisely written as A12 :=
−1
L11 A12 .)
Careful consideration shows that this puts the matrix A in the state
A00 A01 A02 L\U00 U01 U02
A10 A11 A12 = L10 L\U11 U12 ,
A20 A21 A22 L20 L21 b22 − L20U02 − L21U12
A
where
A A
b01 A L00 0 0 U00 U01 U02
00
b b02
p0
P( )
A A
b11 A = L10
L11
0 0 U11 U12 .
10
b b12
p1
A
b20 A
b21 A
b22 L20 L21 I 0 0 A22
Similarly, blocked algorithms with pivoting for some of the other variants can be derived. All are given
in Figure 11.10.
All LU factorization algorithms presented in this note perform exactly the same floating point operations
(with some rearrangement of data thrown in for the algorithms that perform pivoting) as does the triple-
nested loop that implements Gaussian elimination:
11.12. Variations on a Triple-Nested Loop 193
Video
Read disclaimer regarding the videos in the preface!
* YouTube
* Download from UT Box
* View After Local Download
195
Chapter 12. Notes on Cholesky Factorization 196
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
12.1. Definition and Existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
12.2. Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
12.3. An Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
12.4. Proof of the Cholesky Factorization Theorem . . . . . . . . . . . . . . . . . . . . . . 199
12.5. Blocked Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
12.6. Alternative Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
12.7. Cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
12.8. Solving the Linear Least-Squares Problem via the Cholesky Factorization . . . . . . 204
12.9. Other Cholesky Factorization Algorithms . . . . . . . . . . . . . . . . . . . . . . . 204
12.10.Implementing the Cholesky Factorization with the (Traditional) BLAS . . . . . . . 206
12.10.1.What are the BLAS? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
12.10.2.A simple implementation in Fortran . . . . . . . . . . . . . . . . . . . . . . . . 209
12.10.3.Implemention with calls to level-1 BLAS . . . . . . . . . . . . . . . . . . . . . 209
12.10.4.Matrix-vector operations (level-2 BLAS) . . . . . . . . . . . . . . . . . . . . . 209
12.10.5.Matrix-matrix operations (level-3 BLAS) . . . . . . . . . . . . . . . . . . . . . 213
12.10.6.Impact on performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
12.11.Alternatives to the BLAS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
12.11.1.The FLAME/C API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
12.11.2.BLIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
12.1. Definition and Existence 197
Definition 12.1 A matrix A ∈ Cm×m is Hermitian positive definite (HPD) if and only if it is Hermitian
(AH = A) and for all nonzero vectors x ∈ Cm it is the case that xH Ax > 0. If in addition A ∈ Rm×m then A
is said to be symmetric positive definite (SPD).
(If you feel uncomfortable with complex arithmetic, just replace the word “Hermitian” with “Symmetric”
in this document and the Hermitian transpose operation, H , with the transpose operation, T .
Example 12.2 Consider the case where m = 1 so that A is a real scalar, α. Notice that then A is SPD if
and only if α > 0. This is because then for all nonzero χ ∈ R it is the case that αχ2 > 0.
Homework 12.3 Let B ∈ Cm×n have linearly independent columns. Prove that A = BH B is HPD.
* SEE ANSWER
Homework 12.4 Let A ∈ Cm×m be HPD. Show that its diagonal elements are real and positive.
* SEE ANSWER
Theorem 12.5 (Cholesky Factorization Theorem) Given a HPD matrix A there exists a lower triangular
matrix L such that A = LLH .
Obviously, there similarly exists an upper triangular matrix U such that A = U H U since we can choose
U H = L.
The lower triangular matrix L is known as the Cholesky factor and LLH is known as the Cholesky
factorization of A. It is unique if the diagonal elements of L are restricted to be positive.
The operation that overwrites the lower triangular part of matrix A with its Cholesky factor will be
denoted by A := CholA, which should be read as “A becomes its Cholesky factor.” Typically, only the
lower (or upper) triangular part of A is stored, and it is that part that is then overwritten with the result. In
this discussion, we will assume that the lower triangular part of A is stored and overwritten.
12.2 Application
The Cholesky factorization is used to solve the linear system Ax = y when A is HPD: Substituting the
factors into the equation yields LLH x = y. Letting z = LH x,
Ax = L (LH x) = Lz = y.
| {z }
z
Thus, z can be computed by solving the triangular system of equations Lz = y and subsequently the desired
solution x can be computed by solving the triangular linear system LH x = z.
Chapter 12. Notes on Cholesky Factorization 198
12.3 An Algorithm
The most common algorithm for computing A := CholA can be derived as follows: Consider A = LLH .
Partition
α11 ? λ 0
A= and L = 11 . (12.1)
a21 A22 l21 L22
Remark 12.6 We adopt the commonly used notation where Greek lower case letters refer to scalars, lower
case letters refer to (column) vectors, and upper case letters refer to matrices. (This is convention is often
attributed to Alston Householder.) The ? refers to a part of A that is neither stored nor updated.
Remark 12.7 Similar to the tril function in Matlab, we use tril (B) to denote the lower triangular part
of matrix B.
12.4. Proof of the Cholesky Factorization Theorem 199
H.
Proof: Since A is Hermitian so are A22 and A22 − l21 l21
χ1
Let x2 ∈ C(n−1)×(n−1) be an arbitrary nonzero vector. Define x = where χ1 = −aH x2 /α11 .
21
x2
Then, since x 6= 0,
H
χ1 α11 aH
21 χ1
0 < xH Ax =
x2 a21 A22 x2
H
χ1 α11 χ1 + aH
21 x2
=
x2 a21 χ1 + A22 x2
= α11 |χ1 |2 + χ1 aH H H
21 x2 + x2 a21 χ1 + x2 A22 x2
aH x2 x2H a21 x2H a21 H aH x2
= α11 21 − a21 x2 −x2H a21 21 + x2H A22 x2
α11 α11 α11 α11
H
a21 a21
= x2H (A22 − )x2 (since x2H a21 aH H H
21 x2 is real and hence equals a21 x2 x2 a21 )
α11
H H
= x2 (A22 − l21 l21 )x2 .
H is HPD.
We conclude that A22 − l21 l21
Proof: of the Cholesky Factorization Theorem
Proof by induction.
Base case: n = 1. Clearly the result is true for a 1 × 1 matrix A = α11 : In this case, the fact that A is
√
HPD means that α11 is real and positive and a Cholesky factor is then given by λ11 = α11 , with
uniqueness if we insist that λ11 is positive.
Inductive step: Assume the result is true for HPD matrix A ∈ C(n−1)×(n−1) . We will show that it holds for
√
A ∈ Cn×n . Let A ∈ Cn×n be HPD. Partition A and L as in (12.1) and let λ11 = α11 (which is well-
H (which exists as a consequence
defined by Lemma 12.8), l21 = a21 /λ11 , and L22 = CholA22 − l21 l21
of the Inductive Hypothesis and Lemma 12.9). Then L is the desired Cholesky factor of A.
By the principle of mathematical induction, the theorem holds.
Chapter 12. Notes on Cholesky Factorization 200
where A11 and L11 are b × b. By substituting these partitioned matrices into A = LLH we find that
H
A11 ? L11 0 L11 0 H
L11 L11 ?
= = .
A21 A22 L21 L22 L21 L22 H
L21 L11 H + L LH
L21 L21 22 22
L11 = CholA11 ?
.
−H H
L21 = A21 L11 L22 = CholA22 − L21 L21
Remark 12.10 The Cholesky factorization A11 := L11 = CholA11 can be computed with the unblocked
algorithm or by calling the blocked Cholesky factorization algorithm recursively.
−H
Remark 12.11 Operations like L21 = A21 L11 are computed by solving the equivalent linear system with
H H
multiple right-hand sides L11 L21 = A21 .
done done AT L ?
↓ ↓
A00 ? ?
aT10 α11 ?
Repartition
A20 a21 A22
↓ ↓
√
UPD. α11
Update
a21
A22 −
UPD. UPD.
α11
a21 aT21
↓ ↓
done done AT L ?
@
End of iteration
R
@
partially
done updated ABL ABR
Figure 12.1: Left: Progression of pictures that explain Cholesky factorization algorithm. Right: Same
pictures, annotated with labels and updates.
Chapter 12. Notes on Cholesky Factorization 202
√
α11 := α11 A11 := CholA11
a21 := a21 /α11 A21 := A21 tril (A11 )−H
A22 := A22 − tril a21 aH A22 := A22 − tril A21 AH
21 21
Figure 12.2: Unblocked and blocked algorithms for computing the Cholesky factorization in FLAME
notation.
12.7. Cost 203
Beginning of iteration: At some stage of the algorithm (Top of the loop), the computation has moved
through the matrix to the point indicated by the thick lines. Notice that we have finished with the
parts of the matrix that are in the top-left, top-right (which is not to be touched), and bottom-left
quadrants. The bottom-right quadrant has been updated to the point where we only need to perform
a Cholesky factorization of it.
Repartition: We now repartition the bottom-right submatrix to expose α11 , a21 , and A22 .
End of iteration: The thick lines are moved, since we now have completed more of the computation, and
only a factorization of A22 (which becomes the new bottom-right quadrant) remains to be performed.
Continue: The above steps are repeated until the submatrix ABR is empty.
To motivate our notation, we annotate this progression of pictures as in Figure 12.1 (right). In those
pictures, “T”, “B”, “L”, and “R” stand for “Top”, “Bottom”, “Left”, and “Right”, respectively. This then
motivates the format of the algorithm in Figure 12.2 (left). It uses what we call the FLAME notation for
representing algorithms [24, 23, 38]. A similar explanation can be given for the blocked algorithm, which
is given in Figure 12.2 (right). In the algorithms, m(A) indicates the number of rows of matrix A.
Remark 12.12 The indices in our more stylized presentation of the algorithms are subscripts rather than
indices in the conventional sense.
Remark 12.13 The notation in Figs. 12.1 and 12.2 allows the contents of matrix A at the beginning of the
iteration to be formally stated:
AT L ? LT L ?
A= = ,
ABL ABR LBL ÂBR − tril LBL LBL H
12.7 Cost
The cost of the Cholesky factorization of A ∈ Cm×m can be analyzed as follows: In Figure 12.2 (left)
during the kth iteration (starting k at zero) A00 is k × k. Thus, the operations in that iteration cost
√
• α11 := α11 : negligible when k is large.
m−1 m−1
CChol (m) ≈ ∑ (m − k − 1)2 + ∑ (m − k − 1)
|k=0 {z } |k=0 {z }
(Due to update of A22 ) (Due to update of a21 )
m−1 m−1
1 1 1
= ∑ j2 + ∑ j ≈ m3 + m2 ≈ m3
j=0 j=0 3 2 3
which allows us to state that (obvious) most computation is in the update of A22 . It can be shown that the
blocked Cholesky factorization algorithm performs exactly the same number of floating point operations.
Comparing the cost of the Cholesky factorization to that of the LU factorization from “Notes on LU
Factorization” we see that taking advantage of symmetry cuts the cost approximately in half.
Recall that if B ∈ Cm×n has linearly independent columns, then A = BH B is HPD. Also, recall from “Notes
on Linear Least-Squares” that the solution, x ∈ Cn to the linear least-squares (LLS) problem
H
B
|{z}B x = BH y .
|{z}
A ŷ
This makes it obvious how the Cholesky factorization can (and often is) used to solve the LLS problem.
Homework 12.15 Consider B ∈ Cm×n with linearly independent columns. Recall that B has a QR fac-
torization, B = QR where Q has orthonormal columns and R is an upper triangular matrix with positive
diagonal elements. How are the Cholesky factorization of BH B and the QR factorization of B related?
* SEE ANSWER
Repartition
A00 ? ?
AT L ?
→ aT α11 ?
10
ABL ABR
A20 a21 A22
whereα11 is 1 × 1
Continue with
A00 ? ?
AT L ?
← aT α11 ?
10
ABL ABR
A20 a21 A22
endwhile
Figure 12.3: Unblocked Cholesky factorization, bordered variant, for Homework 12.17.
Chapter 12. Notes on Cholesky Factorization 206
(Hint: For this exercise, use techniques similar to those in Section 12.4.)
2. Assuming that A00 = L00 L00T , where L is lower triangular and nonsingular, argue that the assign-
00
T T −T
ment l10 := a10 L00 is well-defined.
3. Assuming that A00 is SPD, A00 = L00 L00 T where L is lower triangular and nonsingular, and l T =
00
q 10
T −T T T
a10 L00 , show that α11 − l10 l10 > 0 so that λ11 := α11 − l10 l10 is well-defined.
4. Show that T
A00 a10 L00 0 L00 0
=
aT10 α11 T
l10 λ11 T
l10 λ11
* SEE ANSWER
Homework 12.17 Use the results in the last exercise to give an alternative proof by induction of the
Cholesky Factorization Theorem and to give an algorithm for computing it by filling in Figure 12.3. This
algorithm is often referred to as the bordered Cholesky factorization algorithm.
* SEE ANSWER
Homework 12.18 Show that the cost of the bordered algorithm is, approximately, 13 n3 flops.
* SEE ANSWER
Algorithm Code
for j = 1 : n do j=1, n
√
α j, j := α j, j A(j,j) = sqrt(A(j,j))
for i = j + 1 : n do i=j+1,n
Simple
for k = j + 1 : n do k=j+1,n
for i = k : n do i=k,n
αi,k := αi,k − αi, j αk, j A(i,k) = A(i,k) - A(i,j) * A(k,j)
endfor enddo
endfor enddo
endfor enddo
do j=1, n
for j = 1 : n A( j,j ) = sqrt( A( j,j ) )
√
α j, j := α j, j
call dscal( n-j, 1.0d00 / A(j,j), A(j+1,j), 1 )
Vector-vector
α j+1:n, j := α j+1:n, j /α j, j
do k=j+1,n
for k = j + 1 : n call daxpy( n-k+1, -A(k,j), A(k,j), 1,
αk:n,k := −αk, j αk:n, j + αk:n,k A(k,k), 1 )
endfor enddo
endfor enddo
Figure 12.4: Simple and vector-vector (level-1 BLAS) based representations of the right-looking algo-
rithm.
Chapter 12. Notes on Cholesky Factorization 208
Algorithm Code
for j = 1 : n do j=1, n
√
α j, j := α j, j A(j,j) = sqrt(A(j,j))
Matrix-vector
Figure 12.5: Matrix-vector (level-2 BLAS) based representations of the right-looking algorithm.
12.10. Implementing the Cholesky Factorization with the (Traditional) BLAS 209
We start with a simple implementation in Fortran. A simple algorithm that does not use BLAS and the
corresponding code in given in the row labeled “Simple” in Figure 12.4. This sets the stage for our
explaination of how the algorithm and code can be represented with vector-vector, matrix-vector, and
matrix-matrix operations, and the corresponding calls to BLAS routines.
The first BLAS interface [28] was proposed in the 1970s when vector supercomputers like the early Cray
architectures reigned. On such computers, it sufficed to cast computation in terms of vector operations.
As long as memory was accessed mostly contiguously, near-peak performance could be achieved. This
interface is now referred to as the Level-1 BLAS. It was used for the implementation of the first widely
used dense linear algebra package, LINPACK [16].
Let x and y be vectors of appropriate length and α be scalar. In this and other notes we have vector-
vector operations such as scaling of a vector (x := αx), inner (dot) product (α := xT y), and scaled vector
addition (y := αx + y). This last operation is known as an axpy, which stands for alpha times x plus y.
Our Cholesky factorization algorithm expressed in terms of such vector-vector operations and the cor-
responding code are given in Figure 12.4 in the row labeled “Vector-vector”. If the operations supported
by dscal and daxpy achieve high performance on a target archecture (as it was in the days of vector
supercomputers) then so will the implementation of the Cholesky factorization, since it casts most compu-
tation in terms of those operations. Unfortunately, vector-vector operations perform O(n) computation on
O(n) data, meaning that these days the bandwidth to memory typically limits performance, since retriev-
ing a data item from memory is often more than an order of magnitude more costly than a floating point
operation with that data item.
We summarize information about level-1 BLAS in Figure 12.6.
The next level of BLAS supports operations with matrices and vectors. The simplest example of such
an operation is the matrix-vector product: y := Ax where x and y are vectors and A is a matrix. Another
example is the computation A22 = −a21 aT21 + A22 (symmetric rank-1 update) in the Cholesky factorization.
Here only the lower (or upper) triangular part of the matrix is updated, taking advantage of symmetry.
The use of symmetric rank-1 update is illustrated in Figure 12.5, in the row labeled “Matrix-vector”.
There dsyr is the routine that implements a double precision symmetric rank-1 update. Readability of the
code is improved by casting computation in terms of routines that implement the operations that appear in
the algorithm: dscal for a21 = a21 /α11 and dsyr for A22 = −a21 aT21 + A22 .
If the operation supported by dsyr achieves high performance on a target archecture (as it was in
the days of vector supercomputers) then so will this implementation of the Cholesky factorization, since
it casts most computation in terms of that operation. Unfortunately, matrix-vector operations perform
O(n2 ) computation on O(n2 ) data, meaning that these days the bandwidth to memory typically limits
performance.
We summarize information about level-2 BLAS in Figure 12.7.
Chapter 12. Notes on Cholesky Factorization 210
• The “” indicates the data type. The choices for this first letter are
s single precision
d double precision
c single precision complex
z double precision complex
• x and y indicate the memory locations where the first elements of x and y are stored,
respectively.
• incx and incy equal the increment by which one has to stride through memory for the
elements of vectors x and y, respectively
routine/ operation
function
swap x↔y
scal x ← αx
copy y←x
axpy y ← αx + y
dot xT y
nrm2 kxk2
asum kre(x)k1 + kim(x)k1
imax min(k) : |re(xk )| + |im(xk )| = max(|re(xi )| + |im(xi )|)
XXYY,
where
• In addition, operations with banded matrices are supported, which we do not discuss
here.
which implements the operation A = αxxT + A, updating the lower or upper triangular part of
A by choosing uplo as ‘Lower triangular’ or ‘Upper triangular’, respectively. The
parameter lda (the leading dimension of matrix A) indicates the increment by which memory
has to be traversed in order to address successive elements in a row of matrix A.
The following table gives the most commonly used level-2 BLAS operations:
routine/ operation
function
gemv general matrix-vector multiplication
symv symmetric matrix-vector multiplication
trmv triangular matrix-vector multiplication
trsv triangular solve vector
ger general rank-1 update
syr symmetric rank-1 update
syr2 symmetric rank-2 update
Algorithm Code
do j=1, n, nb
jb = min( nb, n-j+1 )
A( j+jb, j ), lda )
A j+b:n, j: j+b−1 A−H
j: j+b−1, j: j+b−1
A j+b:n, j+b:n := A j+b:n, j+b:n call dsyrk( ‘Lower triangular’, ‘No transpose’,
J-JB+1, JB, -1.0d00, A( j+jb, j ), lda,
− tril Aj+b:n,j:j+b−1 AH j+b:n,j:j+b−1 1.0d00, A( j+jb, j+jb ), lda )
endfor enddo
int Chol_unb_var3( FLA_Obj A )
{
AT L ?
Partition A → FLA_Obj ATL, ATR, A00, a01, A02,
ABL ABR ABL, ABR, a10t, alpha11, a12t,
whereAT L is 0 × 0 A20, a21, A22;
while m(AT L ) < m(A) do
FLA_Part_2x2( A, &ATL, &ATR,
Determine block size b &ABL, &ABR, 0, 0, FLA_TL );
Repartition
FLAME Notation
The naming convention for level-3 BLAS routines are similar to those for the level-2 BLAS.
A representative call to a level-3 BLAS operation is given by
routine/ operation
function
gemm general matrix-matrix multiplication
symm symmetric matrix-matrix multiplication
trmm triangular matrix-matrix multiplication
trsm triangular solve with multiple right-hand sides
syrk symmetric rank-k update
syr2k symmetric rank-2k update
T =A .
• The call to dtrsm implements A21 := L21 where L21 L11 21
T +A .
• The call to dsyrk implements A22 := −L21 L21 22
The bulk of the computation is now cast in terms of matrix-matrix operations which can achieve high
performance.
We summarize information about level-3 BLAS in Figure 12.9.
One thread
10
6
GFlops
2 Hand optimized
BLAS3
BLAS2
BLAS1
triple loops
0
0 200 400 600 800 1000 1200 1400 1600 1800 2000
n
Figure 12.10: Performance of the different implementations of Cholesky factorization that use different
levels of BLAS. The target processor has a peak of 11.2 Gflops (billions of floating point operations per
second). BLAS1, BLAS2, and BLAS3 indicate that the bulk of computation was cast in terms of level-1,
-2, or -3 BLAS, respectively.
12.11.2 BLIS
The implementations that call BLAS in this paper are coded in Fortran. More recently, the languages of
choice for scientific computing have become C and C++. While there is a C interface to the traditional
BLAS called the CBLAS [10], we believe a more elegant such interface is the BLAS-like Library Instan-
tiation Software (BLIS) interface [41]. BLIS is not only a framework for rapid implementation of the
traditional BLAS, but also presents an alternative interface for C and C++ users.
Chapter 13
Notes on Eigenvalues and Eigenvectors
If you have forgotten how to find the eigenvalues and eigenvectors of 2 × 2 and 3 × 3 matrices, you may
want to review
Video
Read disclaimer regarding the videos in the preface!
* YouTube
* Download from UT Box
* View After Local Download
215
Chapter 13. Notes on Eigenvalues and Eigenvectors 216
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
13.1. Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
13.2. The Schur and Spectral Factorizations . . . . . . . . . . . . . . . . . . . . . . . . . 220
13.3. Relation Between the SVD and the Spectral Decomposition . . . . . . . . . . . . . . 222
13.1. Definition 217
13.1 Definition
Definition 13.1 Let A ∈ Cm×m . Then λ ∈ C and nonzero x ∈ Cm are said to be an eigenvalue and corre-
sponding eigenvector if Ax = λx. The tuple (λ, x) is said to be an eigenpair. The set of all eigenvalues of A
is denoted by Λ(A) and is called the spectrum of A. The spectral radius of A, ρ(A) equals the magnitude
of the largest eigenvalue, in magnitude:
The action of A on an eigenvector x is as if it were multiplied by a scalar. The direction does not
change, only its length is scaled:
Ax = λx.
The following exercises expose some other basic properties of eigenvalues and eigenvectors:
Homework 13.4 Let λ be an eigenvalue of A and let Eλ (A) = {x ∈ Cm |Ax = λx} denote the set of all
eigenvectors of A associated with λ (including the zero vector, which is not really considered an eigenvec-
tor). Show that this set is a (nontrivial) subspace of Cm .
* SEE ANSWER
Definition 13.5 Given A ∈ Cm×m , the function pm (λ) = det(λI − A) is a polynomial of degree at most m.
This polynomial is called the characteristic polynomial of A.
The definition of pm (λ) and the fact that is a polynomial of degree at most m is a consequence of the
definition of the determinant of an arbitrary square matrix. This definition is not particularly enlightening
other than that it allows one to succinctly related eigenvalues to the roots of the characteristic polynomial.
Remark 13.6 The relation between eigenvalues and the roots of the characteristic polynomial yield a
disconcerting insight: A general formula for the eigenvalues of a m × m matrix with m > 4 does not exist.
Chapter 13. Notes on Eigenvalues and Eigenvectors 218
The reason is that there is no general formula for the roots of a polynomial of degree m > 4. Given any
polynomial pm (χ) of degree m, an m × m matrix can be constructed such that its characteristic polynomial
is pm (λ). If
pm (χ) = α0 + α1 χ + · · · + αm−1 χm−1 + χm
and
−αn−1 −αn−2 −αn−3 · · · −α1 −α0
1 0 0 ··· 0 0
0 1 0 ··· 0 0
A=
0 0 1 ··· 0 0
.. .. .. .. .. ..
. . . . . .
0 0 0 ··· 1 0
then
pm (λ) = det(λI − A)
Hence, we conclude that no general formula can be found for the eigenvalues for m × m matrices when
m > 4. What we will see in future “Notes on ...” is that we will instead create algorithms that converge to
the eigenvalues and/or eigenvalues of matrices.
Theorem 13.7 Let A ∈ Cm×m and pm (λ) be its characteristic polynomial. Then λ ∈ Λ(A) if and only if
pm (λ) = 0.
Proof: This is an immediate consequence of Theorem 13.2.
In other words, λ is an eigenvalue of A if and only if it is a root of pm (λ). This has the immediate
consequence that A has at most m eigenvalues and, if one counts multiple roots by their multiplicity, it has
exactly m eigenvalues. (One says “Matrix A ∈ Cm×m has m eigenvalues, multiplicity counted.)
Homework 13.8 The eigenvalues of a diagonal matrix equal the values on its diagonal. The eigenvalues
of a triangular matrix equal the values on its diagonal.
* SEE ANSWER
Corollary 13.9 If A ∈ Rm×m is real valued then some or all of its eigenvalues may be complex valued. In
this case, if λ ∈ Λ(A) then so is its conjugate, λ.
Proof: It can be shown that if A is real valued, then the coefficients of its characteristic polynomial are
all real valued. Complex roots of a polynomial with real coefficients come in conjugate pairs.
It is not hard to see that an eigenvalue that is a root of multiplicity k has at most k eigenvectors. It
is, however, not necessarily the case that an eigenvalue that is a root of multiplicity k also has k linearly
independent eigenvectors. In other words, the null space of λI − A may have dimension less then the
algebraic multiplicity of λ. The prototypical counter example is the k × k matrix
µ 1 0 ··· 0 0
0 µ 1 ... 0 0
. . . . . .
J(µ) = .. . . . . . . .. ..
0 0 0 ... µ 1
0 0 0 ··· 0 µ
13.1. Definition 219
where k > 1. Observe that λI − J(µ) is singular if and only if λ = µ. Since µI − J(µ) has k − 1 linearly
independent columns its null-space has dimension one: all eigenvectors are scalar multiples of each other.
This matrix is known as a Jordan block.
Definition 13.10 A matrix A ∈ Cm×m that has fewer than m linearly independent eigenvectors is said to
be defective. A matrix that does have m linearly independent eigenvectors is said to be nondefective.
Theorem 13.11 Let A ∈ Cm×m . There exist nonsingular matrix X and diagonal matrix Λ such that A =
XΛX −1 if and only if A is nondefective.
Proof:
(⇒). Assume there exist nonsingular matrix X and diagonal matrix Λ so that A = XΛX −1 . Then, equiva-
lently, AX = XΛ. Partition X by columns so that
λ0 0 · · · 0
0 λ1 · · · 0
A x0 x1 · · · xm−1 = x0 x1 · · · xm−1 . .
.. .
.. .. .
..
0 0 · · · λm−1
= λ0 x0 λ1 x1 · · · λm−1 xm−1 .
Then, clearly, Ax j = λ j x j so that A has m linearly independent eigenvectors and is thus nondefective.
(⇐). Assume that A is nondefective. Let {x0 , · · · , xm−1 } equal m linearly independent eigenvectors cor-
responding to eigenvalues {λ0 , · · · , λm−1 }. If X = x0 x1 · · · xm−1 then AX = XΛ where Λ =
diag(λ0 , . . . , λm−1 ). Hence A = XΛX −1 .
Definition 13.12 Let µ ∈ Λ(A) and pm (λ) be the characteristic polynomial of A. Then the algebraic
multiplicity of µ is defined as the multiplicity of µ as a root of pm (λ).
Definition 13.13 Let µ ∈ Λ(A). Then the geometric multiplicity of µ is defined to be the dimension of
Eµ (A). In other words, the geometric multiplicity of µ equals the number of linearly independent eigen-
vectors that are associated with µ.
Theorem 13.14 Let A ∈ Cm×m . Let the eigenvalues of A be given by λ0 , λ1 , · · · , λk−1 , where an eigenvalue
is listed exactly n times if it has geometric multiplicity n. There exists a nonsingular matrix X such that
J(λ0 ) 0 ··· 0
0 J(λ1 ) · · · 0
A=X . .
.. .
.. . .. .
..
0 0 · · · J(λk−1 )
For our discussion, the sizes of the Jordan blocks J(λi ) are not particularly important. Indeed, this decom-
position, known as the Jordan Canonical Form of matrix A, is not particularly interesting in practice. For
this reason, we don’t discuss it further and do not we give its proof.
Chapter 13. Notes on Eigenvalues and Eigenvectors 220
Theorem 13.15 Let A,Y, B ∈ Cm×m , assume Y is nonsingular, and let B = Y −1 AY . Then Λ(A) = Λ(B).
Proof: Let λ ∈ Λ(A) and x be an associated eigenvector. Then Ax = λx if and only if Y −1 AYY −1 x = Y −1 λx
if and only if B(Y −1 x) = λ(Y −1 x).
Definition 13.16 Matrices A and B are said to be similar if there exists a nonsingular matrix Y such that
B = Y −1 AY .
Theorem 13.17 Schur Decomposition Theorem Let A ∈ Cm×m . Then there exist a unitary matrix Q and
upper triangular matrix U such that A = QUQH . This decomposition is called the Schur decomposition
of matrix A.
In the above theorem, Λ(A) = Λ(U) and hence the eigenvalues of A can be found on the diagonal of U.
Proof: We will outline how to construct Q so that QH AQ = U, an upper triangular matrix.
Since a polynomial of degree m has at least one root, matrix A has at least one eigenvalue, λ1 , and
corresponding eigenvector we normalize this eigenvector to have length one. Thus Aq1 = λ1 q1 .
q1 , where
Choose Q2 so that Q = q1 Q1 is unitary. Then
H
H
Q AQ = q1 Q2 A q1 Q2
qH Aq1 qH AQ
2 λ1 q H AQ
2 λ wT
= 1 1 = 1 = 1 ,
H H
Q2 Aq1 Q2 AQ2 H H
λQ2 q1 Q2 AQ2 0 B
where wT = qH H
1 AQ2 and B = Q2 AQ2 . This insight can be used to construct an inductive proof.
One should not mistake the above theorem and its proof as a constructive way to compute the Schur
decomposition: finding an eigenvalue and/or the eigenvalue associated with it is difficult.
AT L AT R
Lemma 13.18 Let A ∈ Cm×m be of form A = . Assume that QT L and QBR are unitary “of
0 ABR
appropriate size”. Then
H
QT L 0 QT L AT L QH
TL QT L AT R QH
BR QT L 0
A= .
0 QBR 0 QBR ABR QH
BR 0 QBR
13.2. The Schur and Spectral Factorizations 221
Homework 13.19 Prove Lemma 13.18. Then generalize it to a result for block upper triangular matrices:
A0,0 A0,1 · · · A0,N−1
0 A1,1 · · · A1,N−1
A= .
.. ..
0
0 . .
0 0 · · · AN−1,N−1
* SEE ANSWER
AT L AT R
Corollary 13.20 Let A ∈ Cm×m be of for A = . Then Λ(A) = Λ(AT L ) ∪ Λ(ABR ).
0 ABR
Homework 13.21 Prove Corollary 13.20. Then generalize it to a result for block upper triangular matri-
ces.
* SEE ANSWER
A theorem that will later allow the eigenvalues and vectors of a real matrix to be computed (mostly)
without requiring complex arithmetic is given by
Theorem 13.22 Let A ∈ Rm×m . Then there exist a unitary matrix Q ∈ Rm×m and quasi upper triangular
matrix U ∈ Rm×m such that A = QUQT .
A quasi upper triangular matrix is a block upper triangular matrix where the blocks on the diagonal are
1 × 1 or 2 × 2. Complex eigenvalues of A are found as the complex eigenvalues of those 2 × 2 blocks on
the diagonal.
Theorem 13.23 Spectral Decomposition Theorem Let A ∈ Cm×m be Hermitian. Then there exist a
unitary matrix Q and diagonal matrix Λ ∈ Rm×m such that A = QΛQH . This decomposition is called the
Spectral decomposition of matrix A.
Proof: From the Schur Decomposition Theorem we know that there exist a matrix Q and upper triangular
matrix U such that A = QUQH . Since A = AH we know that QUQH = QU H QH and hence U = U H . But
a Hermitian triangular matrix is diagonal with real valued diagonal entries.
What we conclude is that a Hermitian matrix is nondefective and its eigenvectors can be chosen to
form an orthogonal basis.
Homework 13.24 Let A be Hermitian and λ and µ be distinct eigenvalues with eigenvectors xλ and xµ ,
respectively. Then xλH xµ = 0. (In other words, the eigenvectors of a Hermitian matrix corresponding to
distinct eigenvalues are orthogonal.)
* SEE ANSWER
Chapter 13. Notes on Eigenvalues and Eigenvectors 222
Homework 13.26 Let A ∈ Cm×m and A = UΣV H its SVD. Relate the Spectral decompositions of AH A and
AAH to U, V , and Σ.
* SEE ANSWER
Chapter 14
Notes on the Power Method and Related
Methods
in which the Power Method and Inverse Power Methods are discussed at a more rudimentary level.
Video
Read disclaimer regarding the videos in the preface!
223
Chapter 14. Notes on the Power Method and Related Methods 224
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
14.1. The Power Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
14.1.1. First attempt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
14.1.2. Second attempt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
14.1.3. Convergence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
14.1.4. Practical Power Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
14.1.5. The Rayleigh quotient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
14.1.6. What if |λ0 | ≥ |λ1 |? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
14.2. The Inverse Power Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
14.3. Rayleigh-quotient Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
14.1. The Power Method 225
From “Notes on Eigenvalues and Eigenvectors” we know then that the columns of X equal eigenvectors
of A and the elements on the diagonal of Λ equal the eigenvalues::
λ0 0 · · · 0
0 λ1 · · · 0
X = x0 x0 · · · xm−1 and Λ = .
.. .
.. . .. .
..
0 0 · · · λm−1
so that
Axi = λi xi for i = 0, . . . , m − 1.
For most of this section we will assume that
What does this mean? We view the columns of X as forming a basis for Cm and then the elements in
vector y = X −1 v(0) equal the coefficients for describing v(0) in that basis. Then
Now, as long as ψ0 6= 0 clearly ψ0 λk0 x0 will eventually dominate which means that v(k) will start pointing
in the direction of x0 . In other words, it will start pointing in the direction of an eigenvector corresponding
to λ0 . The problem is that it will become infinitely long if |λ0 | > 1 or infinitessimily short if |λ0 | < 1. All
is good if |λ0 | = 1.
Again, let v(0) ∈ Cm×m be an “initial guess”. The second attempt at the Power Method iterates as follows:
for k = 0, . . .
v(k+1) = Av(k) /λ0
endfor
so that
Now, since λλ0k < 1 for k > 1 we can argue that
1 0 ··· 0
k 1 0 ··· 0
λ1
0 λ0 ··· 0 0 0 ··· 0
lim v(k) = lim X y = X y
k→∞ k→∞ .. .. .. .. .. . . . . ..
. . . .
. . . .
k
0 0 ··· λm−1 0 0 ··· 0
λ0
= Xψ0 e0 = ψ0 Xe0 = ψ0 x0 .
Thus, as long as ψ0 6= 0 (which means v must have a component in the direction of x0 ) this method will
eventually yield a vector in the direction of x0 . However, this time the problem is that we don’t know λ0
when we start.
14.1.3 Convergence
Before we make the algorithm practical, let us examine how fast the iteration converges. This requires a
few definitions regarding rates of convergence.
Notice that because of the equivalence of norms, if the sequence converges in one norm, it converges in
all norms.
|αk+1 − α| ≤ C|αk − α|
|αk+1 − α| ≤ Ck |αk − α|
with Ck → 0.
If we consider α the correct result then, eventually, the number of correct digits roughly doubles in each
iteration. This can be explained as follows: If |αk − α| < 1, then the number of correct decimal digits is
given by
− log10 |αk − α|.
Since log10 is a monotonically increasing function,
log10 |αk+1 − α| ≤ log10 C|αk − α|2 = log10 (C) + 2 log10 |αk − α| ≤ 2 log10 (|αk − α|
and hence
− log10 |αk+1 − α| ≥ 2( − log10 (|αk − α| ).
| {z } | {z }
number of correct number of correct
digits in αk+1 digits in αk
Cubic convergence is dizzyingly fast: Eventually the number of correct digits triples from one iteration
to the next.
We now define a convenient norm.
Lemma 14.3 Let X ∈ Cm×m be nonsingular. Define k · kX : Cm → R by kykX = kXyk for some given norm
k · k : Cm → R. Then k · kX is a norm.
Hence
0 0 ··· 0
k
λ1
0 ··· 0
X −1 (v(k) − ψ0 x0 ) =
λ0
y
.. ... ... ..
. .
k
λm−1
0 0 ··· λ0
Chapter 14. Notes on the Power Method and Related Methods 230
and
0 0 ··· 0
0 λλ10 · · · 0
X −1 (v(k+1) − ψ0 x0 ) =
−1 (k)
X (v − ψ0 x0 ).
.. . . . . ..
. . . .
λm−1
0 0 ··· λ0
Now, let k · k be a p-norm1 and its induced matrix norm and k · kX −1 as defined in Lemma 14.3. Then
kv(k+1) − ψ0 x0 kX −1 = kX −1 (v(k+1) − ψ0 x0 )k
0 0 ··· 0
0 λ1 · · · 0
−1 (k)
=
. .λ0 . X (v − x )
.. ψ 0 0
.. . . . .
.
λ
0 0 ··· m−1
λ0
λ1 λ1
≤ kX −1 (v(k) − ψ0 x0 )k = kv(k) − ψ0 x0 kX −1 .
λ0 λ0
This shows that, in this norm, the convergence of v(k) to ψ0 x0 is linear: The difference between current
approximation, v(k) , and the solution, ψx0 , is reduced by at least a constant factor in each iteration.
for k = 0, . . .
v(k+1) = Av(k)
v(k+1) = v(k+1) /kv(k+1) k
endfor
Proof: Let x be an eigenvector of A and λ the associated eigenvalue. Then Ax = λx. Multiplying on the
left by xH yields xH Ax = λxH x which, since x 6= 0 means that λ = xH Ax/(xH x).
Clearly this ratio as a function of x is continuous and hence an approximation to x0 when plugged into this
formula would yield an approximation to λ0 .
1 Wechoose a p-norm to make sure that the norm of a diagonal matrix equals the absolute value of the largest element (in
magnitude) on its diagonal.
14.2. The Inverse Power Method 231
Theorem 14.6 Let A ∈ Cm×m be nonsingular. Then λ and x are an eigenvalue and associated eigenvector
of A if and only if 1/λ and x are an eigenvalue and associated eigenvector of A−1 .
Show that
1 1 1
≥ ··· ≥ 1 .
> ≥
λm−1 λm−2 λm−3 λ0
* SEE ANSWER
Thus, an eigenvector associated with the smallest (in magnitude) eigenvalue of A is an eigenvector associ-
ated with the largest (in magnitude) eigenvalue of A−1 . This suggest the following naive iteration:
for k = 0, . . .
v(k+1) = A−1 v(k)
v(k+1) = λm−1 v(k+1)
endfor
Of course, we would want to factor A = LU once and solve L(Uv(k+1) ) = v(k) rather than multiplying
with A−1 . From the analysis of the convergence of the “second attempt” for a Power Method algorithm
we conclude that now
(k+1)
λm−1 (k)
kv − ψm−1 xm−1 kX −1 ≤ kv − ψm−1 xm−1 k −1 .
X
λm−2
for k = 0, . . .
v(k+1) = A−1 v(k)
v(k+1) = v(k+1) /kv(k+1) k
endfor
Often, we would expect the Invert Power Method to converge faster than the Power Method. For
example, take the case where |λk | are equally spaced between 0 and m: |λk | = (k + 1). Then
λ1 m − 1 λm−1 1
= and = .
λ0 m λm−2 2
which means that the Power Method converges much more slowly than the Inverse Power Method.
Lemma 14.8 Let A ∈ Cm×m and µ ∈ C. Then (λ, x) is an eigenpair of A if and only if (λ − µ, x) is an
eigenpair of (A − µI).
The matrix A − µI is referred to as the matrix A that has been “shifted” by µ. What the lemma says is that
shifting A by µ shifts the spectrum of A by µ:
This suggests the following (naive) iteration: Pick a value µ close to λm−1 . Iterate
for k = 0, . . .
v(k+1) = (A − µI)−1 v(k)
v(k+1) = (λm−1 − µ)v(k+1)
endfor
Of course one would solve (A − µI)v(k+1) = v(k) rather than computing and applying the inverse of A.
If we index the eigenvalues so that |λ0 − µ| ≤ · · · ≤ |λm−2 − µ| < |λm−1 − µ| then
(k+1)
λm−1 − µ (k)
kv − ψm−1 xm−1 kX −1 ≤ kv − ψm−1 xm−1 k −1 .
X
λm−2 − µ
The closer to λm−1 the “shift” (so named because it shifts the spectrum of A) is chosen, the more favorable
the ratio that dictates convergence.
A more practical algorithm is given by
14.3. Rayleigh-quotient Iteration 233
for k = 0, . . .
v(k+1) = (A − µI)−1 v(k)
v(k+1) = v(k+1) /kv(k+1) k
endfor
The question now becomes how to chose µ so that it is a good guess for λm−1 . Often an application
inherently supplies a reasonable approximation for the smallest eigenvalue or an eigenvalue of particular
interest. However, we know that eventually v(k) becomes a good approximation for xm−1 and therefore
the Rayleigh quotient gives us a way to find a good approximation for λm−1 . This suggests the (naive)
Rayleigh-quotient iteration:
for k = 0, . . .
µk = v(k) H Av(k) /(v(k) H v(k) )
v(k+1) = (A − µk I)−1 v(k)
v(k+1) = (λm−1 − µk )v(k+1)
endfor
Now2
(k+1)
λm−1 − µk (k)
kv − ψm−1 xm−1 kX −1 ≤ kv − ψm−1 xm−1 k −1
X
λm−2 − µk
with
lim (λm−1 − µk ) = 0
k→∞
which means super linear convergence is observed. In fact, it can be shown that once k is large enough
which is known as quadratic convergence. Roughly speaking this means that every iteration doubles
the number of correct digits in the current approximation. To prove this, one shows that |λm−1 − µk | ≤
Ckv(k) − ψm−1 xm−1 kX −1 .
Better yet, it can be shown that if A is Hermitian, then, once k is large enough,
which is known as cubic convergence. Roughly speaking this means that every iteration triples the number
of correct digits in the current approximation. This is mind-boggling fast convergence!
A practical Rayleigh quotient iteration is given by
v(0) = v(0) /kv(0) k2
for k = 0, . . .
µk = v(k) H Av(k) (Now kv(k) k2 = 1)
v(k+1) = (A − µk I)−1 v(k)
v(k+1) = v(k+1) /kv(k+1) k
endfor
2 I think... I have not checked this thoroughly. But the general idea holds. λm−1 has to be defined as the eigenvalue to which
the method eventually converges.
Chapter 14. Notes on the Power Method and Related Methods 234
Chapter 15
Notes on the QR Algorithm and other Dense
Eigensolvers
Video
Read disclaimer regarding the videos in the preface!
Tragically, the camera ran out of memory for the first lecture... Here is the second lecture, which discusses
the implicit QR algorithm
* YouTube
* Download from UT Box
* View After Local Download
235
Chapter 15. Notes on the QR Algorithm and other Dense Eigensolvers 236
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
15.1. Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
15.2. Subspace Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
15.3. The QR Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
15.3.1. A basic (unshifted) QR algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 242
15.3.2. A basic shifted QR algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
15.4. Reduction to Tridiagonal Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
15.4.1. Householder transformations (reflectors) . . . . . . . . . . . . . . . . . . . . . 244
15.4.2. Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
15.5. The QR algorithm with a Tridiagonal Matrix . . . . . . . . . . . . . . . . . . . . . . 247
15.5.1. Givens’ rotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
15.6. QR Factorization of a Tridiagonal Matrix . . . . . . . . . . . . . . . . . . . . . . . . 248
15.7. The Implicitly Shifted QR Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 250
15.7.1. Upper Hessenberg and tridiagonal matrices . . . . . . . . . . . . . . . . . . . . 250
15.7.2. The Implicit Q Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
15.7.3. The Francis QR Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
15.7.4. A complete algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
15.8. Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
15.8.1. More on reduction to tridiagonal form . . . . . . . . . . . . . . . . . . . . . . . 258
15.8.2. Optimizing the tridiagonal QR algorithm . . . . . . . . . . . . . . . . . . . . . 258
15.9. Other Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
15.9.1. Jacobi’s method for the symmetric eigenvalue problem . . . . . . . . . . . . . . 258
15.9.2. Cuppen’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
15.9.3. The Method of Multiple Relatively Robust Representations (MRRR) . . . . . . 261
15.10.The Nonsymmetric QR Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
15.10.1.A variant of the Schur decomposition . . . . . . . . . . . . . . . . . . . . . . . 261
15.10.2.Reduction to upperHessenberg form . . . . . . . . . . . . . . . . . . . . . . . . 262
15.10.3.The implicitly double-shifted QR algorithm . . . . . . . . . . . . . . . . . . . . 265
15.1. Preliminaries 237
15.1 Preliminaries
The QR algorithm is a standard method for computing all eigenvalues and eigenvectors of a matrix. In this
note, we focus on the real valued symmetric eigenvalue problem (the case where A ∈ Rn×n . For this case,
recall the Spectral Decomposition Theorem:
Theorem 15.1 If A ∈ Rn×n then there exists unitary matrix Q and diagonal matrix Λ such that A = QΛQT .
We will partition Q = q0 · · · qn−1 and assume that Λ = diag(()λ0 , · · · , λn−1 ) so that throughout
this note, qi and λi refer to the ith column of Q and the ith diagonal element of Λ, which means that each
tuple (λ, qi ) is an eigenpair.
We start with a matrix V ∈ Rn×r with normalized columns and iterate something like
V (0) = V
for k = 0, . . . convergence
V (k+1) = AV (k)
Normalize the columns to be of unit length.
end for
The problem with this approach is that all columns will (likely) converge to an eigenvector associated with
the dominant eigenvalue, since the Power Method is being applied to all columns simultaneously. We will
now lead the reader through a succession of insights towards a practical algorithm.
Let us examine what V = AV looks like, for the simple case where V = v0 v1 v2 (three columns).
b
We know that
v j = Q QT v j .
| {z }
yj
Hence
n−1
v0 = ∑ ψ0, j q j ,
j=0
n−1
v1 = ∑ ψ1, j q j , and
j=0
n−1
v2 = ∑ ψ2, j q j ,
j=0
Chapter 15. Notes on the QR Algorithm and other Dense Eigensolvers 238
• If we happened to know λ0 , λ1 , and λ2 then we could divide the columns by these, respectively, and
get new vectors
n−1 λj n−1 λj n−1 λj
vb0 vb1 vb2 = ∑ j=0 0, j λ0 j ∑ j=0 1, j λ1 j ∑ j=0 2, j λ2 q j
ψ q ψ q ψ
ψ1,0 λλ10 q0 + ψ2,0 λλ20 q0 + ψ2,1 λλ12 q1 +
= ψ0,0 q0 + ψ1,1 q1 + ψ2,2 q2 + (15.1)
n−1 λj n−1 λj n−1 λj
∑ j=1 ψ0, j λ0 q j ∑ j=2 ψ1, j λ1 q j ∑ j=3 ψ2, j λ2 q j
• Assume that |λ0 | > |λ1 | > |λ2 | > |λ3 | ≥ · · · ≥ |λn−1 |. Then, similar as for the power method,
– The first column will see components in the direction of {q1 , . . . , qn−1 } shrink relative to the
component in the direction of q0 .
– The second column will see components in the direction of {q2 , . . . , qn−1 } shrink relative to the
component in the direction of q1 , but the component in the direction of q0 increases, relatively,
since |λ0 /λ1 | > 1.
– The third column will see components in the direction of {q3 , . . . , qn−1 } shrink relative to the
component in the direction of q2 , but the components in the directions of q0 and q1 increase,
relatively, since |λ0 /λ2 | > 1 and |λ1 /λ2 | > 1.
in the direction of q0 :
n−1 λj
vb1 − qT0 vb1 q0 = ψ1,1 q1 + ∑ ψ1, j qj
j=2 λ1
so that we are left with the component in the direction of q1 and components in directions of
q2 , . . . , qn−1 that are suppressed every time through the loop.
• Similarly, if we also know q1 , the components of vb2 in the direction of q0 and q1 can be subtracted
from that vector.
15.2. Subspace Iteration 239
• We do not know λ0 , λ1 , and λ2 but from the discussion about the Power Method we remember that
we can just normalize the so updated vb0 , vb1 , and vb2 to have unit length.
• We do not know q0 , q1 , and q2 , but we can informally argue that if we keep iterating,
– The vector vb0 , normalized in each step, will eventually point in the direction of q0 .
– S (b
v0 , vb1 ) will eventually equal S (q0 , q1 ).
– In each iteration, we can subtract the component of vb1 in the direction of vb0 from vb1 , and then
normalize vb1 so that eventually result in a the vector that points in the direction of q1 .
– S (b
v0 , vb1 , vb2 ) will eventually equal S (q0 , q1 , q2 ).
– In each iteration, we can subtract the component of vb2 in the directions of vb0 and vb1 from vb2 ,
and then normalize the result, to make vb2 eventually point in the direction of q2 .
What we recognize is that normalizing vb0 , subtracting out the component of vb1 in the direction of vb0 , and
then normalizing vb1 , etc., is exactly what the Gram-Schmidt process does. And thus, we can use any
convenient (and stable) QR factorization method. This also shows how the method can be generalized to
work with more than three columns and even all columns simultaneously.
The algorithm now becomes:
This shows that, if the components in the direction of q0 and q1 are subtracted out, it is the
component
λ3
in the direction of q3 that is deminished in length the most slowly, dictated by the ratio λ2 . This, of
(k)
course, generalizes: the jth column of V (k) , vi will have a component in the direction of q j+1 , of length
(k)
|qTj+1 v j |, that can be expected to shrink most slowly.
We demonstrate this in Figure 15.1, which shows the execution of the algorithm with p = n for a 5 × 5
(k)
matrix, and shows how |qTj+1 v j | converge to zero as as function of k.
Chapter 15. Notes on the QR Algorithm and other Dense Eigensolvers 240
Figure 15.1: Convergence of the subspace iteration for a 5 × 5 matrix. This graph is mislabeled: x should
be labeled with v. The (linear) convergence of v j to a vector in the direction of q j is dictated by now
quickly the component in the direction q j+1 converges to zero. The line labeled |qTj+1 x j | plots the length
of the component in the direction q j+1 as a function of the iteration number.
Next, we observe that if V ∈ Rn×n in the above iteration (which means we are iterating with n vectors
at a time), then AV yields a next-to last column of the form
λj
∑n−3
j=0 γn−2, j q j+
λn−2
ψn−2,n−2 qn−2 + ,
ψn−2,n−1 λλn−1
n−2
qn−1
where ψi, j = qTj vi . Thus, given that the components in the direction of q j , j = 0, . . . , n − 2 can be expected
in later iterations
to be greatly reduced by the QR factorization that subsequently happens with AV , we
(k)
notice that it is λλn−1 that dictates how fast the component in the direction of qn−1 disappears from vn−2 .
n−2
This is a ratio we also saw in the Inverse Power Method and that we noticed we could accelerate in the
Rayleigh Quotient Iteration: At each iteration we should shift the matrix to (A − µk I) where µk ≈ λn−1 .
Since the last column of V (k) is supposed to be converging to qn−1 , it seems reasonable to use µk =
(k)T (k) (k)
vn−1 Avn−1 (recall that vn−1 has unit length, so this is the Rayleigh quotient.)
The above discussion motivates the iteration
15.2. Subspace Iteration 241
0
10 | qT0 x(k)
4
|
| qT1 x(k)
4
|
| qT x(k) |
2 4
T (k)
length of component in direction ... | q3 x4 |
−5
10
−10
10
−15
10
0 5 10 15 20 25 30 35 40
k
Figure 15.2: Convergence of the shifted subspace iteration for a 5 × 5 matrix. This graph is mislabeled: x
should be labeled with v. What this graph shows is that the components of v4 in the directions q0 throught
q3 disappear very quickly. The vector v4 quickly points in the direction of the eigenvector associated
with the smallest (in magnitude) eigenvalue. Just like the Rayleigh-quotient iteration is not guaranteed to
converge to the eigenvector associated with the smallest (in magnitude) eigenvalue, the shifted subspace
iteration may home in on a different eigenvector than the one associated with the smallest (in magnitude)
eigenvalue. Something is wrong in this graph: All curves should quickly drop to (near) zero!
Notice that this does not require one to solve with (A − µk I), unlike in the Rayleigh Quotient Iteration.
However, it does require a QR factorization, which requires more computation than the LU factorization
(approximately 43 n3 flops).
We demonstrate the convergence in Figure 15.2, which shows the execution of the algorithm with a
(k)
5 × 5 matrix and illustrates how |qTj vn−1 | converge to zero as as function of k.
Chapter 15. Notes on the QR Algorithm and other Dense Eigensolvers 242
We have informally argued that the columns of the orthogonal matrices V (k) ∈ Rn×n generated by the
(unshifted) subspace iteration converge to eigenvectors of matrix A. (The exact conditions under which
this happens have not been fully discussed.) In Figure 15.3 (left), we restate the subspace iteration. In
it, we denote matrices V (k) and R(k) from the subspace iteration by Vb (k) and Rb to distinguish them from
the ones computed by the algorithm on the right. The algorithm on the left also computes the matrix
b(k) = V (k)T AV (k) , a matrix that hopefully converges to Λ, the diagonal matrix with the eigenvalues of A
A
on its diagonal. To the right is the QR algorithm. The claim is that the two algorithms compute the same
quantities.
We conclude that if Vb (k) converges to the matrix of orthonormal eigenvectors when the subspace iteration
is applied to V (0) = I, then A(k) converges to the diagonal matrix with eigenvalues along the diagonal.
In Figure 15.4 (left), we restate the subspace iteration with shifting. In it, we denote matrices V (k) and R(k)
from the subspace iteration by Vb (k) and Rb to distinguish them from the ones computed by the algorithm
on the right. The algorithm on the left also computes the matrix A b(k) = V (k)T AV (k) , a matrix that hopefully
converges to Λ, the diagonal matrix with the eigenvalues of A on its diagonal. To the right is the shifted
QR algorithm. The claim is that the two algorithms compute the same quantities.
15.3. The QR Algorithm 243
Figure 15.4: Basic shifted subspace iteration and basic shifted QR algorithm.
We conclude that if Vb (k) converges to the matrix of orthonormal eigenvectors when the shifted subspace
iteration is applied to V (0) = I, then A(k) converges to the diagonal matrix with eigenvalues along the
diagonal.
The convergence of the basic shifted QR algorithm is illustrated below. Pay particular attention to the
convergence of the last row and column.
2.01131953448 0.05992695085 0.14820940917 2.21466116574 0.34213192482 0.31816754245
(0)
(1)
A = 0.05992695085
2.30708673171 0.93623515213 A = 0.34213192482 2.54202325042
0.57052186467
0.14820940917 0.93623515213 1.68159373379 0.31816754245 0.57052186467 1.24331558383
2.63492207667 0.47798481637 0.07654607908 2.87588550968 0.32971207176 0.00024210487
(2)
(3)
A = 0.47798481637 2.35970859985 0.06905042811 A = 0.32971207176 2.12411444949 0.00014361630
0.07654607908 0.06905042811 1.00536932347 0.00024210487 0.00014361630 1.00000004082
2.96578660126 0.18177690194 0.00000000000 2.9912213907 0.093282073553 0.00000000000
(4)
(5)
A = 0.18177690194
2.03421339873 0.00000000000 A = 0.0932820735 2.008778609226
0.00000000000
0.00000000000 0.00000000000 1.00000000000 0.0000000000 0.000000000000 1.00000000000
Once the off-diagonal elements of the last row and column have converged (are sufficiently small), the
problem can be deflated by applying the following theorem:
Theorem 15.4 Let
A0,0 A01 ··· A0N−1
0 A1,1 · · · A1,N−1
A= . ,
.. .. .. ..
. . .
0 0 · · · AN−1,N−1
where Ak,k are all square. Then Λ(A) = ∪N−1
k=0 Λ(Ak,k ).
Chapter 15. Notes on the QR Algorithm and other Dense Eigensolvers 244
In other words, once the last row and column have converged, the algorithm can continue with the subma-
trix that consists of the first n − 1 rows and columns.
The problem with the QR algorithm, as stated, is that each iteration requires O(n3 ) operations, which
is too expensive given that many iterations are required to find all eigenvalues and eigenvectors.
In the next section, we will see that if A(0) is a tridiagonal matrix, then so are all A(k) . This reduces the cost
of each iteration from O(n3 ) to O(n). We first show how unitary similarity transformations can be used to
reduce a matrix to tridiagonal form.
Definition 15.6 Let u ∈ Rn , τ ∈ R. Then H = H(u) = I − uuT /τ, where τ = 12 uT u, is said to be a reflector
or Householder transformation.
We observe:
• Let z be any vector that is perpendicular to u. Applying a Householder transform H(u) to z leaves
the vector unchanged: H(u)z = z.
• Let any vector x be written as x = z + uT xu, where z is perpendicular to u and uT xu is the component
of x in the direction of u. Then H(u)x = z − uT xu.
This can be interpreted as follows: The space perpendicular to u acts as a “mirror”: any vector in that
space (along the mirror) is not reflected, while any other vector has the component that is orthogonal
to the space (the component outside and orthogonal to the mirror) reversed in direction. Notice that a
reflection preserves the length of the vector. Also, it is easy to verify that:
1. HH = I (reflecting the reflection of a vector results in the original vector);
2. H = H T , and so H T H = HH T = I (a reflection is an orthogonal matrix and thus preserves the norm);
and
3. if H0 , · · · , Hk−1 are Householder transformations and Q = H0 H1 · · · Hk−1 , then QT Q = QQT = I (an
accumulation of reflectors is an orthogonal matrix).
As part of the reduction to condensed form operations, given a vector x we will wish to find a
Householder transformation, H(u), such that H(u)x equals a vector with zeroes below the first element:
H(u)x = ∓kxk2 e0 where e0 equals the first column of the identity matrix. It can be easily checked that
choosing u = x ± kxk2 e0 yields the desired H(u). Notice that any nonzero scaling of u has the same prop-
erty, and the convention is to scale u so that the first element equals one. Let us define [u, τ, h] = HouseV(x)
to be the function that returns u with first element equal to one, τ = 12 uT u, and h = H(u)x.
15.4. Reduction to Tridiagonal Form 245
15.4.2 Algorithm
The first step towards computing the eigenvalue decomposition of a symmetric matrix is to reduce the
matrix to tridiagonal form.
The basic algorithm for reducing a symmetric matrix to tridiagonal form, overwriting the original
matrix with the result, can be explained as follows. We assume that symmetric A is stored only in the
lower triangular part of the matrix and that only the diagonal and subdiagonal of the symmetric tridiagonal
matrix is computed, overwriting those parts of A. Finally, the Householder vectors used to zero out parts
of A overwrite the entries that they annihilate (set to zero).
α11 aT21
• Partition A → .
a21 A22
Repartition
A00 a01 A02 t0
AT L AT R t
T → τ
→ aT aT12
α11 ,
10 1
ABL ABR tB
A20 a21 A22 t2
whereα11 and τ1 are scalars
Continue with
A00 a01 A02 t0
AT L AT R t
T ← τ1
← aT aT12
α11 ,
10
ABL ABR tB
A20 a21 A22 t2
endwhile
Figure 15.5: Basic algorithm for reduction of a symmetric matrix to tridiagonal form.
15.5. The QR algorithm with a Tridiagonal Matrix 247
× × × × × × × 0 0 0 × × 0 0 0
× × × × × × × × × × × × × 0 0
× × × × × −→ 0 × × × × −→ 0 × × × × −→
× × × × × 0 × × × × 0 0 × × ×
× × × × × 0 × × × × 0 0 × × ×
Original matrix First iteration Second iteration
× × 0 0 0 × × 0 0 0
× × × 0 0 × × × 0 0
0 × × × 0 −→ 0 × × × 0 −→
0 0 × × × 0 0 × × ×
0 0 0 × × 0 0 0 × ×
Third iteration
Figure 15.6: Illustration of reduction of a symmetric matrix to tridiagonal form. The ×s denote nonzero
elements in the matrix. The gray entries above the diagonal are not actually updated.
This is captured in the algorithm in Figure 15.5. It is also illustrated in Figure 15.6.
The total cost for reducing A ∈ Rn×n is approximately
n−1
4
4(n − k − 1)2 flops ≈ n3 flops.
∑ 3
k=0
where γ2 + σ2 = 1. (Notice that γ and σ can be thought of as the cosine and sine of an angle.) Then
T
γ −σ γ −σ γ σ γ −σ
GT G = =
σ γ σ γ −σ γ σ γ
2 2
γ + σ −γσ + γσ 1 0
= = ,
2
γσ − γσ γ + σ 2 0 1
which means that a Givens’ rotation is a unitary matrix.
Now, if γ = χ1 /kxk2 and σ = χ2 /kxk2 , then γ2 + σ2 = (χ21 + χ22 )/kxk22 = 1 and
T
γ −σ χ γ σ χ 2 2
(χ1 + χ2 )/kxk2 kxk2
1 = 1 = = .
σ γ χ2 −σ γ χ2 (χ1 χ2 − χ1 χ2 )/kxk2 0
Then
α
b 0,0 α
b 0,1 α
b 0,2 0 1 0 0 0 α
b 0,0 α
b 0,1 α
b 0,2 0
0 α
b 1,1 α
b b
b 1,2 α
b
b1,3 0 γ2,1 σ2,1 0 0 α
b 1,1 α
b 1,2 0
=
0 0 0 −σ2,1 γ2,1 0 0
α
b 2,2 α
b 2,3 α2,1 α2,2 α2,3
0 0 α3,2 α3,3 0 0 0 1 0 0 α3,2 α3,3
T
α
b 2,2 γ3,2 −σ3,2 α
b 2,2 α
b
b 2,2
Finally, from one can compute γ3,2 and σ3,2 so that = .
α3,2 σ3,2 γ3,2 α3,2 0
Then
α α b 0,2 0
α 1 0 0 0 α α
b 0,1 α 0
0,0
b 0,1
0,0
b b b 0,2
0 α 0 1 0 0 0 α
b
b 1,1 α
b 1,2 α
b b
b 1,3 b 1,1 α
b b
b 1,2 α
b
b 1,3
=
0 0 1 0 0 0
α
b 2,2 α
b b
b 2,3 γ3,2 σ3,2 α
b 2,2 α
b 2,3
0 0 0 α b 3,3 0 1 −σ3,2 γ3,2 0 0 α3,2 α3,3
The matrix Q is the orthogonal matrix that results from multiplying the different Givens’ rotations together:
1 0 0 0 1 0 0 0
γ1,0 −σ1,0 0 0
0 0 0 γ2,1 −σ2,1 0 0 1 0 0
σ1,0 γ1,0
Q= . (15.2)
1 0 0 σ2,1 γ2,1 0 0 0 γ3,2 −σ3,2
0 0
0 0 0 1 0 0 0 1 0 0 σ3,2 γ3,2
The next question is how to compute RQ given the QR factorization of the tridiagonal matrix:
α
b 0,0 α
b 0,1 α
b 0,2 0 γ1,0 −σ1,0 0 0 1 0 0 0 1 0 0 0
0 α α α 0 0
0 −σ2,1 0
0 1 0 0
b b b σ γ1,0 γ2,1
b 1,1 b 1,2 b1,3 1,0
0 0 α
b
b 2,2 α
b 2,3
b
0
0 1 0
0 σ2,1 γ2,1 0
0
0 γ3,2 −σ3,2
0 0 0 α
b 3,3 0 0 0 1 0 0 0 1 0 0 σ3,2 γ3,2
| {z }
α̃0,0 α̃0,1 α
b 0,2 0
α̃
1,0 b˜ 1,1
α α
b
b 1,2 α
b
b 1,3
0 0 α
b
b 2,2 α
b
b 2,3
0 0 0 α
b 3,3
| {z }
α̃0,0 α̃˜ 0,1 α̃0,2 0
α̃
1,0 α̃˜ 1,1 α̃1,2 α
b
b 1,3
0 α̃2,1 α̃2,2 α
b
b 2,3
0 0 0 α
b 3,3
| {z }
α̃0,0 ˜α̃0,1 α̃0,2 0
α̃1,0 α̃˜ 1,1 α̃˜ 1,2 α̃1,3
.
0
α̃2,1 α̃˜ 2,2 α̃2,3
0 0 α̃3,2 α̃3,3
Dear Colleagues,
John Francis was born in 1934 in London and currently lives in Hove, near
Brighton. His residence is about a quarter mile from the sea; he is a
widower. In 1954, he worked at the National Research Development Corp
(NRDC) and attended some lectures given by Christopher Strachey.
In 1955,’56 he was a student at Cambridge but did not complete a degree.
He then went back to NRDC as an assistant to Strachey where he got
involved in flutter computations and this led to his work on QR.
After leaving NRDC in 1961, he worked at the Ferranti Corp and then at the
University of Sussex. Subsequently, he had positions with various
industrial organizations and consultancies. He is now retired. His
interests were quite general and included Artificial Intelligence,
computer languages, systems engineering. He has not returned to numerical
computation.
He was surprised to learn there are many references to his work and
that the QR method is considered one of the ten most important
algorithms of the 20th century. He was unaware of such developments as
TeX and Math Lab. Currently he is working on a degree at the Open
University.
John Francis did remarkable work and we are all in his debt. Along with
the conjugate gradient method, it provided us with one of the basic tools
of numerical analysis.
Gene Golub
Figure 15.7: Posting by the late Gene Golub in NA Digest Sunday, August 19, 2007 Volume 07 : Issue
34. An article on the ten most important algorithms of the 20th century, published in SIAM News, can be
found at http://www.uta.edu/faculty/rcli/TopTen/topten.pdf.
Chapter 15. Notes on the QR Algorithm and other Dense Eigensolvers 254
α
b 2,1
again preserves eigenvalues. Finally, from one can compute γ3,1 and σ3,1 so that
α
b 3,1
T
γ3,1 −σ3,1 α
b 2,1 α̃2,1
= .
σ3,1 γ3,1 α
b 3,1 0
Then
α̃0,0 α̃1,0 0 0 1 0 0 0 α̃0,0 α̃1,0 0 0 1 0 0 0
α̃1,0 α̃1,1 α̃2,1 0 0 1 0 0 α̃1,0 α̃1,1 α
b
b 2,1 α 0
b 3,1 1 0 0
=
0
α̃2,1 α̃2,2 α̃2,3 1
0 γ3,2 σ3,2 0
α
b
b 2,1 α
b 2,2 α 1
b 2,3 0 γ3,1 −σ3,1
0 0 α̃3,2 α̃3,3 0 1 −σ3,2 γ3,2 0 α
b 3,1 α
b 3,2 α3,3 0 1 σ3,1 γ3,1
The matrix Q is the orthogonal matrix that results from multiplying the different Givens’ rotations to-
gether:
1 0 1 0 0 0 0 0
γ1,0 −σ1,0 0 0
0 γ2,0 −σ2,0 0 0 1 0 0
σ1,0 γ1,0 0 0
Q= .
0 σ2,0 γ2,0 0 0 0 γ3,1 −σ3,1
0 0 1 0
0 0 0 1
0 0 0 1 0 0 σ 3,1 γ3,1
γ1,0
σ
1,0
It is important to note that the first columns of Q is given by , which is exactly the same first
0
0
column had Q been computed as in Section 15.6 (Equation 15.2). Thus, by the Implicit Q Theorem, the
tridiagonal matrix that results from this approach is equal to the tridiagonal matrix that would be computed
by applying the QR factorization from Section 15.6 with A − µI, A − µI → QR followed by the formation
of RQ + µI using the algorithm for computing RQ in Section 15.6.
The successive elimination of elements α b i+1,i is often referred to as chasing the bulge while the entire
process that introduces the bulge and then chases it is known as a Francis Implicit QR Step. Obviously,
the method generalizes to matrices of arbitrary size, as illustrated in Figure 15.8. An algorithm for the
chasing of the bulge is given in Figure 17.4. (Note that in those figures T is used for A, something that
needs to be made consistent in these notes, eventually.) In practice, the tridiagonal matrix is not stored as
a matrix. Instead, its diagonal and subdiagonal are stored as vectors.
×× TT L T
TML
×××
××× +
××× Beginning of iteration
TML TMM T
TBM
+ ×××
×××
××× TBM TBR
××
↓ ↓
×× T00 t10
×××
××× + T
T10 τ11 T
t21
××× Repartition t21 T22 t32
+ ×××
××× T
t32 τ33 T
t43
××× t43 T44
××
↓ ↓
×× T00 t10
×××
××× T
t10 τ11 T
t21
××× + Update t21 T22 t32
×××
+ ××× T
t32 τ33 T
t43
××× t43 T44
××
↓ ↓
××
××× TT L T
TML
×××
××× + End of iteration
××× TML TMM T
TBM
+ ×××
××× TBM TBR
××
Figure 15.8: One step of “chasing the bulge” in the implicitly shifted symmetric QR algorithm.
• If an element of the subdiagonal (and corresponding element on the superdiagonal) becomes small
enough, it can be considered to be zero and the problem deflates (decouples) into two smaller tridi-
agonal matrices. Small is often taken to means that |αi+1,i | ≤ ε(|αi,i | + |αi+1,i+1 |) where ε is some
quantity close to the machine epsilon (unit roundoff).
• If A = QT QT reduced A to the tridiagonal matrix T before the QR algorithm commensed, then the
Givens’ rotations encountered as part of the implicitly shifted QR algorithm can be applied from the
Chapter 15. Notes on the QR Algorithm and other Dense Eigensolvers 256
Repartition
T00 ? 0 0 0
TT L ? 0 tT τ11 ? 0 0
10
? → 0 ? 0
TML TMM t21 T22
0 TBM TBR 0 0 T
t32 τ33 ?
0 0 0 t43 T44
whereτ11 and τ33 are scalars
(during final step, τ33 is 0 × 0)
τ21 τ21
Compute (γ, σ) s.t. GTγ,σt21 = , and assign t21 =
0 0
T22 = GTγ,σ T22 Gγ,σ
T = tT G
t32 (not performed during final step)
32 γ,σ
Continue with
T00 ? 0 0 0
TT L ? 0 tT τ11 ? 0 0
10
←
? 0 ? 0
TML TMM t21 T22
0 0 T
t32 ?
0 TBM TBR τ33
0 0 0 t43 T44
endwhile
right to the appropriate columns of Q so that upon completion Q is overwritten with the eigenvectors
of A. Notice that applying a Givens’ rotation to a pair of columns of Q requires O(n) computation
per Givens rotation. For each Francis implicit QR step O(n) Givens’ rotations are computed, mak-
ing the application of Givens’ rotations to Q of cost O( n2 ) per iteration of the implicitly shifted QR
algorithm. Typically a few (2-3) iterations are needed per eigenvalue that is uncovered (by defla-
tion) meaning that O(n) iterations are needed. Thus, the QR algorithm is roughly of cost O(n3 )
if the eigenvalues are accumulated (in addition to the cost of forming the Q from the reduction to
tridiagonal form, which takes another O(n3 ) operations.)
15.7. The Implicitly Shifted QR Algorithm 257
• If an element on the subdiagonal becomes zero (or very small), and hence the corresponding element
of the superdiagonal, then the problem can be deflated: If
× ×
× × ×
× × ×
T00 0 × × ×
T =
0 T11 × × 0
0 × ×
× × ×
× ×
then
– The computation can continue separately with T00 and T11 .
– One can pick the shift from the bottom-right of T00 as one continues finding the eigenvalues of
T00 , thus accelerating the computation.
– One can pick the shift from the bottom-right of T11 as one continues finding the eigenvalues of
T11 , thus accelerating the computation.
– One must continue to accumulate the eigenvectors by applying the rotations to the appropriate
columns of Q.
Because of the connection between the QR algorithm and the Inverse Power Method, subdiagonal
entries near the bottom-right of T are more likely to converge to a zero, so most deflation will happen
there.
• A question becomes when an element on the subdiagonal, τi+1,i can be considered to be zero. The
answer is when |τi+1,i | is small relative to |τi | and |τi+1,i+1 . A typical condition that is used is
q
|τi+1,i | ≤ u |τi,i τi + 1, i + 1|.
• If A ∈ Cn×n is Hermitian, then its Spectral Decomposition is also computed via the following steps,
which mirror those for the real symmetric case:
– Reduce to tridiagonal form. Householder transformation based similarity transformations can
again be used for this. This leaves one with a tridiagonal matrix, T , with real values along the
diagonal (because the matrix is Hermitian) and values on the subdiagonal and superdiagonal
that may be complex valued.
– The matrix QT such A = QT T QH
T can then be formed from the Householder transformations.
– A simple step can be used to then change this tridiagonal form to have real values even on the
subdiagonal and superdiagonal. The matrix QT can be updated accordingly.
– The tridiagonal QR algorithm that we described can then be used to diagonalize the matrix,
accumulating the eigenvectors by applying the encountered Givens’ rotations to QT . This is
where the real expense is: Apply the Givens’ rotations to matrix T requires O(n) per sweep.
Applying the Givens’ rotation to QT requires O(n2 ) per sweep.
For details, see some of our papers mentioned in the next section.
Chapter 15. Notes on the QR Algorithm and other Dense Eigensolvers 258
Field G. Van Zee, Robert A. van de Geijn, Gregorio Quintana-Ortı́, G. Joseph Elizondo.
Families of Algorithms for Reducing a Matrix to Condensed Form.
ACM Transactions on Mathematical Software (TOMS) , Vol. 39, No. 1, 2012
(Reduction to tridiagonal form is one case of what is more generally referred to as “condensed form”.)
Sweep 1
× 0 × × × × 0 × × × × 0
0 × × × × × × × × × × ×
→ → →
× × × × 0 × × × × × × ×
× × × × × × × × 0 × × ×
zero (1, 0) zero (2, 0) zero (3, 0)
× × × 0 × × × × × × × ×
× × 0 × × × × 0 × × × ×
→ → →
× 0 × × × × × × × × × 0
0 × × × × 0 × × × × 0 ×
zero (2, 1) zero (3, 1) zero (3, 2)
Sweep 2
× 0 × × × × 0 × × × × 0
0 × × × × × × × × × × ×
→ → →
× × × 0 0 × × × × × × ×
× × 0 × × × × × 0 × × ×
zero (1, 0) zero (2, 0) zero (3, 0)
× × × 0 × × × × × × × ×
× × 0 × × × × 0 × × × ×
→ → →
× 0 × × × × × × × × × 0
0 × × × × 0 × × × × 0 ×
zero (2, 1) zero (3, 1) zero (3, 2)
such that
T
T γ11 −σ31 α11 α31 γ11 −σ31 α
b 11 0
J31 A31 J31 = = .
σ31 γ33 α31 α33 σ31 γ33 0 α
b 33
We know this exists since the Spectral Decomposition of the 2 × 2 matrix exists. Such a rotation is called
a Jacobi rotation. (Notice that it is different from a Givens’ rotation because it diagonalizes a 2 × 2 matrix
when used as a unitary similarity transformation. By contrast, a Givens’ rotation zeroes an element when
applied from one side of a matrix.)
Homework 15.11 In the above discussion, show that α211 + 2α231 + α233 = α
b 211 + α
b 233 .
* SEE ANSWER
Jacobi rotation rotations can be used to selectively zero off-diagonal elements by observing the fol-
lowing:
T
I 0 0 0 0 A00 a10 AT20 a30 AT40 I 0 0 0 0
0 γ 0 −σ 0 aT α aT α a T 0 γ 0 −σ 0
11 31 10 11 21 31 41 11 13
T
JAJ = T
0 0 I 0 0
A20 a21 A22 a32 A42 0 0 I 0 0
0 σ31 0 γ33 0 aT α31 aT α33 aT 0 σ31 0 γ33 0
30 32 43
0 0 0 0 I A40 a41 A42 a43 A44 0 0 0 0 I
A00 ab10 AT20 ab30 AT40
abT α abT21 0 abT41
10 b 11
= T
A20 ab21 A22 ab32 A42 = A,
b
abT abT32 α abT43
30 0 b 33
A40 ab41 A42 ab43 A44
where
γ11 −σ31 aT10 aT21 aT41 abT10 abT21 abT41
= .
σ31 γ33 aT30 aT32 aT43 abT30 abT32 abT43
Importantly,
What this means is that if one defines off(A) as the square of the Frobenius norm of the off-diagonal
elements of A,
off(A) = kAk2F − kdiag(A)k2F ,
b = off(A) − 2α2 .
then off(A) 31
• The good news: every time a Jacobi rotation is used to zero an off-diagonal element, off(A) de-
creases by twice the square of that element.
• The bad news: a previously introduced zero may become nonzero in the process.
The original algorithm developed by Jacobi searched for the largest (in absolute value) off-diagonal
element and zeroed it, repeating this processess until all off-diagonal elements were small. The algorithm
was applied by hand by one of his students, Seidel (of Gauss-Seidel fame). The problem with this is that
searching for the largest off-diagonal element requires O(n2 ) comparisons. Computing and applying one
Jacobi rotation as a similarity transformation requires O(n) flops. Thus, for large n this is not practical.
Instead, it can be shown that zeroing the off-diagonal elements by columns (or rows) also converges to a
diagonal matrix. This is known as the column-cyclic Jacobi algorithm. We illustrate this in Figure 15.10.
• There exists a unitary matrix Q ∈ Cn×n and upper triangular matrix R ∈ Cn×n such that A = QRQH .
Importantly: even if A is real valued, the eigenvalues and eigenvectors may be complex valued.
Theorem 15.12 Let A ∈ Rn×n . Then there exist unitary Q ∈ Rn×n and quasi upper triangular matrix
R ∈ Rn×n such that A = QRQT .
Here quasi upper triangular matrix means that the matrix is block upper triangular with blocks of the
diagonal that are 1 × 1 or 2 × 2.
Remark 15.13 The important thing is that this alternative to the Schur decomposition can be computed
using only real arithmetic.
• Update
A a01 A02 I 0 0 A a01 A02 I 0 0
00 00
T
aT12 0 a10 α11 aT12
T
:= 0 1
a10 α11 0 1 0
0 a21 A22 0 0 H 0 a21 A22 0 0 H
A a01 A02 H
00
T T
= a10
α11 a12 H
0 Ha21 HA22 H
where H = H(u21 ).
– Note that a21 := Ha21 need not be executed since this update was performed by the instance
of HouseV above.4
3Note that the semantics here indicate that a21 is overwritten by Ha21 .
4In practice, the zeros below the first element of Ha21 are not actually written. Instead, the implementation overwrites these
elements with the corresponding elements of the vector u21 .
15.10. The Nonsymmetric QR Algorithm 263
Repartition
A00 a01 A02 t0
AT L AT R t
T → τ
→ aT aT12
α11 ,
10 1
ABL ABR tB
A20 a21 A22 t2
whereα11 is a scalar
Continue with
A00 a01 A02 t0
AT L AT R t
T ← τ1
← aT aT12
α11 ,
10
ABL ABR tB
A20 a21 A22 t2
endwhile
Figure 15.11: Basic algorithm for reduction of a nonsymmetric matrix to upperHessenberg form.
Chapter 15. Notes on the QR Algorithm and other Dense Eigensolvers 264
× × × × × × × × × × × × × × ×
× × × × × × × × × × × × × × ×
× × × × × −→ 0 × × × × −→ 0 × × × × −→
× × × × × 0 × × × × 0 0 × × ×
× × × × × 0 × × × × 0 0 × × ×
Original matrix First iteration Second iteration
× × × × × × × × × ×
× × × × × × × × × ×
0 × × × × −→ 0 × × × × −→
0 0 × × × 0 0 × × ×
0 0 0 × × 0 0 0 × ×
Third iteration
Figure 15.12: Illustration of reduction of a nonsymmetric matrix to upperHessenbert form. The ×s denote
nonzero elements in the matrix.
1 1
= (A22 − u21 uT21 A22 )(I − u21 uT21 )
τ τ
1 1 1
= A22 − u21 uT21 A22 − A22 u21 uT21 + 2 u21 uT21 Au21 uT21
τ τ τ | {z }
2β
1 T β T 1 T β T
= A22 − u21 u21 A22 − 2 u21 u21 − Au21 u21 − 2 u21 u21
τ τ τ τ
1 β β 1 T
= A22 − u21 uT21 A22 − uT21 − Au21 − u21 u
τ τ τ τ 21
| {z } | {z }
wT21 z21
1 1
= A22 − u21 wT21 − z21 uT21
| τ {z τ }
rank-2 update
It doesn’t suffice to only This is captured in the algorithm in Figure 15.11. It is also illustrated in Fig-
ure 15.12.
Homework 15.14 Give the approximate total cost for reducing a nonsymmetric A ∈ Rn×n to upper-
Hessenberg form.
* SEE ANSWER
For a detailed discussion on the blocked algorithm that uses FLAME notation, we recommend [32]
and [43]
Field G. Van Zee, Robert A. van de Geijn, Gregorio Quintana-Ortı́, G. Joseph Elizondo.
Families of Algorithms for Reducing a Matrix to Condensed Form.
ACM Transactions on Mathematical Software (TOMS) , Vol. 39, No. 1, 2012
The purpose of this note is to give some high level idea of how the Method of Relatively Robust Repre-
sentations (MRRR) works.
267
Chapter 16. Notes on the Method of Relatively Robust Representations (MRRR) 268
Outline
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
16.1. MRRR, from 35,000 Feet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
16.2. Cholesky Factorization, Again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
16.3. The LDLT Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
16.4. The UDU T Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
16.5. The UDU T Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
16.6. The Twisted Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
16.7. Computing an Eigenvector from the Twisted Factorization . . . . . . . . . . . . . . 279
16.1. MRRR, from 35,000 Feet 269
• It can compute all eigenvalues and eigenvectors of tridiagonal matrix in O(n2 ) time (versus O(n3 )
time for the symmetric QR algorithm).
The benefit when computing all eigenvalues and eigenvectors of a dense matrix is considerably less be-
cause transforming the eigenvectors of the tridiagonal matrix back into the eigenvectors of the dense matrix
requires an extra O(n3 ) computation, as discussed in [42]. In addition, making the method totally robust
has been tricky, since the method does not rely exclusively on unitary similarity transformations.
The fundamental idea is that of a twisted factorization of the tridiagonal matrix. This note builds up
to what that factorization is, how to compute it, and how to then compute an eigenvector with it. We
start by reminding the reader of what the Cholesky factorization of a symmetric positive definite (SPD)
matrix is. Then we discuss the Cholesky factorization of a tridiagonal SPD matrix. This then leads to
the LDLT factorization of an indefinite and indefinite tridiagonal matrix. Next follows a discussion of the
UDU T factorization of an indefinite matrix, which then finally yields the twisted factorization. When the
matrix is nearly singular, an approximation of the twisted factorization can then be used to compute an
approximate eigenvalue.
Notice that the devil is in the details of the MRRR algorithm. We will not tackle those details.
We have discussed in class the Cholesky factorization, A = LLT , which requires a matrix to be symmetric
positive definite. (We will restrict our discussion to real matrices.) The following computes the Cholesky
factorization:
α11 a21 T
• Partition A → .
a21 A22
√
• Update α11 := α11 .
• Update A22 := A22 − a21 aT21 (updating only the lower triangular part).
Algorithm: A := C HOL(A)
AT L ?
Partition A →
ABL ABR
where AT L is 0 × 0
while m(AT L ) < m(A) do
Repartition
A00 ? ?
AT L ?
→ aT α
10 11 ?
ABL ABR
A20 a21 A22
√
α11 := α11
a21 := a21 /α11
A22 := A22 − a21 aT21
Continue with
A00 ? ?
AT L ?
← aT α11 ?
10
ABL ABR
A20 a21 A22
endwhile
Figure 16.1: Unblocked algorithm for computing the Cholesky factorization. Updates to A22 affect only
the lower triangular part.
16.2. Cholesky Factorization, Again 271
Continue with
A00 ? ?
A ? ?
FF
α10 eT α11 ? ?
T L
? ←
αMF eL αMM
0 α21 α22 ?
0 αLM eF ALL
0 0 α32 eF A33
endwhile
Figure 16.2: Algorithm for computing the the Cholesky factorization of a tridiagonal matrix.
Chapter 16. Notes on the Method of Relatively Robust Representations (MRRR) 272
Then
T
α11 aT21 1 0 δ1 0 1 0
=
a21 A22 l21 L22 0 D22 l21 L22
δ11 0 T
1 l21
=
δ11 l21 L22 D22 T
0 L22
δ11 ?
=
δ11 l21 T + L D LT
δ11 l21 l21 22 22 22
16.3. The LDLT Factorization 273
Algorithm: A := LDLT(A)
AT L ?
Partition A →
ABL ABR
whereAT L is 0 × 0
while m(AT L ) < m(A) do
Repartition
A00 ? ?
AT L ?
→ aT α
10 11 ?
ABL ABR
A20 a21 A22
whereα11 is 1 × 1
Continue with
A00 ? ?
AT L ?
← aT α11 ?
10
ABL ABR
A20 a21 A22
endwhile
This suggests the following algorithm for overwriting the strictly lower triangular part of A with the strictly
lower triangular part of L and the diagonal of A with D:
α11 a21T
• Partition A → .
a21 A22
• Update A22 := A22 − l21 aT21 (updating only the lower triangular part).
• a21 := l21 .
T .
• Continue with computing A22 → L22 D22 L22
Chapter 16. Notes on the Method of Relatively Robust Representations (MRRR) 274
This algorithm will complete as long as δ11 6= 0, which happens when A is nonsingular. This is equivalent
to A does not having zero as an eigenvalue. Such a matrix is also called indefinite.
Homework 16.1 Modify the algorithm in Figure 16.1 so that it computes the LDLT factorization. (Fill in
Figure 16.3.)
* SEE ANSWER
Homework 16.2 Modify the algorithm in Figure 16.2 so that it computes the LDLT factorization of a
tridiagonal matrix. (Fill in Figure 16.4.) What is the approximate cost, in floating point operations, of
computing the LDLT factorization of a tridiagonal matrix? Count a divide, multiply, and add/subtract as
a floating point operation each. Show how you came up with the algorithm, similar to how we derived the
algorithm for the tridiagonal Cholesky factorization.
* SEE ANSWER
Notice that computing the LDLT factorization of an indefinite matrix is not a good idea when A is
nearly singular. This would lead to some δ11 being nearly zero, meaning that dividing by it leads to very
large entries in l21 and corresponding element growth in A22 . (In other words, strange things will happen
“down stream” from the small δ11 .) Not a good thing. Unfortunately, we are going to need something like
this factorization specifically for the case where A is nearly singular.
Homework 16.3 Derive an algorithm that, given an indefinite matrix A, computes A = UDU T . Overwrite
only the upper triangular part of A. (Fill in Figure 16.5.) Show how you came up with the algorithm,
similar to how we derived the algorithm for LDLT .
* SEE ANSWER
Notice that the UDU T factorization has the exact same shortcomings as does LDLT when applied
to a singular matrix. If D has a small element on the diagonal, it is again “down stream” that this can
cause large elements in the factored matrix. But now “down stream” means towards the top-left since the
algorithm moves in the opposite direction.
16.5. The UDU T Factorization 275
Repartition
A00 ? ?
A ? ?
FF
α eT α ? ?
T 10 L 11
? →
αMF eL αMM
0 α21 α22 ?
0 αLM eF ALL
0 0 α32 eF A33
whereα22 is a scalars
Continue with
A00 ? ?
A ? ?
FF
α10 eT α11 ? ?
L
αMF eTL αMM ? ←
0 α21 α22 ?
0 αLM eF ALL
0 0 α32 eF A33
endwhile
Figure 16.4: Algorithm for computing the the LDLT factorization of a tridiagonal matrix.
Chapter 16. Notes on the Method of Relatively Robust Representations (MRRR) 276
Repartition
A00 a01 A02
AT L AT R
→ ? α11 aT
12
? ABR
? ? A22
whereα11 is 1 × 1
Continue with
A00 a01 A02
AT L AT R
← ? α11 aT12
? ABR
? ? A22
endwhile
Figure 16.5: Unblocked algorithm for computing A = UDU T . Updates to A00 affect only the upper
triangular part.
16.5. The UDU T Factorization 277
Repartition
A00 α01 eL 0 0
A α e 0
FF FM L
? α11 α12 0
? αMM αML eTF →
? ? α22 α23 eTF
? ? ALL
? ? ? A33
where
Continue with
A00 α01 eL 0 0
A α e 0
FF FM L
? α11 α12 0
? αMM αML eTF ←
? ? T
α22 α23 eF
? ? ALL
? ? ? A33
endwhile
Figure 16.6: Algorithm for computing the the UDU T factorization of a tridiagonal matrix.
Chapter 16. Notes on the Method of Relatively Robust Representations (MRRR) 278
• Find a column that has no pivot in it. This identifies an independent (free) variable.
• It is inherently unstable since you are working with a matrix, B = A − λI that inherently has a bad
condition number. (Indeed, it is infinity if λ is an exact eigenvalue.)
• λ is not an exact eigenvalue when it is computed by a computer and hence B is not exactly singular.
So, no independent variables will even be found.
These are only some of the problems. To overcome this, one computes something called a twisted factor-
ization.
Again, let B be a tridiagonal matrix. Assume that λ is an approximate eigenvalue of B and let A =
B − λI. We are going to compute an approximate eigenvector of B associated with λ by computing a vector
that is in the null space of a singular matrix that is close to A. We will assume that λ is an eigenvalue of
B that has multiplicity one, and is well-separated from other eigenvalues. Thus, the singular matrix close
to A has a null space with dimension one. Thus, we would expect A = LDLT to have one element on the
diagonal of D that is essentially zero. Ditto for A = UEU T , where E is diagonal and we use this letter to
be able to distinguish the two diagonal matrices.
Thus, we have
• A = B − λI is indefinite.
• A = LDLT . L is bidiagonal, unit lower triangular, and D is diagonal with one small element on the
diagonal.
• A = UEU T . U is bidiagonal, unit upper triangular, and E is diagonal with one small element on the
diagonal.
16.7. Computing an Eigenvector from the Twisted Factorization 279
Let
A00 α10 eL 0 L00 0 0 U00 υ01 eL 0
A = α10 eTL α21 eTF
, L = λ10 eLT 0 ,U = 0 υ21 eTF ,
1
1
α11
0 α21 eF A22 0 λ21 eF L22 0 0 U22
D00 0 0 E00 0 0
D = 0 δ1 , and E = 0 ε1 0 ,
0
0 0 D22 0 0 E22
where all the partitioning is “conformal”.
(Hint: multiply out A = LDLT and A = UEU T with the partitioned matrices first. Then multiply out the
above. Compare and match...) How should φ1 be chosen? What is the cost of computing the twisted
factorization given that you have already computed the LDLT and UDU T factorizations? A ”Big O”
estimate is sufficient. Be sure to take into account what eTL D00 eL and eTF E22 eF equal in your cost estimate.
* SEE ANSWER
Because λ was assumed to have multiplicity one and well-separated, the resulting twisted factorization
has “nice” properties. We won’t get into what that exactly means.
Chapter 16. Notes on the Method of Relatively Robust Representations (MRRR) 280
For simplicity we will focus on the case where A ∈ Rn×n . We will assume that the reader has read Chap-
ter 15.
281
Chapter 17. Notes on Computing the SVD of a Matrix 282
Outline
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
17.1. Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
17.2. Reduction to Bidiagonal Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
17.3. The QR Algorithm with a Bidiagonal Matrix . . . . . . . . . . . . . . . . . . . . . . 287
17.4. Putting it all together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
17.1. Background 283
17.1 Background
Recall:
Theorem 17.1 If A ∈ Rm×m then there exists unitary matrices U ∈ Rm×m and V ∈ Rn×n , and diagonal
matrix Σ ∈ Rm×n such that A = UΣV T . This is known as the Singular Value Decomposition.
There is a relation between the SVD of a matrix A and the Spectral Decomposition of AT A:
Homework 17.2 If A = UΣV T is the SVD of A then AT A = V Σ2V T is the Spectral Decomposition of AT A.
* SEE ANSWER
The above exercise suggests steps for computing the Reduced SVD:
• Form C = AT A.
• Compute unitary V and diagonal Λ such that C = QΛQT , ordering the eigenvalues from largest to
smallest on the diagonal of Λ.
• Form W = AV . Then W = UΣ so that U and Σ can be computed from W by choosing the diago-
nal elements of Σ to equal the lengths of the corresponding columns of W and normalizing those
columns by those lengths.
The problem with this approach is that forming AT A squares the condition number of the problem. We
will show how to avoid this.
× × × ×
× × × ×
× × × ×
× × × ×
× × × ×
• We introduce zeroes below the “diagonal” in the first column by computing a Householder transfor-
mation and applying this from the left:
Chapter 17. Notes on Computing the SVD of a Matrix 284
Repartition
A00 a01 A02 t0 r0
AT L AT R t r
T → τ , T → ρ
→ aT aT12
α11 ,
10 1 1
ABL ABR tB rB
A20 a21 A22 t2 r2
whereα11 , τ1 , and ρ1 are scalars
1 α11 α11
[ , τ1 , ] := HouseV( )
u21 a21 a21
aT12 := aT12 − wT12
z21 := (y21 − βu21 /τ1 )/τ1
A22 := A22 − u21 wT21 (rank-1 update)
Continue with
A00 a01 A02 t0 r0
AT L AT R t r
T ← τ1 , T ← ρ1
← aT aT12
α11 ,
10
ABL ABR tB rB
A20 a21 A22 t2 r2
endwhile
Figure 17.1: Basic algorithm for reduction of a nonsymmetric matrix to bidiagonal form.
17.2. Reduction to Bidiagonal Form 285
× × × × × × 0 0 × × 0 0
× × × × 0 × × × 0 × × 0
× × × × −→ 0 × × × −→ 0 0 × × −→
× × × × 0 × × × 0 0 × ×
× × × × 0 × × × 0 0 × ×
Original matrix First iteration Second iteration
× × 0 0 × × 0 0
0 × × 0 0 × × 0
0 0 × × −→ 0 0 × ×
0 0 0 × 0 0 0 ×
0 0 0 × 0 0 0 0
Third iteration Fourth iteration
where
* α̃11 is updated as part of the computation of the Householder vector;
T T T
* w12 := (a12 + u21 A22 )/τ1 ;
T T T
* ã12 := a12 − w12 ; and
T
* Ã22 := A22 − u21 w12 .
This introduces zeroes below the ”diagonal” in the first column:
× × × × × × × ×
× × × × 0 × × ×
× × × × −→ 0 × × ×
× × × × 0 × × ×
× × × × 0 × × ×
Chapter 17. Notes on Computing the SVD of a Matrix 286
The zeroes below α11 are not actually written. Instead, the implementation overwrites these
elements with the corresponding elements of the vector uT21 .
• Next, we introduce zeroes in the first row to the right of the element on the superdiagonal by com-
puting a Householder transformation from ãT12 :
– Let [v12 , ρ1 , a12 ] := HouseV(a12 ). This not only computes the Householder vector, but also
zeroes all but the first entry in ãT12 , updating that first entry.
– Update
aT12 aT12 α̃12 eT0
:= (I − 1 v12 vT12 ) =
A22 A22 ρ1 Ã22
where
T
* α̃12 equals the first element of the updated a12 ;
* w21 := A22 v12 /ρ1 ;
T
* Ã22 := A22 − w21 v12 .
This introduces zeroes to the right of the ”superdiagonal” in the first row:
× × × × × × 0 0
0 × × × 0 × × ×
0 × × × −→ 0 × × ×
0 × × × 0 × × ×
0 × × × 0 × × ×
– The zeros to the right of the first element of aT12 are not actually written. Instead, the imple-
mentation overwrites these elements with the corresponding elements of the vector vT12 .
The above observations are captured in the algorithm in Figure 17.1. It is also illustrated in Figure 17.2.
Homework 17.3 Homework 17.4 Give the approximate total cost for reducing A ∈ Rn×n to bidiagonal
form.
* SEE ANSWER
For a detailed discussion on the blocked algorithm that uses FLAME notation, we recommend [43]
Field G. Van Zee, Robert A. van de Geijn, Gregorio Quintana-Ortı́, G. Joseph Elizondo.
Families of Algorithms for Reducing a Matrix to Condensed Form.
ACM Transactions on Mathematical Software (TOMS) , Vol. 39, No. 1, 2012
17.3. The QR Algorithm with a Bidiagonal Matrix 287
where β10 BT00 el is (clearly) a vector with only a nonzero in the last entry.
The above proof also shows that if B has no zeroes on its superdiagonal, then neither does BT B.
This means that one can apply the QR algorithm to matrix BT B. The problem, again, is that this squares
the condition number of the problem.
The following extension of the Implicit Q Theorem comes to the rescue:
Theorem 17.6 Let C, B ∈ Rm×n . If there exist unitary matrices U ∈ Rm×m and V ∈ Rn×n so that B =
U T CV is upper bidiagonal and has positive values on its superdiagonal then B and V are uniquely deter-
mined by C and the first column of V .
The above theorem supports an algorithm that, starting with an upper bidiagonal matrix B, implicitly
performs a shifted QR algorithm with T = BT B.
Consider the 5 × 5 bidiagonal matrix
β β 0 0 0
0,0 0,1
0 β 0 0
1,1 β1,2
B= 0 0 β 2,2 β2,3 0 .
0 0 0 β3,3 β 3,4
0 0 0 0 β4,4
Then T = BT B equals
β20,0 ? 0 0 0
β β
0,1 0,0 ? ? 0 0
T =
0 0 ? ? 0 ,
0 0 0 ? ?
0 0 0 0 β23,4 + β24,4
Chapter 17. Notes on Computing the SVD of a Matrix 288
where the ?s indicate “don’t care” entries. Now, if an iteration of the implicitly shifted QR algorithm were
executed with this matrix, then the shift would be µk = β23,4 + β24,4 (actually, it is usually computed from
the bottom-right 2 × 2 matrix, a minor detail) and the first Givens’ rotation would be computed so that
γ σ0,1 2
β − µI
0,1 0,0
−σ0,1 γ0,1 β0,1 β1,1
has a zero second entry. Let us call the n × n matrix with this as its top-left submatrix G0 . Then applying
this from the left and right of T means forming G0 T G0 = G0 BT BGT0 = (BGT0 )T (BGT0 ). What if we only
apply it to B? Then
β˜ 0,0 β˜ 0,1 0 0 0 β0,0 β0,1 0 0 0 γ0,1 −σ0,1 0 0 0
β˜ β˜ 1,1 β1,2 0 0 0 β1,1 β1,2 0 0 σ γ0,1 0 0 0
1,0 0,1
=
.
0 0 β2,2 β2,3 0 0 0 β2,2 β2,3 0 0 0 1 0 0
0 0 0 β3,3 β3,4 0 0 0 β3,3 β3,4 0 0 0 1 0
0 0 0 0 β4,4 0 0 0 0 β4,4 0 0 0 0 1
The idea now is to apply Givens’ rotation from the left and right to “chasethe bulge”
except that now the
˜β0,0
rotations applied from both sides need not be the same. Thus, next, from one can compute γ1,0
β˜ 1,0
γ1,0 σ1,0 β˜ 0,0 β˜ 0,0
and σ1,0 so that = . Then
−σ1,0 γ1,0 β˜ 1,0 0
β˜ 0,0 β˜ 0,1
β˜ 02 0 0 γ1,0 σ1,0 0 0 0 β˜ 0,0 β˜ 0,1 0 0 0
β˜
0 1,1 β˜ 1,2 0 0 −σ
1,0 γ1,0 0 0 β˜ 1,0
0 β˜ 1,1 β1,2 0 0
0 0 0 = 0 0 1 0 0 .
0 0 0
β2,2 β2,3 β2,2 β2,3
0 0 0 β3,3 β3,4
0 0 0 1 0
0
0 0 β3,3 β3,4
0 0 0 0 β4,4 0 0 0 0 1 0 0 0 0 β4,4
˜β γ0,2 σ0,2 β˜
Continuing, from 0,1 one can compute γ0,2 and σ0,2 so that 0,1 =
β˜ 0,2 −σ0,2 γ0,2 β˜ 0,2
˜˜
β
0,2 . Then
0
˜ ˜
β˜ 0,0 β˜ 0,1
β0,0 β˜ 0,1 0 0 0 β˜ 02 0 0 1 0 0 0 0
˜
β˜
β˜ β˜ 1,2 β˜ 1,2
0
1,1 0 0
0 1,1 0 0 0
γ1,0 −σ1,0 0 0
β˜ 2,1 β˜ 2,2 =
0
β2,3 0 0 0 β2,2 β2,3 0 0
σ1,0 γ1,0 0 0
0 0 0 β3,3 β3,4 0 0 0 β3,3 β3,4 0
0 1 0 0
0 0 0 0 β4,4 0 0 0 0 β4,4 0 0 0 0 1
× × 0 0 0 × × × 0 0 × × 0 0 0
× × × 0 0 0 × × 0 0 0 × × 0 0
0 0 × × 0 −→ 0 0 × × 0 −→ 0 × × × 0 −→
0 0 0 × × 0 0 0 × × 0 0 0 × ×
0 0 0 0 × 0 0 0 0 × 0 0 0 0 ×
× × 0 0 0 × × 0 0 0
0 × × × 0 0 × × 0 0
0 0 × × 0 −→ 0 0 × × 0 −→
0 0 0 × × 0 0 × × ×
0 0 0 0 × 0 0 0 0 ×
× × 0 0 0 × × 0 0 0
0 × × 0 0 0 × × 0 0
0 0 × × × −→ 0 0 × × 0 −→
0 0 0 × × 0 0 0 × ×
0 0 0 0 × 0 0 0 × ×
× × 0 0 0
0 × × 0 0
0 0 × × 0
0 0 × ×
0 0 0 0 ×
Figure 17.3: Illustration of one sweep of an implicit QR algorithm with a bidiagonal matrix.
Chapter 17. Notes on Computing the SVD of a Matrix 290
Repartition
B00 β01 el 0 0 0
BT L BT M ? 0 β11 β12 0 0
0 BMM BMR → 0 0
β21 β22 β23
0 0 BBR 0
0 0 β33 β34 eT0
0 0 0 0 B44
whereτ11 and τ33 are scalars
(during final step, τ33 is 0 × 0)
γL1 σL1 β1,1 β˜ 1,1
Compute (γL1 , σL1 ) s.t. =
−σL1 γL1 β2,1 0
overwriting β1,1 with β˜ 1,1
β1,2 β1,3 γL1 σL1 β1,2 0
:=
β2,2 β2,3 −σL1 γL1 β2,2 β2,3
if m(BBR ) 6= 0
γR1 σR1 β1,2 β˜ 1,2
Compute (γR1 , σR1 ) s.t. =
−σR1 γR1 β1,3 0
overwriting β1,2 with β˜ 1,2
β1,2 0 β1,2 β1,3
γR1 −σR1
:= β2,2 β2,3
β2,2 β2,3
σR1 γR1
β3,2 β3,3 0 β3,3
Continue with
B00 β01 el 0 0 0
BT L BT M ? 0 β11 β12 0 0
0 ← 0 0
BMM BMR β21 β22 β23
0 0 BBR 0
0 0 β33 β34 eT0
0 0 0 0 B44
endwhile
Video
Read disclaimer regarding the videos in the preface!
* YouTube
* Download from UT Box
* View After Local Download
293
Chapter 18. Notes on Splitting Methods 294
Outline
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
18.1. A Simple Example: One-Dimensional Boundary Value Problem . . . . . . . . . . . 295
18.2. A Two-dimensional Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
18.2.1. Discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
18.3. Direct solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
18.4. Iterative solution: Jacobi iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
18.4.1. Motivating example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
18.4.2. More generally . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
18.5. The general case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
18.6. Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
18.6.1. Some useful facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
18.1. A Simple Example: One-Dimensional Boundary Value Problem 295
Au = h2 f ,
−∆u = f
18.2.1 Discretization
To solve the problem computationally with a computer, the problem is again discretized. Relating back
to the problem of the membrane on the unit square in the previous section, this means that the contin-
uous domain is viewed as a mesh instead, as illustrated in Figure 18.1. In that figure, υi will equal the
displacement from rest.
Now, just like before, we will let φi be the value of f (x, y) at the mesh point i. One can approximate
υ5 υ6 υ7 υ8
υ1 υ2 υ3 υ4
Figure 18.1: Discretized domain, yielding a mesh. The specific ordering of the elements of u, by rows,
is known as the “natural ordering”. If one ordered differently, for example randomly, this would induce
a permutation on the rows and columns of matrix A, since it induces a permutation on the order of the
indices.
becomes
u(x − h, y) + 2u(x, y) − u(x + h, y) u(x, y − h) + 2u(x, y) − u(x, y + h)
− − = f (x, y)
h2 h2
or, equivalently,
−u(x − h, y) − u(x, y − h) + 4u(x, y) − u(x + h, y) − u(x, y + h)
= f (x, y).
h2
If (x, y) corresponds to the point i in a mesh where the interior points form a N × N grid, this translates to
the system of linear equations
−υi−N − υi−1 + 4υi − υi+1 − υi+N = h2 φi .
This can be rewritten as
υi−N + υi−1 + υi+1 + υi+N
υi = h2 φi −
4
or
4υ1 − υ2 − υ5 = h2 φ0
−υ1 +4υ2 − υ3 −υ6 = h2 φ6
− υ2 +4υ3 − υ4 −υ7 = h2 φ2
(18.1)
− υ3 +4υ4 −υ8 = h2 φ3
−υ1 +4υ5 −υ6 −υ9 = h2 φ5
... ...... ... ... .
= ..
Chapter 18. Notes on Splitting Methods 298
This now shows how solving the discretized Laplace’s equation boils down to the solution of a linear
system Au = h2 f (= b), where A has a distinct sparsity pattern (pattern of nonzeroes).
Remark 18.1 The point is that many problems that arise in computational science require the solution to
a system of linear equations Au = b where A is a (very) sparse matrix.
Definition 18.2 Wilkinson defined a sparse matrix as any matrix with enough zeros that it pays to take
advantage of them.
It is tempting to simply use a dense linear solver to compute the solution to Au = b. This would require
O(n3 ) operations, where n equals the size of matrix A. One can take advantage of the fact that beyond the
outer band of “−1”s the matrix is entire zeroes to reduce the cost to O(nB2 ), where B equals the width of
the banded matrix. And there are sparse direct methods that try to further reduce fill-in of zeroes to bring
the number of operations required to factor to matrix. Details of these go beyond the scope of this note.
It is more common to solve sparse problems like our model problem via iterative methods which generate
a sequence of vectors u(k) , k = 0, . . .. The first vector, u(0) , represents an initial guess of what the solution
is. The hope is that u(k) converges to the solution u, in other words, that eventually u(k) becomes arbitrarily
close to the solution. More precisely, we would like for it to be the case that ku(k) − uk → 0 for some norm
k · k, where u is the true solution.
18.4. Iterative solution: Jacobi iteration 299
Consider Au = b. If we guessed perfectly, then u(0) would solve Ax = b and it would be the case that
Naturally, that is a bit optimistic. Therefore, a new approximation to the solution is created by computing
In other words, a new guess for the displacement ui at point i is generated by the values at the points
around it, plus some contribution from βi (which itself incorporates contributions from φi in our example).
This process can be used to compute a sequence of vectors u(0) , u(1) , . . . by similarly computing u(k+1)
from u(k) :
Typically, the physics of the problem dictates that this iteration will eventually yield a vector u(k) that is
arbitrarily close to the solution of Au = b. More on the mathematical reasons for this later. In other words,
the vectors u(k) will converge to u: limk→∞ u(k) = u or limk→∞ ku(k) − uk = 0.
Consider
(k+1) (k)
D00 0 0 x0 L00 0 0 U00 υ01 U02 υ0 b0
(k+1) (k)
= − l T
0 δ11 0 0 0 + 0 0 υ1 + β1 .
υ υ12
1 10
(k+1) (k)
0 0 D22 x2 L20 l21 L22 0 0 U22 υ2 b2
Then
(k+1) T (k) (k)
δ11 υ1 = β1 − l10 υ0 − υT12 υ2 .
T = aT , and υ = aT , so that
Now, for the Jacobi iteration δ11 = α11 , l10 10 12 12
This suggests the algorithm in Figure 18.2. For those who prefer indices (and for these kinds of iterations,
indices often clarify rather than obscure), this can be described as
(k+1) 1
(k)
= βi − αi j υ j .
υi
αii ∑
j 6= i
αi j 6= 0
Remark 18.3 It is not hard to see that, for the example of the discretized square, this yields exactly the
computations that compute u(k+1) from u(k) since there
0 1 1
1 0 1 1
1 0 1 1
1 0 1
1 0 1 1
−(L +U) =
...
1 1 0 1
1 1 0 1
1 1 0
...
1 0
.. .. ..
. . .
and D = 4I.
h i
Algorithm: x (k+1) := S PLITTING M ETHOD I TERATION(A, x(k) , b)
(k+1) (k)
xT AT L AT R x b
Partition x(k+1) → (k+1) , A → , x(k) → T , b → T
(k)
xB ABL ABR xB bB
(k+1) (k)
whereAT L is 0 × 0, xT , xT , bT have 0 elements
(k+1)
while m(xT ) < m(x(k+1) ) do
Repartition
(k+1)
x0 A a01 A02
xT
(k+1) AT L AT R 00
→ χ(k+1) , → aT α11 aT ,
xB
(k+1) 1 ABL ABR 10 12
(k+1)
x2 A20 a21 A22
(k)
x b
xT
(k) 0 b 0
→ (k) T → β1
,
χ
(k) 1
xyB (k) bB
x2 b2
(k+1) (k)
whereχ1 , α11 , χ1 , and β1 are scalars
Continue with
(k+1)
x0 A a A02
(k+1)
xT 00 01
(k+1) AT L AT R
← χ , ← aT α11 aT
,
(k+1) 1 10 12
xB (k+1)
ABL ABR
x2 A20 a21 A22
(k)
x b
(k)
xT 0 bT 0
(k)
← χ , ← β1
(k) 1
xB
(k) bB
x2 b2
endwhile
Figure 18.2: Various splitting methods (one iteration x(k+1) = M −1 (Nx(k) + b)).
formed: one solves with M instead. Now, a vector u is the solution of Au = b if and only if it satisfies
u = M −1 (Nu + b). The idea is to start with an initial guess (approximation) of u, u(0) , and to then iterate
to compute u(k+1) = M −1 (Nu(k) + b), which requires a multiplication with N and a solve with M in each
iteration.
18.5. The general case 303
Example 18.4 Let A ∈ Cn×n and split this matrix A = L + D +U, where L and U are the strictly lower and
upper triangular parts of A, respectively, and D its diagonal. Then choosing M = D and N = −(L + U)
yields the Jacobi iteration.
Proof: Notice Au = b implies that (M − N)u = b implies that Mu = Nu + b and hence u = M −1 (Nu + b).
Hence
u(k+1) − u = M −1 (Nu(k) + b) − M −1 (Nu + b) = M −1 N(u(k) − u).
Taking norms of both sides, one gets that
If kM −1 Nk < 1 then the right-hand side of this will converge to zero, meaning that u(k) converges to u.
Now, often one checks convergence by computing the residual r(k) = b − Au(k) . After all, if r(k) is
approximately the zero vector, then u(k) approximately solves Au = b. The following corollary links the
convergence of r(k) to the convergence of u(k) .
Corollary 18.6 Let A ∈ Cn×n be nonsingular and u, b ∈ Cn so that Au = b. Let u(k) ∈ Cn and let r(k) =
b − Au(k) . Then u(k) converges to u if and only if r(k) converges to the zero vector.
Proof: Assume that u(k) converges to u. Note that r(k) = b − Au(k) = Au − Au(k) = A(u − u(k) ). Since A is
nonsingular, clearly r(k) converges to the zero vector if and only if u(k) converges to u.
Now let us see how to extract a more detailed algorithm from this. Partition, conformally,
A00 a01 A02 M00 m01 M02 N n01 N02
00
A = aT10 α11 aT12 , M = mT10 µ11 mT12 , N = nT10 ν11 nT12 ,
A20 a21 A22 M20 m21 M22 N20 n21 N22
(k)
x0 b
0
(k) (k)
u = , and b = β1 .
υ1
(k)
x2 b2
Chapter 18. Notes on Splitting Methods 304
Consider
(k+1) (k)
M m01 M02 x0 N n01 N02 x0 b
00 00 0
T (k+1) (k)
m10 µ11 mT12
T
= n10 ν11 nT12 + β1 .
υ1 υ1
(k+1) (k)
M20 m21 M22 x2 N20 n21 N22 x2 b2
Then
(k+1) (k+1) (k+1) (k) (k) (k)
mT10 x0 + µ11 υ1 + mT12 x2 = nT10 x0 + ν11 υ1 + nT12 x2 + β1 .
Jacobi iteration
Example 18.8 For the Jacobi iteration mT10 = 0, µ11 = α11 , mT12 = 0, nT10 = −aT10 , ν11 = 0, and nT12 = −aT10 ,
so that
(k+1) (k) (k)
υ1 = (β1 − aT10 x0 − aT12 x2 )/α11 .
Gauss-Seidel iteration A modification of the Jacobi iteration is inspired by the observation that in
Eqns. (18.1)–(18.2) when computing υi one could use the new (updated) values for υ j , j < i:
(k+1)
4 υ1
(k+1)
−1 4 υ
2
(k+1)
−1 4 υ
3
(k+1)
−1 4 υ4
(k+1)
−1
4 υ5
(k+1)
−1 −1 4
υ6
(k+1)
−1 −1 4 υ
7
(k+1)
−1 −1 4 υ
8
(k+1)
−1 4 υ
9
.. .. .. ..
. . . .
(k)
0 1 1 υ
1
(k)
0 0 1 1
υ2
0 0 1 1 (k)
υ3
(k)
0 0 1 υ
4
(k)
0 0 1 1 υ
5
= + b.
. ..
(k)
0 0 0 1 υ
6
(k)
0 0 0 1 υ7
(k)
0 0 0
υ8
... (k)
0 0
υ9
.. .. ..
..
. . . .
Again, split A = L + D +U and partition these matrices as in (18.3) and (18.4). Consider
(k+1) (k)
D00 + L00 0 0 x0 U00 υ01 U02 x0 b0
(k+1) (k)
T = − 0
l10 δ11 0 0 υ1 + β1 .
υ υ12
1
(k+1) (k)
L20 l21 D22 + L22 x2 0 0 U22 x2 b2
Then
T (k+1) (k+1) (k)
l10 x0 + δ11 υ1 = β1 − υT12 x2 .
T = aT , and υ = aT , so that
Now, for the Gauss-Seidel iteration δ11 = α11 , l10 10 12 12
This suggests the algorithm in Figure 18.2. For those who prefer indices, this can be described as
i−1 n−1
(k+1) 1 (k+1)
(k)
= βi − − αi j υ j .
υi
αii ∑ αi j υ j ∑
j=0 j = i+1
αi j 6= 0 αi j 6= 0
Notice that this fits the general framework since now M = L + D and N = −U.
Successive Over Relaxation (SOR) Consider the update as performed by the Gauss-Seidel iteration
for some relaxation parameter ω = 1 + α. Going further would mean picking ω > 1. Then
or
α11 (k+1) 1 − ω
(k+1) (k) (k)
aT10 x0 υ1 + = α11 υ1 − aT12 x2 + β1 .
ω ω
Now, if one once again partitions A = L + D +U and one takes M = L + ω1 D and N = 1−ω
ω D −U then
it can be easily checked that Mu(k+1) = Nu(k) + b. Thus,
1 −1 1 − ω
ku(k) − uk ≤ k(L + D) ( D −U)kk ku(0) − uk = k(ωL + D)−1 ((1 − ω)D − ωU)kk ku(0) − uk.
ω ω
The idea now is that by choosing ω carefully,
Symmetric Successive Over Relaxation Gauss-Seidel and SOR update the unknowns in what is called
the natural ordering meaning that one updates υ0 , υ1 , · · · in that prescribed order, using the most recently
updated values and, in the case of SOR, extrapolating the update. The iteration can be made symmetric by
updating first in the natural ordering and then updating similarly, but in reverse natural ordering.
1 1−ω
Then this is equivalent to choosing MF = L + ω D and NF = ω D −U (the Forward splitting)
and MB = U + ω1 D and NB = 1−ω
ω D − L (the Backward splitting). Then
MF u(k+1/2) = NF u(k) + b
MB u(k+1) = NB u(k+1/2) + b,
or,
h h i i
= (ωU + D)−1 ((1 − ω)D − ωL) (ωL + D)−1 ((1 − ω)D − ωU) u(k) + b + b
h h i i
−1 −1 (k)
= (ωU + D) ((1 − ω)D − ωL) (ωL + D) ((1 − ω)D − ωU) u + ωb + ωb
18.6 Theory
Theorem 18.9 Let k·k be matrix norm induced by a vector norm k·k. Then for any A ∈ Cm×n ρ(A) ≤ kAk.
Theorem 18.11 Given a matrix A ∈ Cn×n and ε > 0, there exists a consistent matrix norm k · k such that
kAk ≤ ρ(A) + ε.
Proof: Let
T
ρ(A) t01 H
H
A = UTU = u0 U1 u0 U1
0 T11
be a Schur decomposition of A. Define k · k by
T 1 0
kXk =
U XU
.
0 ε/kAk2 I
2
.
18.6. Theory 309
(⇐) Assume ρ(M −1 N) < 1. Pick ε such that ρ(M −1 N) + ε < 1. Finally, pick k · k such that kM −1 Nk ≤
ρ(M −1 N) + ε. Then kM −1 Nk < 1 and hence the sequence converges.
(⇒) We will show that if ρ(M −1 N) ≥ 1 then there exists a x(0) such that the iteration does not converge.
Let y 6= 0 have the property that M −1 Ny = ρ(M −1 N)y. Choose x(0) = y + x where Ax = b. Then
kx(1) − xk = kM −1 N(x(0) − x)k = kM −1 Nyk = kρ(M −1 N)yk
= ρ(M −1 N)kyk = ρ(M −1 N)kx(0) − xk ≥ kx(0) − xk.
Extending this, one finds that for all k, kx(k) − xk = kM −1 N(x(0) − x)k. Thus, the sequence does not
converge.
Definition 18.13 A matrix A ∈ Cn×n is said to be diagonally dominant if for all i, 0 ≤ i < n
|αi,i | ≥ ∑ |αi, j |.
j6=i
In other words, a matrix is reducible if and only if there exists a symmetric permutation of the rows and
columns that leaves the matrix block upper triangular.
Homework 18.17 A symmetric matrix A ∈ Cn×n is reducible if and only if there exists a permutation
matrix P such that
TTL 0
PAPT = ,
0 TBR
where TT L (and hence TBR ) is square of size b × b where 0 < b < n.
In other words, a symmetric matrix is reducible if and only if there exists a symmetric permutation of the
rows and columns that leaves the matrix block diagonal.
Theorem 18.18 If A is strictly diagonally dominant, then the Jacobi iteration converges.
Proof: Let
α0,0 0 ··· 0 0 −α0,0 · · · −α0,n−1
0 α1,1 · · · 0 −α
1,0 0 · · · −α1,n−1
A= . − .
.. .. .. .. .
.. .
.. .. ..
. . .
. .
0 0 · · · αn−1,n−1 −αn−1,0 −αn−1,1 · · · 0
| {z } | {z }
M N
Then
−1
α0,0 0 ··· 0 0 −α0,1 · · · −α0,n−1
−1
0 α1,1 · · · 0 −α
1,0 0 · · · −α1,n−1
M N = .
.. .. ... .. .. .. ... ..
. .
. . .
0 0 · · · αn−1,n−1 −αn−1,0 −αn−1,1 · · · 0
α α0,n−1
0 − α0,1
0,0
··· − α0,0
α1,0 α1,n−1
− α1,1 0 ··· − α1,1
= .. .. .. ..
.
. . .
αn−1,0 n−1,1 α
− αn−1,n−1 − αn−1,n−1 ··· 0
|αi, j |
∑ |αi, j | < 1.
j6=i
By the Gershgorin Disk Theorem we therefore know that ρ(M −1 N) < 1. Hence we know there exists a
norm k · k such that kM −1 Nk < 1, and hence the Jacobi iteration converges.
18.6. Theory 311
Theorem 18.19 If A is strictly diagonally dominant, then the Gram-Schmidt iteration converges.
Proof:
Theorem 18.20 If A is weakly diagonally dominant, irreducible, and has at least one row for which
Proofs of these last few observations will be added to this notes in the future.
Chapter 18. Notes on Splitting Methods 312
Chapter 19
Notes on Descent Methods and the Conjugate
Gradient Method
In this note, we assume that the n × n matrix A is Symmetric Positive Definite. We are interested in
iterative solving the linear system Ax = b. We will do so by creating a sequence of approximate solutions,
{x(0) , x(1) , . . .} that, hopefully, converge to the true solution x.
313
Chapter 19. Notes on Descent Methods and the Conjugate Gradient Method 314
Outline
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
19.1. Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
19.2. Descent Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
19.3. Relation to Splitting Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
19.4. Method of Steepest Descent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
19.5. Preconditioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
19.6. Methods of A-conjugate Directions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
19.7. Conjugate Gradient Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
19.1. Basics 315
19.1 Basics
The basic idea is to look at the problem of solving Ax = b instead as the minimization problem that finds
the vector x that minimizes the function f (x) = 12 xT Ax − xT b.
Theorem 19.1 Let A be SPD and assume that Ax = b. Then the vector x minimizes the function f (y) =
1 T T
2 y Ay − y b.
The basic idea behind a descent method is that at the kth iteration one has an approximation to x, x(k) . One
would like to create a better approximation, x(k+1) . To do so, one picks a search direction, p(k) , and lets
x(k+1) = x(k) + αk p(k) . In other words, one searches for a minimum along a line defined by the current
iterate, x(k) , and the search direction, p(k) . One then picks αk so that, preferrably, f (x(k+1) ) ≤ f (x(k) ).
Typically, one picks αk to exactly minimize the function along the line (leading to exact descent methods).
Now
1
f (x(k+1) ) = f (x(k) + αk p(k) ) = (x(k) + αk p(k) )T A(x(k) + αk p(k) ) − (x(k) + αk p(k) )T b
2
1 (k) T (k) 1
= x Ax + αk p(k) T Ax(k) + α2k p(k) T Ap(k) − x(k) T b − αk p(k) T b
2 2
1 (k) T (k) 1
= x Ax − x(k) T b + αk p(k) T Ax(k) + α2k p(k) T Ap(k) − αk p(k) T b
2 2
1
= f (x(k) ) + α2k p(k) T Ap(k) + αk p(k) T (Ax(k) − b)
2
1
= f (x(k) ) + p(k) T Ap(k) α2k − p(k) T r(k) αk ,
2
where r(k) = b − Ax(k) , the residual. This is a quadratic equation in αk (since this is the only free variable).
Thus, minimizing this expression exactly requires the deriviative with respect to αk to be zero:
d f (x(k) + αk p(k) )
0= = p(k) T Ap(k) αk − p(k) T r(k) .
dαk
Chapter 19. Notes on Descent Methods and the Conjugate Gradient Method 316
Figure 19.1: Three basic descent method. The formulation on the middles follows from the one on the left
by virtue of b − Ax(k+1) = b − A(x(k) + αk p(k) ) = r(k) − αk Ap(k) . It is preferred because it requires only
one matrix-vector multiplication per iteration (to form Ap(k) . The one of the right overwrites the various
vectors to reduce storage.
p(k) T r(k)
αk = and x(k+1) = x(k) + αk p(k) .
p(k) T Ap(k)
A question now becomes how to pick the search directions {p(0) , p(1) , . . .}.
Basic decent methods based on these ideas are given in Figure 19.1. What is missing in those algo-
rithms is a stopping criteria. Notice that αk = 0 if p(k) T r(k) = 0. But this does not necessarily mean that we
have converged, since it merely means that p(k) is orthogonal to r(k) . What we will see is that commonly
used methods pick p(k) not to be orthogonal to r(k) . Then p(k) T r(k) = 0 implies r(k) = 0 and this condition,
cheap to compute, can be used as a stopping criteria.
• p(0) = e0 .
• r(0) = Ax(0) − b.
• p(0) T r(0) = eT0 (Ax(0) − b) = eT0 Ax(0) − eT0 b = abT0 x(0) − β0 , where abi denotes the ith row of A.
19.4. Method of Steepest Descent 317
Careful contemplation then reveals that this is exactly how the first element in vector x is changed
in the Gauss-Seidel method!
We leave it to the reader to similarly deduce that x(n) is exactly the vector one gets from applying one step
of Gauss-Seidel (updating all elements of x once):
x(n) = D−1 ((L + LT )x(0) + b)
where D and −(L + LT ) equal the diagonal and off-diagonal parts of A so that A = M − N = D − (L + LT ).
Given that choosing the search directions cyclically as {e0 , e1 , . . .} yields the Gauss-Seidel iteration,
one can image picking x(k+1) = x(k) + ωαk p(k) , with some relaxation factor ω. This would yield SOR if
we continue to use, cyclically, the search directions {e0 , e1 , . . .}.
When the next iterate is chosen to equal the exact minimum along the line defined by the search
direction, the method is called an exact descent direction and it is, clearly, guaranteed that f (x(k+1) ) ≤
f (x(k) ). When a relaxation parameter ω 6= 1 is used, this is no longer the case, and the method is called
inexact.
19.5 Preconditioning
For general nonlinear f (x), using the direction of steepest descent as the search direction is often effective.
Not necessarily so for our problem, if A is relatively ill-conditioned.
A picture clarifies this (on the blackboard). The key insight is that if κ(A) = λ0 /λn−1 (the ratio between
the largest and smallest eigenvalues or, equivalently, the ratio between the largest and smallest singular
value), then convergence can take many iterations.
What would happen if λ0 = · · · = λn−1 ? Then A = QΛQT is the spectral decomposition of A and
A = Q(λ0 I)QT = λ0 I and
and the search directions were linearly independent. The primary reason is that then the descent direction
method is guaranteed to complete in at most n iterations, since then
S (p(0) , . . . , p(n−1) ) = Rn
so that
f (x(n) ) = min f (x) = minn f (x)
x∈S (p(0) ,...,p(n−1) ) x∈R
so that Ax(n) = b.
19.6. Methods of A-conjugate Directions 319
Figure 19.2: Left: method of steepest decent. Middle: method of steepest decent with transformed prob-
lem. Right: preconditioned method of steepest decent. It can be checked that the x(k) computed by
the middle algorithm is exactly the x(k) computed by the one on the right. Of course, the computation
x(k+1) = L−T x̃(k+1) needs only be done once, after convergence, in the algorithm in the middle.
Unfortunately, the method of steepest descent does not have this property. The iterate x(k+1) minimizes
f (x) where x is constraint to be on the line x(k) + αp(k) . Because in each step f (x(k+1) ) ≤ f (x(k) ), a slightly
stronger result holds: It also minimizes f (x) where x is constraint to be on the union of lines x( j) + αp( j) ,
(0) (k)
over all vectors in S (p , . . . , p ).
j = 0, . . . , k. However, that is not the same as it minimizing
We can write write (19.1) more concisely: Let P(k) = p(0) p(1) · · · p(k) . Then
y0
min f (x) = min f (P(k) y) = min f ( P(k−1) p(k) )
(0) (k)
x∈S (p ,...,p ) y y ψ1
T
1 y0 y
= min P(k−1) p(k) A P(k−1) p(k) 0
y 2 ψ1 ψ1
T
y0
− P(k−1) p(k) b .
ψ1
h
1 T (k−1) T (k) T
i h
(k−1) (k)
i
= min y P + ψ1 p A P y0 + ψ1 p
y 2 0
h i i
− yT0 P(k−1) T + ψ1 p(k) T b
1 T (k−1) T (k−1) T (k−1) T (k) 1 2 (k) T (k) T (k−1) T (k) T
= min y0 P AP y0 + ψ1 y0 P Ap + ψ1 p Ap − y0 P b − ψ1 p b
y 2 2
Chapter 19. Notes on Descent Methods and the Conjugate Gradient Method 320
1 T (k−1) T (k−1) T (k−1) T T (k−1) T (k) 1 2 (k) T (k) (k) T
= min y0 P AP y0 − y0 P b + ψ1 y0 P Ap + ψ1 p Ap − ψ1 p b .
y 2 2
y0
where y = . Now, if
ψ1
P(k−1) T Ap(k) = 0
then
Definition 19.2 Let p(0) , . . . , p(k−1) ∈ Rn and A be SPD. Then this sequence of vectors is said to be A-
conjugate if p( j) T Ap(k) = 0 if and only if j 6= k.
endfor
Now, if r(k+1) = 0, then we know that x(k+1) solves Ax = b, and we are done. So, we can assume that
r(k+1) 6= 0. How can we construct a new p(k+1) such that p(k+1) T Ap(k) = 0. For the Conjugate Gradient
method we pick
p(k+1) = r(k+1) + γk p(k)
such that
T
p(k+1) Ap(k) = 0.
Now,
0 = p(k+1) T Ap(k) = (r(k+1) + γk p(k) )T Ap(k) = r(k+1) T Ap(k) + γk p(k) T Ap(k )
so that
r(k+1) T Ap(k)
γk = − .
p(k) T Ap(k)
Now, it can be shown that not only p(k+1) T Ap(k) , but also p(k+1) T Ap( j) , for j = 0, 1, . . . , k. Thus, the
Conjugate Gradient Method is an A-conjugate method.
Working these insights into the basic descent method algorithm yields the most basic form of the
Conjugate Gradient method, summarized in Figure 19.3 (left).
Chapter 19. Notes on Descent Methods and the Conjugate Gradient Method 322
Chapter 20
Notes on Lanczos Methods
In this note, we give a brief overview of the ideas behind Lanczos Methods. These methods are useful
when computing (some) eigenvalues and eigenvectors of a sparse matrix.
323
Chapter 20. Notes on Lanczos Methods 324
Outline
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
20.1. Krylov Subspaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
20.1. Krylov Subspaces 325
From our discussion of the Power Method, we notice that it is convenient to instead work with mutually
orthonormal vectors. Consider the QR factorization of K(A, q0 , n):
1 ρ0,1 . . . ρ0,n−1
0 ρ1,1 . . . ρ1,n−1
K(A, q0 , n) = q0 x1 . . . xn−1 = q0 q1 . . . qn−1 . = QR
.. .
.. . .. .
..
0 0 · · · ρn−1,n−1
Notice that
AK(A, q0 , n) = A q0 x1 . . . xn−1 = x1 . . . xn−1 Axn−1 .
Partition
T
1 r01
K(A, q0 , n) = q0 X1 ,Q = q0 Q1 , and R = .
0 R11
Then
K(A, q0 , n) = A q0 X1 = X1 Axn−1
and hence
1 T
r01
K(A, q0 , n) = A q0 Q1 = T
Q1 R11 − q0 r01 Axn−1
0 R11
Now, notice that
T
QT AQR = q0 Q1 A q0 Q1 R
T
= q0 Q1 T
Q1 R11 − q0 r01 Axn−1
T T
= (Q R − q r T ) Ax
q0 Q1 1 11 0 01 q0 Q1 n−1
rT qT0 Axn−1
= 01 .
R11 QT1 Axn−1
Chapter 20. Notes on Lanczos Methods 326
so that
T00 ? 0 0
τ10 eTL
τ11 ? 0
A Q0 q1 q2 Q3 = Q0 q1 q2 Q3
0 τ21 τ22 ?
0 0 τ32 e0 T33
which means that τ11 := qT1 u. This allows us to update u := u − τ11 q1 = Aq1 − τ10 Q0 e1 − τ11 q1 . We
notice that now τ21 q2 = u and hence we can choose τ21 := kq2 k2 , since q2 must have length one, and then
q2 := u/τ21 . We then create a new vector u := Aq2 − τ21 q1 . This allows us to move where we are in the
matrices forward:
QL qM QR ← Q0 q1 q2 Q3
and
T ? 0 0
TT L ? 0 00
τ10 eT
τ11 ? 0
L
τML eTL ? ← ,
τMM
0 ?
τ21 τ22
0 τBM e0 TBR
0 0 τ32 e0 T33
Repartition
QL qM QR → q1 q2 Q3 ,
Q0
T ? 0 0
TT L ? 0 00
T ? ?
τ10 eL τ11
T
τML eL τMM ? →
0 τ21 τ22 ?
0 τBM e0 TBR
0 0 τ32 e0 T33
whereq2 has 1 column, τ22 is 1 × 1
τ11 := qT1 u
u := u − τ11 q1
τ21 := kq2 k2
q2 := u/τ21
u := Aq2 − τ21 q1
Continue with
QL qM QR → Q0 q1 q2 Q3 ,
T ? 0 0
TT L ? 0 00
τ10 eT τ11
? ?
L
τML eTL τMM ? ←
0 ?
τ21 τ22
0 τBM e0 TBR
0 0 τ32 e0 T33
endwhile
Figure 20.1: Lanscos algorithm for symmetric Q. It computes Q and T such that AQ = QT . It lacks a
stopping criteria.
20.1. Krylov Subspaces 329
• If q2 represents the kth column of Q, then it is in thedirection of (Ak−1 q0 )⊥ , the component of
Ak−1 q0 that is orthogonal to the columns of Q0 q1 .
• As k gets large, Ak−1 q0 is essentially in the space spanned by Q0 q1 .
• q2 is computed from
τ21 q2 = Aq1 − τ10 Q0 eL − τ11 q1 .
• The length of Aq1 − τ10 Q0 eL − τ11 q1 must be very small as k gets large since Ak−1 q0 eventually lies
approximately in the direction of Ak−2 q0 .
• Hence
T00 ? 0 0
τ10 eTL
τ11 0 0
A Q0 q1 q2 Q3 ≈ Q0 q1 q2 Q3
0 0 ? ?
0 0 ? ?
or, equivalently,
T00 ?
A Q0 q1 ≈ Q0 q1 = S,
τ10 eTL τ11
where S is a (k − 1) × (k − 1) tridiagonal matrix.
Here the space spanned by Q0 q1 , C ( Q0 q1 ), is said to be an invariant subspace of
matrix A.
S = QS ΛS QTS
then h i h i
A Q0 q1 QS ≈ Q0 q1 QS ΛS .
Repartition
QL qM QR → q1 q2 Q3 ,
Q0
T ? 0 0
TT L ? 0 00
T ? ?
τ10 eL τ11
T
τML eL τMM ? →
0 τ21 τ22 ?
0 τBM e0 TBR
0 0 τ32 e0 T33
whereq2 has 1 column, τ22 is 1 × 1
τ11 := qT1 u
u := u − τ11 q1
τ21 := kq2 k2
if |τ | > tolerance
21
q2 := u/τ21
u := Aq2 − τ21 q1
Continue with
QL qM QR → Q0 q1 q2 Q3 ,
T ? 0 0
TT L ? 0 00
τ10 eTL τ11 ? ?
T
? ←
τML eL τMM
0 ?
τ21 τ22
0 τBM e0 TBR
0 0 τ32 e0 T33
endwhile
Figure 20.2: Lanscos algorithm for symmetric Q. It computes QL and TT L such that AQL ≈ QL TT L .
More Chapters to be Added in the Future!
331
Chapter 20. Notes on Lanczos Methods 332
Answers
T
abT0
abT
1
• . = ab0 ab1 · · · abn−1 .
..
abTm−1
aH
0
H aH
1
• a0 a1 · · · an−1 = . .
..
aH
m−1
333
H
abT0
abT
1
• . = ab0 ab1 · · · abn−1 .
..
abTm−1
* BACK TO TEXT
* BACK TO TEXT
334
T
A0,0 A0,1 ··· A0,N−1 AT0,0 AT1,0 ··· ATM−1
A1,0 A1,1 ··· A1,N−1 AT AT1,1 · · · ATM−1,1
0,1
• = .
.. .. .. .. .. ..
. . ··· .
. . ··· .
AM−1,0 AM−1,1 · · · AM−1,N−1 AT0,N−1 AT1,N−1 · · · ATM−1,N−1
H
A0,0 A0,1 ··· A0,N−1 AH
0,0 AH
1,0 ··· AH
M−1
A1,0 A1,1 ··· A1,N−1 AH AH · · · AH
0,1 1,1 M−1,1
• = .
.. .. .. .
.. .
.. ..
. . ··· .
··· .
AM−1,0 AM−1,1 · · · AM−1,N−1 H H H
A0,N−1 A1,N−1 · · · AM−1,N−1
* BACK TO TEXT
• (αx)T = αxT .
• (αx)H = αxH .
x0 αx0
x1 αx1
• α . =
.. ..
.
xN−1 αxN−1
* BACK TO TEXT
* BACK TO TEXT
335
H
x0 y0
x1 y1
• . = ∑N−1 H ni N−1
i=0 xi yi . (Provided xi , yi ∈ C and ∑i=0 ni = n.)
.
.. ..
xN−1 yN−1
* BACK TO TEXT
336
Chapter 2. Notes on Vector and Matrix Norms (Answers)
Homework 2.2 Prove that if ν : Cn → R is a norm, then ν(0) = 0 (where the first 0 denotes the zero vector
in Cn ).
Answer: Let x ∈ Cn and ~0 the zero vector of size n and 0 the scalar zero. Then
ν(~0) = ν(0 · x) 0 · x = ~0
= |0|ν(x) ν(·) is homogeneous
= 0 algebra
* BACK TO TEXT
Notice that x 6= 0 means that at least one of its components is nonzero. Let’s assume that
χ j 6= 0. Then
kxk1 = |χ0 | + · · · + |χn−1 | ≥ |χ j | > 0.
* BACK TO TEXT
337
• x 6= 0 ⇒ kxk∞ > 0 (k · k∞ is positive definite):
Notice that x 6= 0 means that at least one of its components is nonzero. Let’s assume that
χ j 6= 0. Then
kxk∞ = max |χi | ≥ |χ j | > 0.
i
* BACK TO TEXT
In other words, it equals the vector 2-norm of the vector that is created by stacking the columns of A on
top of each other. The fact that the Frobenius norm is a norm then comes from realizing this connection
and exploiting it.
Alternatively, just grind through the three conditions!
* BACK TO TEXT
abT0
abT
1
Homework 2.20 Let A ∈ Cm×n and partition A = . . Show that
..
abTm−1
kAk∞ = max kb
ai k1 = max (|αi,0 | + |αi,1 | + · · · + |αi,n−1 |)
0≤i<m 0≤i<m
338
abT0
abT
1
Answer: Partition A = . . Then
..
abTm−1
a T
a Tx
b 0
b 0
abT
abT x
1
1
kAk∞ = max kAxk∞ = max
. x
= max
kxk∞ =1 kxk∞ =1
..
kxk∞ =1
.
..
abT
abT x
m−1 ∞ m−1 ∞
n−1 n−1
= max max |aTi x| = max max | ∑ αi,p χ p | ≤ max max ∑ |αi,p χ p |
kxk∞ =1 i kxk∞ =1 i p=0 kxk∞ =1 i p=0
n−1 n−1 n−1
= max max ∑ (|αi,p ||χ p |) ≤ max max ∑ (|αi,p |(max |χk |)) ≤ max max ∑ (|αi,p |kxk∞ )
kxk∞ =1 i p=0 kxk∞ =1 i p=0 k kxk∞ =1 i p=0
n−1
= max ∑ (|αi,p | = kb
ai k1
i p=0
* BACK TO TEXT
339
Homework 2.21 Let y ∈ Cm and x ∈ Cn . Show that kyxH k2 = kyk2 kxk2 .
Answer: Answer needs to be filled in.
* BACK TO TEXT
kABkµ,ν = max kABxkµ ≤ max kAkµ,ν kBxkν = kAkµ,ν max kBxkν = kAkµ,ν kBkν
kxkν =1 kxkν =1 kxkν =1
* BACK TO TEXT
so that kABk2F ≤ kAk22 kBk22 . Taking the square-root of both sides established the desired result.
* BACK TO TEXT
340
Homework 2.28 Let k · k be a matrix norm induced by the k · · · k vector norm. Show that κ(A) =
kAkkA−1 k ≥ 1.
Answer:
kIk = kAA−1 k ≤ kAkkA−1 k.
But
kIk = max kIxk = max kxk = 1.
kxk=1 kxk
Hence 1 ≤ kAkkA−1 k.
* BACK TO TEXT
341
Chapter 3. Notes on Orthogonality and the SVD (Answers)
Homework 3.4 Let Q ∈ Cm×n (with n ≤ m). Partition Q = q0 q1 · · · qn−1 . Show that Q is an
orthonormal matrix if and only if q0 , q1 , . . . , qn−1 are mutually orthonormal.
Answer: Answer needs to be filled in.
* BACK TO TEXT
Homework 3.6 Let Q ∈ Cm×m . Show that if Q is unitary then Q−1 = QH and QQH = I.
Answer: If Q is unitary, then QH Q = I. If A, B ∈ Cm×m , the matrix B such that BA = I is the inverse of
A. Hence Q−1 = QH . Also, if BA = I then AB = I and hence QQH = I.
* BACK TO TEXT
Homework 3.7 Let Q0 , Q1 ∈ Cm×m both be unitary. Show that their product, Q0 Q1 , is unitary.
Answer: Obviously, Q0 Q1 is a square matrix.
(Q0 Q1 )H (Q0 Q1 ) = QH H
QH
1 Q0 Q0 Q1 = | 1 = I.
1{zQ}
| {z }
I I
Hence Q0 Q1 is unitary.
* BACK TO TEXT
Homework 3.8 Let Q0 , Q1 , . . . , Qk−1 ∈ Cm×m all be unitary. Show that their product, Q0 Q1 · · · Qk−1 , is
unitary.
Answer: Strictly speaking, we should do a proof by induction. But instead we will make the more
informal argument that
= QH H
k−1 · · · Q1 |QH
0 Q0 Q1 · · · Qk−1 = I.
{z }
I
| {z }
I
| {z }
I
| {z }
I
* BACK TO TEXT
342
Homework 3.9 Let U ∈ Cm×m be unitary and x ∈ Cm , then kUxk2 = kxk2 .
H
Answer: kUxk22 = (Ux)H (Ux) = xH U H 2
| {zU} x = x x = kxk2 . Hence kUxk2 = kxk2 .
I
* BACK TO TEXT
Homework 3.10 Let U ∈ Cm×m and V ∈ Cn×n be unitary matrices and A ∈ Cm×n . Then
kUAk2 = kAV k2 = kAk2 .
Answer:
• kUAk2 = maxkxk2 =1 kUAxk2 = maxkxk2 =1 kAxk2 = kAk2 .
• kAV k2 = maxkxk2 =1 kAV xk2 = maxkV xk2 =1 kA(V x)k2 = maxkyk2 =1 kAyk2 = kAk2 .
* BACK TO TEXT
Homework 3.11 Let U ∈ Cm×m and V ∈ Cn×n be unitary matrices and A ∈ Cm×n . Then kUAkF =
kAV kF = kAkF .
Answer:
n−1
• Partition A = a0 a1 · · · an−1 . Then it is easy to show that kAk2F = ∑ j=0 ka j k22 . Thus
kUAk2F = kU a0 a1 · · · an−1 k2F = k Ua0 Ua1 · · · Uan−1 k2F
n−1 n−1
= ∑ kUa j k22 = ∑ ka j k22 = kAk2F .
j=0 j=0
abTm−1 abTm−1V
m−1 m−1
= ∑ aTi )H k22 =
kV H (b ∑ k(baTi )H k22 = kAk2F .
i=0 i=0
343
* BACK TO TEXT
n−1
kDk2 = max kDxk2 ≥ kDe j k2 = kδ j e j k2 = |δ j |ke j k2 = |δ j | = max |δi |.
kxk2 =1 i=0
AT
Homework 3.14 Let A = . Use the SVD of A to show that kAk2 = kAT k2 .
0
Answer: Let AT = UT ΣT VTH be the SVD of A. Then
AT U Σ V H U
A= = T T T = T ΣT VTH ,
0 0 0
which is the SVD of A. As a result, cleary the largest singular value of AT equals the largest singular value
of A and hence kAk2 = kAT k2 .
* BACK TO TEXT
344
Homework 3.15 Assume that U ∈ Cm×m and V ∈ Cn×n be unitary matrices. Let A, B ∈ Cm×n with B =
UAV H . Show that the singular values of A equal the singular values of B.
Answer: Let A = UA ΣAVAH be the SVD of A. Then B = UUA ΣAVAH V H = (UUA )ΣA (VVA )H where both
UUA and VVA are unitary. This gives us the SVD for B and it shows that the singular values of B equal the
singular values of A.
* BACK TO TEXT
σ0 0
Homework 3.16 Let A ∈ Cm×n with A = and assume that kAk2 = σ0 . Show that kBk2 ≤
0 B
kAk2 . (Hint: Use the SVD of B.)
Answer: Let B = UB ΣBVBH be the SVD of B. Then
H
σ0 0 σ 0 1 0 σ 0 1 0
A= = 0 = 0
0 B 0 UB ΣBVBH 0 UB 0 ΣB 0 VB
which shows the relationship between the SVD of A and B. Since kAk2 = σ0 , it must be the case that the
diagonal entries of ΣB are less than or equal to σ0 in magnitude, which means that kBk2 ≤ kAk2 .
* BACK TO TEXT
• Inductive step: Similarly modify the inductive step of the proof of the theorem.
345
• By the Principle of Mathematical Induction the result holds for all matrices A ∈ Cm×n with m ≥ n.
* BACK TO TEXT
• κ2 (A) = σ0 /σm−1 .
346
Chapter 4. Notes on Gram-Schmidt QR Factorization (Answers)
Homework 4.1 • What happens in the Gram-Schmidt algorithm if the columns of A are NOT linearly
independent?
Answer: If a j is the first column such that {a0 , . . . , a j } are linearly dependent, then a⊥j will equal
the zero vector and the process breaks down.
• How can the Gram-Schmidt algorithm be used to identify which columns of A are linearly indepen-
dent?
Answer: Again, if a⊥j = 0 for some j, then the columns are linearly dependent.
* BACK TO TEXT
Homework 4.2 Homework 4.3 Convince yourself that the relation between the vectors {a j } and {q j }
in the algorithms in Figure 4.2 is given by
ρ0,0 ρ0,1 · · · ρ0,n−1
0 ρ1,1 · · · ρ1,n−1
a0 a1 · · · an−1 = q0 q1 · · · qn−1 . ,
.. .
.. . .. .
..
0 0 · · · ρn−1,n−1
where
H for i < j
qi a j
1 for i = j
H j−1
qi q j = and ρi, j = ka j − ∑i=0 ρi, j qi k2 for i = j
0 otherwise
0 otherwise.
Homework 4.5 Homework 4.6 Let A have linearly independent columns and let A = QR be a QR fac-
torization of A. Partition
RT L RT R
A → AL AR , Q → QL QR , and R → ,
0 RBR
347
1. AL = QL RT L : QL RT L equals the QR factorization of AL ,
2. C (AL ) = C (QL ): the first k columns of Q form an orthonormal basis for the space spanned by the
first k columns of A.
3. RT R = QH
L AR ,
4. (AR − QL RT R )H QL = 0,
5. AR − QL RT R = QR RBR , and
6. C (AR − QL RT R ) = C (QR ).
QH H
L (AR − QL RT R ) = QL QR RBR
is equivalent to
QH
L AR − Q
H
Q R = QH Q R = 0.
| L{z L} T R | L{z R} BR
I 0
Rearranging yields 3.
• Since AR − QL RT R = QR RBR we find that (AR − QL RT R )H QL = (QR RBR )H QL and
(AR − QL RT R )H QL = RH H
BR QR QL = 0.
348
Chapter 6. Notes on Householder QR Factorization (Answers)
• H = H H , and
Answer:
* BACK TO TEXT
Homework 6.4 Show that if x ∈ Rn , v = x ∓ kxk2 e0 , and τ = vT v/2 then (I − 1τ vvT )x = ±kxk2 e0 .
* BACK TO TEXT
where τ = uH u/2 = (1 + uH
2 u2 )/2 and ρ =
±kxk2 .
q
z z
Hint: ρρ = |ρ|2 = kxk22 since H preserves the norm. Also, kxk22 = |χ1 |2 + kx2 k22 and z = |z| .
Answer:
* BACK TO TEXT
Answer:
* BACK TO TEXT
349
Homework 6.11 If m = n then Q could be accumulated by the sequence
Give a high-level reason why this would be (much) more expensive than the algorithm in Figure 6.6.
Answer:
* BACK TO TEXT
Answer:
−1 −1 −1 −1
T t T −T00 t01 /τ1 T T −T00 T00 t01 /τ1 + τ1 /τ1 I 0
00 01 00 = 00 00 = .
0 τ1 0 1/τ1 0 τ1 /τ1 0 1
* BACK TO TEXT
Homework 6.13 Homework 6.14 Consider u1 ∈ Cm with u1 6= 0 (the zero vector), U0 ∈ Cm×k , and non-
singular T00 ∈ Ck×k . Define τ1 = (uH
1 u1 )/2, so that
1
H1 = I − u1 uH
1
τ1
equals a Householder transformation, and let
−1 H
Q0 = I −U0 T00 U0 .
Show that
−1
−1 H 1 T00 t01 H
Q0 H1 = (I −U0 T00 U0 )(I − u1 uH
1 )=I− U0 u1 U0 u1 ,
τ1 0 τ1
where t01 = QH
0 u1 .
Answer:
−1 H 1
Q0 H1 = (I −U0 T00 U0 )(I − u1 uH
1)
τ1
−1 H 1 −1 H 1
= I −U0 T00 U0 − u1 uH
1 +U0 T00 U0 u1 uH
1
τ1 τ1
−1 H 1 1 −1
= I −U0 T00 U0 − u1 uH 1 + U0 T00 t01 uH
1
τ1 τ1
350
Also
−1
T00 t01 H
I− U0 u1 U0 u1
0 τ1
−1 −1
T00 −T00 t01 /τ1 H
= I− U0 u1 U0 u1
0 1/τ1
−1 H −1
T00 U0 − T00 t01 uH
1 /τ1
= I− U0 u1
1/τ1 uH
1
−1 H −1
= I −U0 (T00 U0 − T00 t01 uH
1 /τ1 ) − 1/τ1 u1 u1
H
−1 H 1 1 −1
= I −U0 T00 U0 − u1 uH 1 + U0 T00 t01 uH
1
τ1 τ1
* BACK TO TEXT
Homework 6.14 Homework 6.15 Consider ui ∈ Cm with ui 6= 0 (the zero vector). Define τi = (uH
i ui )/2,
so that
1
Hi = I − ui uH
τi i
equals a Householder transformation, and let
U = u0 u1 · · · uk−1 .
Show that
H0 H1 · · · Hk−1 = I −UT −1U H ,
where T is an upper triangular matrix.
Answer: The results follows from Homework 6.14 via a proof by induction.
* BACK TO TEXT
351
Chapter 7. Notes on Solving Linear Least-squares Problems (An-
swers)
Homework 7.2 Let A ∈ Cm×n with m < n have linearly independent rows. Show that there exist a lower
triangular matrix LL ∈ Cm×m and a matrix QT ∈ Cm×n with orthonormal
such that A = LL QT , noting
rows
that LL does not have any zeroes on the diagonal. Letting L = LL 0 be Cm×n and unitary Q =
Q
T , reason that A = LQ.
QB
Don’t overthink the problem: use results you have seen before.
Answer: We know that AH ∈ Cn×m with linearly independent
columns (and n ≤ m). Hence there exists
RT
a unitary matrix Q̌ = FlaOneByTwoQL QR and R = with upper triangular matrix RT that has no
0
zeroes on its diagonal such that AH = Q̌L RT . It is easy to see that the desired QT equals QT = Q̌H
L and the
desired LL equals RHT.
* BACK TO TEXT
Homework 7.3 Let A ∈ Cm×n with m < n have linearly independent rows. Consider
kAx − yk2 = min kAz − yk2 .
z
Use the fact that A = LL QT , where LL ∈ Cm×m is lower triangular and QT has orthonormal rows, to argue
−1
that any vector of the
form QH H
T LL y + QB wB (where wB is any vector in C
n−m ) is a solution to the LLS
QT
problem. Here Q = .
QB
Answer:
min kAz − yk2 = min kLQz − yk2
z z
= min kLw − yk2
w
z = QH w
w
T − y
= min
LL 0
w
wB
H
z=Q w 2
= min kLL wT − yk2 .
w
z = QH w
352
describes all solutions to the LLS problem.
* BACK TO TEXT
Homework 7.4 Continuing Exercise 7.2, use Figure 7.1 to give a Classical Gram-Schmidt inspired al-
gorithm for computing LL and QT . (The best way to check you got the algorithm right is to implement
it!)
Answer:
* BACK TO TEXT
Homework 7.5 Continuing Exercise 7.2, use Figure 7.2 to give a Householder QR factorization inspired
algorithm for computing L and Q, leaving L in the lower triangular part of A and Q stored as Householder
vectors above the diagonal of A. (The best way to check you got the algorithm right is to implement it!)
Answer:
* BACK TO TEXT
353
Chapter 8. Notes on the Condition of a Problem (Answers)
Homework 8.1 Show that, if A is a nonsingular matrix, for a consistent matrix norm, κ(A) ≥ 1.
Answer: Hmmm, I need to go and check what the exact definition of a consistent matrix norm is
here... What I mean is a matrix norm induced by a vector norm. The reason is that then kIk = 1.
Let k · k be the norm that is used to define κ(A) = kAA−1 k. Then
* BACK TO TEXT
Homework 8.2 If A has linearly independent columns, show that k(AH A)−1 AH k2 = 1/σn−1 , where σn−1
equals the smallest singular value of A. Hint: Use the SVD of A.
Answer: Let A = UΣV H be the reduced SVD of A. Then
(since the two norm of a diagonal matrix equals its largest diagonal element in absolute value).
* BACK TO TEXT
Homework 8.3 Let A have linearly independent columns. Show that κ2 (AH A) = κ2 (A)2 .
Answer: Let A = UΣV H be the reduced SVD of A. Then
* BACK TO TEXT
354
• Show that Ax = y if and only if AH Ax = AH y.
Answer: Since A has linearly independent columns and is square, we know that A−1 and A−H exist.
If Ax = y, then multiplying both sides by AH yields AH Ax = AH y. If AH Ax = AH y then multiplying
both sides by A−H yields Ax = y.
• Reason that using the method of normal equations to solve Ax = y has a condition number of κ2 (A)2 .
* BACK TO TEXT
Homework 8.6 Characterize the set of all square matrices A with κ2 (A) = 1.
Answer: If κ2 (A) = 1 then σ0 /σn−1 = 1 which means that σ0 = σn−1 and hence σ0 = σ1 = · · · = σn−1 .
Hence the singular value decomposition of A must equal A = UΣV H = σ0UV H . But UV H is unitary since
U and V H are, and hence we conclude that A must be a nonzero multiple of a unitary matrix.
* BACK TO TEXT
355
Chapter 9. Notes on the Stability of an Algorithm (Answers)
Homework 9.3 Assume a floating point number system with β = 2 and a mantissa with t digits so that a
typical positive number is written as .d0 d1 . . . dt−1 × 2e , with di ∈ {0, 1}.
Answer: . 10 · · · 0} × 21 .
| {z
t
digits
• What is the largest positive real number u (represented as a binary fraction) such that the float-
ing point representation of 1 + u equals the floating point representation of 1? (Assume rounded
arithmetic.)
· · · 0} × 21 + . |00{z
Answer: . |10{z · · · 0} 1 × 21 = . 10 · · · 0} 1 × 21 which rounds to . 10
| {z · · · 0} × 21 = 1.
| {z
t t t
digits digits digits t
digits
· · 01} × 21 > 1.
| ·{z
It is not hard to see that any larger number rounds to . 10
t
digits
* BACK TO TEXT
356
Homework 9.12 Prove Theorem 9.11.
Answer:
Show that if |A| ≤ |B| then kAk1 ≤ kBk1 :
Let
A = a0 · · · an−1 and B = b0 · · · bn−1 .
Then
!
m−1
kAk1 = max ka j k1 = max ∑ |αi, j |
0≤ j<n 0≤ j<n i=0
!
m−1
= ∑ |αi,k | where k is the index that maximizes
i=0
!
m−1
≤ ∑ |βi,k | since |A| ≤ |B|
i=0
!
m−1
≤ max ∑ |βi, j | = max kb j k1 = kBk1 .
0≤ j<n i=0 0≤ j<n
κ := ((χ0 ψ0 + χ1 ψ1 ) + χ2 ψ2 ),
357
Case 1: ∏ni=0 (1 + εi )±1 = (∏n−1 ±1
i=0 (1 + εi ) )(1 + εn ). By the I.H. there exists a θn such that (1 + θn ) =
±1 and |θ | ≤ nu/(1 − nu). Then
∏n−1
i=0 (1 + εi ) n
!
n−1
∏ (1 + εi)±1 (1 + εn ) = (1 + θn )(1 + εn ) = 1 + θn + εn + θn εn ,
| {z }
i=0
θn+1
* BACK TO TEXT
nu bu nu bu
γn + γb + γn γb = + +
1 − nu 1 − bu (1 − nu) (1 − bu)
nu(1 − bu) + (1 − nu)bu + bnu2
=
(1 − nu)(1 − bu)
nu − bnu2 + bu − bnu2 + bnu2 (n + b)u − bnu2
= =
1 − (n + b)u + bnu2 1 − (n + b)u + bnu2
(n + b)u (n + b)u
≤ 2
≤ = γn+b .
1 − (n + b)u + bnu 1 − (n + b)u
* BACK TO TEXT
Homework 9.19 Let k ≥ 0 and assume that |ε1 |, |ε2 | ≤ u, with ε1 = 0 if k = 0. Show that
I +Σ (k) 0
(1 + ε2 ) = (I + Σ(k+1) ).
0 (1 + ε1 )
Hint: reason the case where k = 0 separately from the case where k > 0.
Answer:
Case: k = 0. Then
I +Σ (k) 0
(1 + ε2 ) = (1 + 0)(1 + ε2 ) = (1 + ε2 ) = (1 + θ1 ) = (I + Σ(1) ).
0 (1 + ε1 )
358
Case: k = 1. Then
I + Σ(k) 0 1 + θ1 0
(1 + ε2 ) = (1 + ε2 )
0 (1 + ε1 ) 0 (1 + ε1 )
(1 + θ1 )(1 + ε2 ) 0
=
0 (1 + ε1 )(1 + ε2 )
(1 + θ2 ) 0
= = (I + Σ(2) ).
0 (1 + θ2 )
Case: k > 1. Notice that
(I + Σ(k) )(1 + ε2 ) = diag(()(1 + θk ), (1 + θk ), (1 + θk−1 ), · · · , (1 + θ2 ))(1 + ε2 )
= diag(()(1 + θk+1 ), (1 + θk+1 ), (1 + θk ), · · · , (1 + θ3 ))
Then
I + Σ(k) 0 (I + Σ(k) )(1 + ε2 ) 0
(1 + ε2 ) =
0 (1 + ε1 ) 0 (1 + ε1 )(1 + ε2 )
(k)
(I + Σ )(1 + ε2 ) 0
= = (I + Σ(k+1) ).
0 (1 + θ2 )
* BACK TO TEXT
359
(Note: strictly speaking, one should probably treat the case n = 1 separately.)!.
* BACK TO TEXT
Homework 9.25 In the above theorem, could one instead prove the result
y̌ = A(x + δx),
where δx is “small”?
Answer: The answer is “no”. The reason is that for each individual element of y
However, the δx for each entry ψ̌i is different, meaning that we cannot factor out x + δx to find that
y̌ = A(x + δx).
* BACK TO TEXT
Homework 9.27 In the above theorem, could one instead prove the result
Č = (A + ∆A)(B + ∆B),
360
Chapter 10. Notes on Performance (Answers)
No exercises to answer yet.
361
Chapter 11. Notes on Gaussian Elimination and LU Factorization (An-
swers)
Answer:
I 0 0 I 0 0 I 0 0 I 0 0
k k k k
0 = 0 0 = 0
0 1 0 0 1 1 1 0
0 −l21 I 0 l21 I 0 −l21 + l21 I 0 0 I
* BACK TO TEXT
L 0 0
00
T
Homework 11.7 Let L̃k = L0 L1 . . . Lk . Assume that L̃k has the form L̃k−1 = l10 1 0 , where L̃00
L20 0 I
L 0 0 I 0 0
00
is k × k. Show that L̃k is given by L̃k = l10
T
.. (Recall: L = 0 .)
1 0 bk 0 1
L20 l21 I 0 −l21 I
Answer:
b−1
L̃k = L̃k−1 Lk = L̃k−1 Lk
−1
L00 0 0 I 0 0 L 0 0 I 0 0
00
T T
= l10 1 0 . 0 0 = l10 1 0 . 0 1 0
1
L20 0 I 0 −l21 I L20 0 I 0 l21 I
L 0 0
00
T
= l10 1 0 .
L20 l21 I
* BACK TO TEXT
362
function [ A_out ] = LU_unb_var5( A )
%------------------------------------------------------------%
%------------------------------------------------------------%
end
return
Homework 11.12 Implement LU factorization with partial pivoting with the FLAME@lab API, in M-
script.
Answer: See Figure 11.3.
* BACK TO TEXT
Homework 11.13 Derive an algorithm for solving Ux = y, overwriting y with the solution, that casts most
computation in terms of DOT products. Hint: Partition
T
υ11 u12
U → .
0 U22
Call this Variant 1 and use Figure 11.6 to state the algorithm.
363
Algorithm: Solve Uz = y, overwriting y (Variant 1) Algorithm: Solve Uz = y, overwriting y (Variant 2)
UT L UT R y UT L UT R y
Partition U → ,y→ T Partition U → ,y→ T
UBL UBR yB UBL UBR yB
where UBR is 0 × 0, yB has 0 rows where UBR is 0 × 0, yB has 0 rows
while m(UBR ) < m(U) do while m(UBR ) < m(U) do
Repartition Repartition
U u U
U u U
UT L UT R 00 01 02 UT L UT R 00 01 02
→ uT υ11 uT
, → uT υ11 uT
,
UBL UBR 10 12
UBL UBR 10 12
U u U U u U
20 21 22 20 21 22
y y
yT 0 yT 0
→
ψ1 →
ψ1
yB yB
y2 y2
ψ1 := ψ1 − uT12 x2 ψ1 := χ1 /υ11
ψ1 := ψ1 /υ11 y0 := y0 − χ1 u01
Figure 6 (Answer): Algorithms for the solution of upper triangular system Ux = y that overwrite y with x.
364
Answer:
Partition
υ11 uT12 χ1 ψ1
= .
0 U22 x2 y2
Multiplying this out yields
υ11 χ1 + uT12 x2 ψ1
= .
U22 x2 y2
So, if we assume that x2 has already been computed and has overwritten y2 , then χ1 can be computed as
χ1 = (ψ1 − uT12 x2 )/υ11
which can then overwrite ψ1 . The resulting algorithm is given in Figure 11.6 (Answer) (left).
* BACK TO TEXT
Homework 11.14 Derive an algorithm for solving Ux = y, overwriting y with the solution, that casts most
computation in terms of AXPY operations. Call this Variant 2 and use Figure 11.6 to state the algorithm.
Answer: Partition
U00 u01 x0 y0
= .
0 υ11 χ1 ψ1
Multiplying this out yields
U00 x0 + u01 χ1 y0
= .
υ11 χ1 ψ1
So, χ1 = ψ1 /υ11 after which x0 can be computed by solving U00 x0 = y0 − χ1 u01 . The resulting algorithm
is given in Figure 11.6 (Answer) (right).
* BACK TO TEXT
Homework 11.15 If A is an n × n matrix, show that the cost of Variant 1 is approximately 23 n3 flops.
Answer: During the kth iteration, L00 is k × k, for k = 0, . . . , n − 1. Then the (approximate) cost of the
steps are given by
• Solve L00 u01 = a01 for u01 , overwriting a01 with the result. Cost: k2 flops.
T U = aT (or, equivalently, U T (l T )T = (aT )T for l T ), overwriting aT with the result.
• Solve l10 00 10 00 10 10 10 10
Cost: k2 flops.
T u , overwriting α with the result. Cost: 2k flops.
• Compute υ11 = α11 − l10 01 11
* BACK TO TEXT
365
Homework 11.16 Derive the up-looking variant for computing the LU factorization.
Answer: Consider the loop invariant:
A AT R L\UT L UT R
TL =
ABL ABR ABL
b ABR
b
LT LUT L = A
bT L LT LUT R = A
bT R
∧ ((
((( ((((
(UT L = ABL LBL
LBL ( (
U R + LBRUBR = ABR
( (
(((T(
( ( b ( b
L00U00 = A
b00 L00 u01 = ab01 L00U02 = A
b02
TU =a
l10 bT10 T u +υ = α
l10 T U + uT = a
l10 bT12
00 01 11 b 11 02 12
L20U00 = A
b20 L20 u01 + υ11 l21 = ab21 L20U02 + l21 uT12 + L22U22 = A
b22
The equalities in yellow can be used to compute the desired parts of L and U:
T U = aT for l T , overwriting aT with the result.
• Solve l10 00 10 10 10
T u , overwriting α with the result.
• Compute υ11 = α11 − l10 01 11
* BACK TO TEXT
Homework 11.17 Implement all five LU factorization algorithms with the FLAME@lab API, in M-
script.
* BACK TO TEXT
366
Homework 11.18 Which of the five variants can be modified to incorporate partial pivoting?
Answer: Variants 2, 4, and 5.
* BACK TO TEXT
1 0 0 ··· 0 1
−1 1 0 ··· 0 1
−1 −1 1 · · · 0 1
A= . .
.. . . .
.. .. . . .. ..
. .
−1 −1 ··· 1 1
−1 −1 · · · −1 1
Eliminating the entries below the diagonal in the second column yields:
1 0 0 ··· 0 1
0 1 0 ··· 0 2
0 0 1 ··· 0 4
.
.. .. .. . . .. ..
. . . . . .
0 0 ··· 1 4
0 0 ··· −1 4
367
Eliminating the entries below the diagonal in the (n − 1)st column yields:
1 0 0 ··· 0 1
0 1 0 ··· 0 2
0 0 1 ··· 0 4
.
. . . . . .
.. .. .. . . .. ..
n−2
0 0
··· 1 2
0 0 ··· 0 2 n−1
* BACK TO TEXT
368
Chapter 12. Notes on Cholesky Factorization (Answers)
Homework 12.3 Let B ∈ Cm×n have linearly independent columns. Prove that A = BH B is HPD.
Answer: Let x ∈ Cm be a nonzero vector. Then xH BH Bx = (Bx)H (Bx). Since B has linearly independent
columns we know that Bx 6= 0. Hence (Bx)H Bx > 0.
* BACK TO TEXT
Homework 12.4 Let A ∈ Cm×m be HPD. Show that its diagonal elements are real and positive.
Answer: Let e j be the jth unit basis vectors. Then 0 < eHj Ae j = α j, j .
* BACK TO TEXT
Homework 12.15 Consider B ∈ Cm×n with linearly independent columns. Recall that B has a QR fac-
torization, B = QR where Q has orthonormal columns and R is an upper triangular matrix with positive
diagonal elements. How are the Cholesky factorization of BH B and the QR factorization of B related?
Answer:
RH |{z}
BH B = (QR)H QR = RH QH Q R = |{z} R .
| {z }
I L LH
* BACK TO TEXT
(Hint: For this exercise, use techniques similar to those in Section 12.4.)
1. Show that A00 is SPD.
Answer: Assume that A is n × n so that A00 is (n − 1) × (n − 1). Let x0 ∈ Rn−1 be a nonzero vector.
Then T
x0 A00 a10 x0
x0T A00 x0 = >0
0 aT10 α11 0
T
x0
since is a nonzero vector and A is SPD.
0
369
T , where L is lower triangular and nonsingular, argue that the assign-
2. Assuming that A00 = L00 L00 00
T := aT L−T is well-defined.
ment l10 10 00
−1 T := aT L−T uniquely
Answer: The compution is well-defined because L00 exists and hence l10 10 00
T .
computes l10
3. Assuming that A00 is SPD, A00 = L00 L00 T where L is lower triangular and nonsingular, and l T =
00
q 10
T −T T T
a10 L00 , show that α11 − l10 l10 > 0 so that λ11 := α11 − l10 l10 is well-defined.
Answer: We want to show that α11 − l10 T l > 0. To do so, we are going to construct a nonzero
10
vector x so that xT Ax = α11 − l10
T l , at which point we can invoke the fact that A is SPD.
10
Rather than just giving the answer, we go through the steps that will give insight into the thought
process leading up to the answer as well. Consider
T T
x0 A00 a10 x0 x0 A00 x0 + χ1 a10
=
χ1 aT10 α11 χ1 χ1 aT10 x0 + α11 χ1
= x0T A00 x0 + χ1 a10 + χ1 aT10 x0 + α11 χ1
= x0T A00 x0 + χ1 x0T a10 + χ1 aT10 x0 + α11 χ21 .
T l , perhaps we should pick χ = 1. Then
Since we are trying to get to α11 − l10 10 1
T
x0 A00 a10 x0
= x0T A00 x0 + x0T a10 + aT10 x0 + α11 .
1 aT10 α11 1
370
Algorithm: A := C HOL UNB(A) Bordered algorithm)
AT L ?
Partition A →
ABL ABR
whereAT L is 0 × 0
while m(AT L ) < m(A) do
Repartition
A00 ? ?
AT L ?
→ aT α11 ?
10
ABL ABR
A20 a21 A22
whereα11 is 1 × 1
Continue with
A00 ? ?
AT L ?
← aT α11 ?
10
ABL ABR
A20 a21 A22
endwhile
4. Show that T
A00 a10 L00 0 L00 0
=
aT10 α11 T
l10 λ11 T
l10 λ11
Homework 12.17 Use the results in the last exercise to give an alternative proof by induction of the
Cholesky Factorization Theorem and to give an algorithm for computing it by filling in Figure 12.3. This
algorithm is often referred to as the bordered Cholesky factorization algorithm.
Answer:
Proof by induction.
371
Base case: n = 1. Clearly the result is true for a 1 × 1 matrix A = α11 : In this case, the fact that A is
√
SPD means that α11 is real and positive and a Cholesky factor is then given by λ11 = α11 , with
uniqueness if we insist that λ11 is positive.
Inductive step: Assume the result is true for SPD matrix A ∈ C(n−1)×(n−1) . We will show that it holds
for A ∈ Cn×n . Let A ∈ Cn×n be SPD. Partition A and L like
A00 ? L 0
A= and L = 00 .
aT10 α11 T
l10 λ11
Homework 12.18 Show that the cost of the bordered algorithm is, approximately, 31 n3 flops.
Answer: During the kth iteration, k = 0, . . . , n − 1 assume that A00 is k × k. Then
−T
• aT10 = aT10 L00 (implemented as the lower triangular solve L00 l10 = a10 ) requires, approximately, k2
flops.
* BACK TO TEXT
372
Chapter 13. Notes on Eigenvalues and Eigenvectors (Answers)
Homework 13.4 Let λ be an eigenvalue of A and let Eλ (A) = {x ∈ Cm |Ax = λx} denote the set of all
eigenvectors of A associated with λ (including the zero vector, which is not really considered an eigenvec-
tor). Show that this set is a (nontrivial) subspace of Cm .
Answer:
• 0 ∈ Eλ (A): (since we explicitly include it).
* BACK TO TEXT
Homework 13.8 The eigenvalues of a diagonal matrix equal the values on its diagonal. The eigenvalues
of a triangular matrix equal the values on its diagonal.
Answer: Since a diagonal matrix is a special case of a triangular matrix, it suffices to prove that the
eigenvalues of a triangular matrix are the values on its diagonal.
If A is triangular, so is A − λI. By definition, λ is an eigenvalue of A if and only if A − λI is singular.
But a triangular matrix is singular if and only if it has a zero on its diagonal. The triangular matrix A − λI
has a zero on its diagonal if and only if λ equals one of the diagonal elements of A.
* BACK TO TEXT
Homework 13.19 Prove Lemma 13.18. Then generalize it to a result for block upper triangular matrices:
A0,0 A0,1 · · · A0,N−1
0 A1,1 · · · A1,N−1
A= .
0 . .. .
..
0
0 0 · · · AN−1,N−1
Answer:
373
AT L AT R
Lemma 13.18 Let A ∈ Cm×m be of form A = . Assume that QT L and QBR are
0 ABR
unitary “of appropriate size”. Then
H
QT L 0 QT L AT L QH
TL QT L AT R QH
BR QT L 0
A= .
0 QBR 0 QBR ABR QH
BR 0 QBR
Proof:
H
QT L 0 QT L AT L QH
TL QT L AT R QH
BR QT L 0
0 QBR 0 QBR ABR QH
BR 0 QBR
QH H
T L QT L AT L QT L QT L QH H
T L QT L AT R QBR QBR
=
0 QH H
BR QBR ABR QBR QBR
AT L AT R
= = A.
0 ABR
* BACK TO TEXT
Homework 13.21 Prove Corollary 13.20. Then generalize it to a result for block upper triangular matri-
ces.
Answer:
AT L AT R
Colollary 13.20 Let A ∈ Cm×m be of for A = . Then Λ(A) = Λ(AT L ) ∪
0 ABR
Λ(ABR ).
374
Proof: This follows immediately from Lemma 13.18. Let AT L = QT L TT Li QH H
T L and ABR = QBR TBRi QBR
be the Shur decompositions of the diagonal blocks. Then Λ(AT L ) equals the diagonal elements of TT L
and Λ(ABR ) equals the diagonal elements of TBR . Now, by Lemma 13.18 the Schur decomposition of A is
given by
H
QT L 0 Q A Q H H
QT L AT R QBR Q 0
A = TL TL TL TL
0 QBR 0 QBR ABR QH BR 0 Q BR
H
QT L 0 TT L QT L AT R QH
BR QT L 0
= .
0 QBR 0 TBR 0 QBR
| {z }
TA
Hence the diagonal elements of TA (which is upper triangular) equal the elements of Λ(A). The set of
those elements is clearly Λ(AT L ) ∪ Λ(ABR ).
The generalization is that if
A0,0 A0,1 · · · A0,N−1
0 A1,1 · · · A1,N−1
A=
0 . .. .
..
0
0 0 · · · AN−1,N−1
where the blocks on the diagonal are square, then
Λ(A) = Λ(A0,0 ) ∪ Λ(A1,1 ) ∪ · · · ∪ Λ(AN−1,N−1 ).
* BACK TO TEXT
Homework 13.24 Let A be Hermitian and λ and µ be distinct eigenvalues with eigenvectors xλ and xµ ,
respectively. Then xλH xµ = 0. (In other words, the eigenvectors of a Hermitian matrix corresponding to
distinct eigenvalues are orthogonal.)
Answer: Assume that Axλ = λxλ and Axµ = µxµ , for nonzero vectors xλ and xµ and λ 6= µ. Then
xµH Axλ = λxµH xλ
and
xλH Axµ = µxλH xµ .
Because A is Hermitian and λ is real
µxλH xµ = xλH Axµ = (xµH Axλ )H = (λxµH xλ )H = λxλH xµ .
Hence
µxλH xµ = λxλH xµ .
If xλH xµ 6= 0 then µ = λ, which is a contradiction.
* BACK TO TEXT
375
Homework 13.25 Let A ∈ Cm×m be a Hermitian matrix, A = QΛQH its Spectral Decomposition, and
A = UΣV H its SVD. Relate Q, U, V , Λ, and Σ.
Answer: I am going to answer this by showing how to take the Spectral decomposition of A, and turn
this into the SVD of A. Observations:
• We will assume all eigenvalues are nonzero. It should be pretty obvious how to fix the below if some
of them are zero.
• Q is unitary and Λ is diagonal. Thus, A = QΛQH is the SVD except that the diagonal elements of Λ
are not necessarily nonnegative and they are not ordered from largest to smallest in magnitude.
• We can fix the fact that they are not nonnegative with the following observation:
λ0 0 · · · 0
0 λ1 · · · 0
A = QΛQH = Q
H
Q
.. .. . . ..
. . . .
0 0 · · · λn−1
λ0 0 · · · 0 sign(λ0 ) 0 ··· 0 sign(λ0 ) 0 ··· 0
0 λ1 · · · 0 0 sign(λ1 ) ··· 0 0 sign(λ1 ) · · · 0
H
= Q Q
.. .. . . .. .
.. .. .. .. .. .. .. ..
. . . .
. . .
. . . .
0 0 ··· λn−1 0 0 · · · sign(λn−1 ) 0 0 · · · sign(λn−1 )
| {z }
I
λ0 0 · · · 0 sign(λ0 ) 0 ··· 0 sign(λ0 ) 0 ··· 0
0 λ1 · · · 0 0 sign(λ1 ) · · · 0 0 sign(λ1 ) · · · 0
H
= Q Q
.. .. . . .. .. .. .. .. .. .. .. ..
. . . .
. . . .
. . . .
0 0 · · · λn−1 0 0 · · · sign(λn−1 ) 0 0 · · · sign(λn−1 )
| {z } | {z }
|λ0 | 0 ··· 0 Q̃H
0 |λ1 | · · · 0
.. .. . . ..
. . . .
0 0 · · · |λn−1 |
| {z }
Λ̃
= QΛ̃Q̃H .
Now Λ̃ has nonnegative diagonal entries and Q̃ is unitary since it is the product of two unitary
matrices.
• Next, we fix the fact that the entries of Λ̃ are not ordered from largest to smallest. We do so by
noting that there is a permutation matrix P such that Σ = PΛ̃PH equals the diagonal matrix with the
values ordered from the largest to smallest. Then
A = QΛ̃Q̃H
376
PH P Λ̃ P
= Q |{z} H
|{z}P Q̃H
I I
* BACK TO TEXT
Homework 13.26 Let A ∈ Cm×m and A = UΣV H its SVD. Relate the Spectral decompositions of AH A
and AAH to U, V , and Σ.
Answer:
AH A = (UΣV H )H UΣV H = V ΣU H UΣV H = V Σ2V H .
Thus, the eigenvalues of AH A equal the square of the singular values of A.
Thus, the eigenvalues of AAH equal the square of the singular values of A.
* BACK TO TEXT
377
Chapter 14. Notes on the Power Method and Related Methods (An-
swers)
* BACK TO TEXT
Answer: This follows immediately from the fact that if α > 0 and β > 0 then
• α > β implies that 1/β > 1/α and
• α ≥ β implies that 1/β ≥ 1/α.
* BACK TO TEXT
* BACK TO TEXT
378
Chapter 15. Notes on the QR Algorithm and other Dense Eigen-
solvers(Answers)
so that
b(k) = Vb (k) T AVb ( k) = Vb (k) T Vb (k+1) Rb(k+1)
A
Since Vb (k) T Vb (k+1) this means that A
b(k) = Vb (k) T Vb (k+1) Rb(k+1) is a QR factorization of A
b(k) .
Now, by the I.H.,
A(k) = A
b(k)Vb (k) T Vb (k+1) Rb(k+1)
But then
b (k)Vb (k) T Vb (k+1) = Vb (k+1) .
V (k+1) = V (k) Q(k+1) = Vb (k) Q(k+1) = V
| {z }
I
Finally,
b(k+1) = Vb (k+1) T AVb (k+1) = V (k+1) T AV (k+1) = (V (k) Q(k+1) )T A(V (k) Q(k+1) )
A
= Q(k+1) T V (k) AV (k) Q(k+1) = Q(k+1) T A(k) Q(k+1) = R(k+1) Q(k+1) = A(k+1)
| {z }
R (k+1)
* BACK TO TEXT
379
• Base case: k = 0. We need to show that Vb (0) = V (0) and A
b(0) = A(0) . This is trivially true.
* BACK TO TEXT
for j = 0, . . . , k. Then
βk+1,k = kq̃k+1 k2
and then
qk+1 = q̃k+1 /βk+1,k .
This way, the columns of Q and B can be determined, one-by-one.
* BACK TO TEXT
380
Homework 15.11 In the above discussion, show that α211 + 2α231 + α233 = α b 233 .
b 211 + α
Answer: If A b31 k2 = kA31 k2 because multiplying on the left and/or the right by a
b31 = J31 A31 J T then kA
31 F F
unitary matrix preserves the Frobenius norm of a matrix. Hence
2
2
α11 α31
αb 11 0
=
.
0 α
α31 α33
b 33
F F
But
2
α11 α31
= α211 + 2α231 + α233
α31 α33
F
and
2
αb 11 0
b 211 + +α
b 233 ,
= α
0 α
b 33
F
Homework 15.14 Give the approximate total cost for reducing a nonsymmetric A ∈ Rn×n to upper-
Hessenberg form.
Answer: To prove this, assume that in the current iteration of the algorithm A00 is k × k. The update in
the current iteration is then
381
Thus, the total cost in flops is, approximately,
n−1
2k(n − k − 1) + 2k(n − k − 1) + 2(n − k − 1)2 + 2(n − k − 1)2 + 2 × 2(n − k − 1)2
∑
k=0
n−1 n−1
= ∑ 4k(n − k − 1) + 4(n − k − 1)2 + ∑ 4(n − k − 1)2
k=0 k=0
n−1
= ∑ [4k(n − k − 1) + 4(n − k − 1)2 ] + 4(n − k − 1)2
k=0
| {z }
= 4(k + n − k − 1)(n − k − 1)
= 4(n − 1)(n − k − 1)
≈ 4n(n − k − 1)
n−1 n−1 n−1 n−1
2
≈ 4n ∑ (n − k − 1) + 4 ∑ (n − k − 1) = 4n ∑ j + 4 ∑ j2
k=0 k=0 j=0 j=0
Z n
n(n − 1) 4 10
≈ 4n +4 j2 d j ≈ 2n3 + n3 = n3 .
2 j=0 3 3
* BACK TO TEXT
382
Algorithm: A := LDLT(A)
AT L ?
Partition A →
ABL ABR
whereAT L is 0 × 0
while m(AT L ) < m(A) do
Repartition
A00 ? ?
AT L ?
→ aT α
10 11 ?
ABL ABR
A20 a21 A22
whereα11 is 1 × 1
Continue with
A00 ? ?
AT L ?
← aT α11 ?
10
ABL ABR
A20 a21 A22
endwhile
Homework 16.1 Modify the algorithm in Figure 16.1 so that it computes the LDLT factorization. (Fill in
Figure 16.3.)
Answer:
Three possible answers are given in Figure 16.5.
* BACK TO TEXT
Homework 16.2 Modify the algorithm in Figure 16.2 so that it computes the LDLT factorization of a
tridiagonal matrix. (Fill in Figure 16.4.) What is the approximate cost, in floating point operations, of
383
Algorithm: A := LDLT TRI(A)
AFF ? ?
Partition A → αMF eTL αMM ?
0 αLM eF ALL
whereALL is 0 × 0
while m(AFF ) < m(A) do
Repartition
A00 ? ?
A ? ?
FF
α eT α ? ?
10 L 11
αMF eTL αMM ? →
0 α21 α22 ?
0 αLM eF ALL
0 0 α32 eF A33
whereα22 is a scalars
Continue with
A00 ? ?
A ? ?
FF
α10 eT α11 ? ?
L
αMF eTL αMM ? ←
0 α21 α22 ?
0 αLM eF ALL
0 0 α32 eF A33
endwhile
Figure 16.6: Algorithm for computing the the LDLT factorization of a tridiagonal matrix.
computing the LDLT factorization of a tridiagonal matrix? Count a divide, multiply, and add/subtract as a
floating point operation each. Show how you came up with the algorithm, similar to how we derived the
algorithm for the tridiagonal Cholesky factorization.
Answer:
Three possible algorithms are given in Figure 16.6.
α21
The key insight is to recognize that, relative to the algorithm in Figure 16.5, a21 = so that,
0
384
for example, a21 := a21 /α11 becomes
α α α /α
21 := 21 /α11 = 21 11 .
0 0 0
* BACK TO TEXT
Homework 16.3 Derive an algorithm that, given an indefinite matrix A, computes A = UDU T . Overwrite
only the upper triangular part of A. (Fill in Figure 16.5.) Show how you came up with the algorithm,
similar to how we derived the algorithm for LDLT .
Answer: Three possible algorithms are given in Figure 16.7.
Partition
A00 a01 U00 u01 D00 0
A→ U → , and D →
T
a01 α11 0 1 0 δ1
Then
T
A00 a01 U00 u01 D00 0 U00 u01
=
aT01 α11 0 1 0 δ1 0 1
U00 D00 u01 δ1 UT 0
= 00
0 δ1 T
u01 1
T T
U00 D00U00 + δ1 u01 u01 u01 δ1
=
? δ1
This suggests the following algorithm for overwriting the strictly upper triangular part of A with the strictly
upper triangular part of U and the diagonal of A with D:
A00 a01
• Partition A → .
T
a01 α11
385
Algorithm: A := UDU T(A)
AT L AT R
Partition A →
? ABR
whereABR is 0 × 0
while m(ABR ) < m(A) do
Repartition
A00 a01 A02
AT L AT R
→ ? α11 aT
12
? ABR
? ? A22
whereα11 is 1 × 1
Continue with
A00 a01 A02
AT L AT R
← ? α11 aT12
? ABR
? ? A22
endwhile
Figure 16.7: Algorithm for computing the the UDU T factorization of a tridiagonal matrix.
386
• Compute u01 := u01 /α11 .
• Update A22 := A22 − u01 aT01 (updating only the upper triangular part).
• a01 := u01 .
T .
• Continue with computing A00 → U00 D00 L00
This algorithm will complete as long as δ11 6= 0,
* BACK TO TEXT
Homework 16.4 Derive an algorithm that, given an indefinite tridiagonal matrix A, computes A = UDU T .
Overwrite only the upper triangular part of A. (Fill in Figure 16.6.) Show how you came up with the
algorithm, similar to how we derived the algorithm for LDLT .
Answer: Three possible algorithms are given in Figure 16.8.
key insight is to recognize that, relative to the algorithm in Figure 16.7, α11 = α22 and a10 =
The
0
so that, for example, a10 := a10 /α11 becomes
α12
0 0 0
:= /α22 = .
α12 α12 α12 /α22
* BACK TO TEXT
387
Algorithm: A := UDU T TRI(A)
A α eT 0
FF FM L
Partition A → ? αMM αML eTF
? ? ALL
whereAFF is 0 × 0
while m(ALL ) < m(A) do
Repartition
A00 α01 eL 0 0
A α e 0
FF FM L
? α11 α12 0
? αMM αML eTF →
? ? α22 α23 eTF
? ? ALL
? ? ? A33
where
Continue with
A00 α01 eL 0 0
A α e 0
FF FM L
? α11 α12 0
? αMM αML eTF ←
? ? T
α22 α23 eF
? ? ALL
? ? ? A33
endwhile
Figure 16.8: Algorithm for computing the the UDU T factorization of a tridiagonal matrix.
388
(Hint: multiply out A = LDLT and A = UEU T with the partitioned matrices first. Then multiply out the
above. Compare and match...) How should φ1 be chosen? What is the cost of computing the twisted
factorization given that you have already computed the LDLT and UDU T factorizations? A ”Big O”
estimate is sufficient. Be sure to take into account what eTL D00 eL and eTF E22 eF equal in your cost estimate.
Answer:
T
L00 0 0 D00 0 0 L00 0 0
λ10 eTL 1 0 0 0 λ10 eTL 1 0
δ1
0 λ21 eF L22 0 0 D22 0 λ21 eF L22
L00 0 0 D00 0 0 LT 0 λ10 eL
00
= λ10 eTL 1 0 0 0 0 λ21 eTF
1
δ1
0 λ21 eF L22 0 0 D22 0 T
L22
L00 0 0 D LT λ10 D00 eL 0
00 00
= λ10 eTL 1 0 0 λ21 δ1 eTF
δ1
0 λ21 eF L22 0 0 T
D22 L22
L00 D00 L00T λ10 L00 D00 eL 0 A00 α01 eL 0
= λ10 eTL D00 L00
T λ210 eTL D00 eL + δ1 λ21 δ1 eTF = α01 eTL α21 eTF . (16.1)
α11
0 λ21 δ1 eF λ221 δ1 eF eTF + L22 D22 L22 T 0 α21 eF A22
and
T
U00 υ01 eL 0 E00 0 0 U00 υ01 eL 0
0 1 υ21 eTF 0 0 0 1 υ21 eTF
ε1
0 0 U22 0 0 E22 0 0 U22
U00 υ01 eL 0 E 0 0 T
U00 0 0
00
= 0 1 υ21 eTF 0 0 υ01 eTL 1 0
ε1
0 0 U22 0 0 E22 0 υ21 eF T
U22
U υ01 eL 0 E UT 0 0
00 00 00
= 0 1 υ21 eTF ε1 υ01 eTL 0
ε1
0 0 U22 0 υ21 E22 eF T
E22U22
U E U T + υ201 ε1 eL eTL υ10 ε1 eL 0 A00 α01 eL 0
00 00 00
= υ01 ε1 eTL ε1 + υ201 eTF E22 eF ε1 υ21 eTF E22U22 = α01 eTL
T α21 eTF . (16.2)
α11
0 TE e
υ21U22 U22 E22U22 T 0 α21 eF A22
22 F
Finally,
T
L00 0 0 D00 0 0 L00 0 0
λ10 eTL 1 υ21 eTF 0 0 λ10 eTL 1 υ21 eTF
φ1
0 0 U22 0 0 E22 0 0 U22
389
L00 0 0 D00 0 0 T
L00 λ10 eL 0
= λ10 eTL 1 υ21 eTF 0 0 0 1 0
φ1
0 0 U22 0 0 E22 0 υ21 eF U22 T
L00 0 0 T
D00 L00 λ10 D00 eL 0
= λ10 eTL 1 υ21 eTF 0 0
φ1
0 0 U22 0 υ21 E22 eF E22U22 T
L00 D00 L00T λ10 L00 D00 eL 0 A00 α01 eL 0
= λ10 eTL D00 L00
T λ210 eTL D00 eL + φ1 + υ221 eTF E22 eF υ21 eTF E22U22T = α eT α21 eTF . (16.3)
α11
01 L
0 υ21U22 E22 eF U22 E22U22T 0 α21 eF A22
The equivalence of the submatrices highlighted in yellow in (16.1) and (??) justify the submatrices high-
lighted in yellow in (16.3).
The equivalence of the submatrices highlighted in grey in (16.1), (??, and (16.3) tell us that
or
so that
α11 = (α11 − δ1 ) + φ1 + (α11 − ε1 ).
Solving this for φ1 yields
φ1 = δ1 + ε1 − α11 .
Notice that, given the factorizations A = LDLT and A = UEU T the cost of computing the twisted factor-
ization is O(1).
* BACK TO TEXT
390
x
0
where x = χ1 is not a zero vector. What is the cost of this computation, given that L00 and U22 have
x2
special structure?
Answer: Choose x0 , χ1 , and x2 so that
T
L 0 0 x 0
00 0
λ10 eTL T χ1 = 1
1 υ21 eF
0 0 U22 x2 0
or, equivalently,
T
L00 λ10 eL 0 x 0
0
0 χ1 = 1
0 1
0 υ21 eF T
U22 x2 0
T
L00 x0 = −λ10 eL
T
U22 x2 = −υ21 eF
T ) and bidiagonal
so that x0 and x2 can be computed via solves with a bidiagonal upper triangular matrix (L00
T ), respectively.
lower triangular matrix (U00
Then
T
L00 0 0 D00 0 0 L00 0 0 x0
λ10 eTL υ21 eTF 0 0 λ10 eTL υ21 eTF
1
0
1
χ1
0 0 U22 0 0 E22 0 0 U22 x2
L 0 0 D00 0 0 0
00
= λ10 eTL T
1
0 0 0 1
υ21 eF
0 0 U22 0 0 E22 0
L 0 0 0 0
00
= λ10 eTL T 0 = 0 ,
1
υ21 eF
0 0 U22 0 0
391
T x = −λ e :
Now, consider solving L00 0 10 L
× × 0 0 0 0 0
0 × × 0 0 0 0
0 0 × × 0 0 0
=
0 0 0
× × 0
0
0 0 0
0 × ×
0
0 0 0 0 0 × −λ10
A moment of reflection shows that if L00 is k × k, then solving L00 T x = −λ e requires O(k) flops.
0 10 L
T x = −υ e requires O(n −
Similarly, since then U22 is then (n − k − 1) × (n − k − 1), then solving U22 2 21 F
k − 1) flops. Thus, computing x requires O(n) flops.
Thus,
• Given tridiagonal Ab computing all eigenvalues requires O(n2 ) computation. (We have not discussed
this in detail...)
Thus, computing all eigenvalues and eigenvectors of a tridiagonal matrix via this method requires
O(n2 ) computation. This is much better than computing these via the tridiagonal QR algorithm.
* BACK TO TEXT
392
Chapter 16 Notes on Computing the SVD (Answers)
Homework 16.2 If A = UΣV T is the SVD of A then AT A = V Σ2V T is the Spectral Decomposition of
AT A.
* BACK TO TEXT
Homework 16.3 Homework 16.4 Give the approximate total cost for reducing A ∈ Rn×n to bidiagonal
form.
* BACK TO TEXT
393
Chapter 17. Notes on Splitting Methods (Answers)
kAk = max kAyk ≥ max kAxk = max kλxk = max |λ|kxk = |λ| = ρ(A).
kyk=1
kxk = 1 kxk = 1 kxk = 1
Ax = λx Ax = λx Ax = λx
* BACK TO TEXT
394
Appendix A
How to Download
Videos associated with these notes can be viewed in one of three ways:
• * Download from UT Box links to the video uploaded to UT-Austin’s “UT Box’ File Sharing
Service”.
• * View After Local Download links to the video downloaded to your own computer in directory
Video within the same directory in which you stored this document. You can download videos by
first linking on * Download from UT Box. Alternatively, visit the UT Box directory in which the
videos are stored and download some or all.
395
396
Bibliography
[1] E. Anderson, Z. Bai, C. Bischof, L. S. Blackford, J. Demmel, Jack J. Dongarra, J. Du Croz, S. Ham-
marling, A. Greenbaum, A. McKenney, and D. Sorensen. LAPACK Users’ guide (third ed.). SIAM,
Philadelphia, PA, USA, 1999.
[3] Paolo Bientinesi. Mechanical Derivation and Systematic Analysis of Correct Linear Algebra Algo-
rithms. PhD thesis, Department of Computer Sciences, The University of Texas, 2006. Technical
Report TR-06-46. September 2006.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[4] Paolo Bientinesi, John A. Gunnels, Margaret E. Myers, Enrique S. Quintana-Ortı́, and Robert A.
van de Geijn. The science of deriving dense linear algebra algorithms. ACM Trans. Math. Soft.,
31(1):1–26, March 2005.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[5] Paolo Bientinesi, Enrique S. Quintana-Ortı́, and Robert A. van de Geijn. Representing linear al-
gebra algorithms in code: The FLAME APIs. ACM Trans. Math. Soft., 31(1):27–59, March 2005.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[6] Paolo Bientinesi and Robert A. van de Geijn. The science of deriving stability analyses. FLAME
Working Note #33. Technical Report AICES-2008-2, Aachen Institute for Computational Engineer-
ing Sciences, RWTH Aachen, November 2008.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[7] Paolo Bientinesi and Robert A. van de Geijn. Goal-oriented and modular stability analysis. SIAM J.
Matrix Anal. & Appl., 32(1):286–308, 2011.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[8] Paolo Bientinesi and Robert A. van de Geijn. Goal-oriented and modular stability analysis. SIAM J.
Matrix Anal. Appl., 32(1):286–308, March 2011.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
We suggest you read FLAME Working Note #33 for more details.
[9] Christian Bischof and Charles Van Loan. The WY representation for products of Householder ma-
trices. SIAM J. Sci. Stat. Comput., 8(1):s2–s13, Jan. 1987.
[10] Basic linear algebra subprograms technical forum standard. International Journal of High Perfor-
mance Applications and Supercomputing, 16(1), 2002.
397
[11] James W. Demmel. Applied Numerical Linear Algebra. SIAM, 1997.
[12] I. S. Dhillon. A New O(n2 ) Algorithm for the Symmetric Tridiagonal Eigenvalue/Eigenvector Prob-
lem. PhD thesis, Computer Science Division, University of California, Berkeley, California, May
1997. Available as UC Berkeley Technical Report No. UCB//CSD-97-971.
[13] I. S. Dhillon. Reliable computation of the condition number of a tridiagonal matrix in O(n) time.
SIAM J. Matrix Anal. Appl., 19(3):776–796, July 1998.
[15] Inderjit S. Dhillon, Beresford N. Parlett, and Christof Vömel. The design and implementation of the
MRRR algorithm. ACM Trans. Math. Soft., 32(4):533–560, December 2006.
[16] J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W. Stewart. LINPACK Users’ Guide. SIAM,
Philadelphia, 1979.
[17] Jack J. Dongarra, Jeremy Du Croz, Sven Hammarling, and Iain Duff. A set of level 3 basic linear
algebra subprograms. ACM Trans. Math. Soft., 16(1):1–17, March 1990.
[18] Jack J. Dongarra, Jeremy Du Croz, Sven Hammarling, and Richard J. Hanson. An extended set of
FORTRAN basic linear algebra subprograms. ACM Trans. Math. Soft., 14(1):1–17, March 1988.
[19] Jack J. Dongarra, Iain S. Duff, Danny C. Sorensen, and Henk A. van der Vorst. Solving Linear
Systems on Vector and Shared Memory Computers. SIAM, Philadelphia, PA, 1991.
[20] Jack J. Dongarra, Sven J. Hammarling, and Danny C. Sorensen. Block reduction of matrices to
condensed forms for eigenvalue computations. Journal of Computational and Applied Mathematics,
27, 1989.
[21] Gene H. Golub and Charles F. Van Loan. Matrix Computations. The Johns Hopkins University
Press, Baltimore, 3nd edition, 1996.
[22] Kazushige Goto and Robert van de Geijn. Anatomy of high-performance matrix multiplication. ACM
Trans. Math. Soft., 34(3):12:1–12:25, May 2008.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[23] John A. Gunnels. A Systematic Approach to the Design and Analysis of Parallel Dense Linear Alge-
bra Algorithms. PhD thesis, Department of Computer Sciences, The University of Texas, December
2001.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[24] John A. Gunnels, Fred G. Gustavson, Greg M. Henry, and Robert A. van de Geijn. FLAME: Formal
Linear Algebra Methods Environment. ACM Trans. Math. Soft., 27(4):422–455, December 2001.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[25] Nicholas J. Higham. Accuracy and Stability of Numerical Algorithms. Society for Industrial and
Applied Mathematics, Philadelphia, PA, USA, second edition, 2002.
398
[26] C. G. J. Jacobi. Über ein leichtes Verfahren, die in der Theorie der Säkular-störungen vorkommenden
Gleichungen numerisch aufzulösen. Crelle’s Journal, 30:51–94, 1846.
[27] Thierry Joffrain, Tze Meng Low, Enrique S. Quintana-Ortı́, Robert van de Geijn, and Field G. Van
Zee. Accumulating Householder transformations, revisited. ACM Trans. Math. Softw., 32(2):169–
179, June 2006.
[28] C. L. Lawson, R. J. Hanson, D. R. Kincaid, and F. T. Krogh. Basic linear algebra subprograms for
Fortran usage. ACM Trans. Math. Soft., 5(3):308–323, Sept. 1979.
[29] Margaret E. Myers, Pierce M. van de Geijn, and Robert A. van de Geijn. Linear Algebra: Founda-
tions to Frontiers - Notes to LAFF With. Self published, 2014.
Download from http://www.ulaff.net.
[30] Jack Poulson, Bryan Marker, Robert A. van de Geijn, Jeff R. Hammond, and Nichols A. Romero.
Elemental: A new framework for distributed memory dense matrix computations. ACM Trans. Math.
Softw., 39(2):13:1–13:24, February 2013.
[31] C. Puglisi. Modification of the Householder method based on the compact WY representation. SIAM
J. Sci. Stat. Comput., 13:723–726, 1992.
[32] Gregorio Quintana-Ortı́ and Robert van de Geijn. Improving the performance of reduction to Hes-
senberg form. ACM Trans. Math. Softw., 32(2):180–194, June 2006.
[33] Robert Schreiber and Charles Van Loan. A storage-efficient WY representation for products of
Householder transformations. SIAM J. Sci. Stat. Comput., 10(1):53–57, Jan. 1989.
[34] G. W. Stewart. Matrix Algorithms Volume 1: Basic Decompositions. SIAM, Philadelphia, PA, USA,
1998.
[35] G. W. Stewart. Matrix Algorithms Volume II: Eigensystems. SIAM, Philadelphia, PA, USA, 2001.
[36] Lloyd N. Trefethen and David Bau III. Numerical Linear Algebra. SIAM, 1997.
[37] Robert van de Geijn and Kazushige Goto. Encyclopedia of Parallel Computing, chapter BLAS (Basic
Linear Algebra Subprograms), pages Part 2, 157–164. Springer, 2011.
[38] Robert A. van de Geijn and Enrique S. Quintana-Ortı́. The Science of Programming Matrix Compu-
tations. www.lulu.com/contents/contents/1911788/, 2008.
[39] Field G. Van Zee. libflame: The Complete Reference. www.lulu.com, 2012.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[40] Field G. Van Zee, Ernie Chan, Robert van de Geijn, Enrique S. Quintana-Ortı́, and Gregorio
Quintana-Ortı́. The libflame library for dense matrix computations. IEEE Computation in Science &
Engineering, 11(6):56–62, 2009.
[41] Field G. Van Zee and Robert A. van de Geijn. BLIS: A framework for rapid instantiation of BLAS
functionality. ACM Trans. Math. Soft., 2015. To appear.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
399
[42] Field G. Van Zee, Robert A. van de Geijn, and Gregorio Quintana-Ortı́. Restructuring the tridiagonal
and bidiagonal QR algorithms for performance. ACM Trans. Math. Soft., 40(3):18:1–18:34, April
2014.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[43] Field G. Van Zee, Robert A. van de Geijn, Gregorio Quintana-Ortı́, and G. Joseph Elizondo. Families
of algorithms for reducing a matrix to condensed form. ACM Trans. Math. Soft., 39(1), 2012.
Download from http://www.cs.utexas.edu/users/flame/web/FLAMEPublications.html.
[44] H. F. Walker. Implementation of the GMRES method using Householder transformations. SIAM J.
Sci. Stat. Comput., 9(1):152–163, 1988.
[45] David S. Watkins. Fundamentals of Matrix Computations, 3rd Edition. Wiley, third edition, 2010.
[46] Stephen J. Wright. A collection of problems for which Gaussian elimination with partial pivoting is
unstable. SIAM J. Sci. Comput., 14(1):231–238, 1993.
400
Index
401
inner product, 9 by rows, 13
invariant subspace, 329 cost, 12
inverse via axpy, 13
Moore-Penrose generalized, 50 via dot, 13
pseudo, 50 matrix-vector operation, 11
gemv, 11
LAFF Notes, iv ger, 14
linear system solve, 175 matrix-vector multiplication, 11
triangular, 175–178 rank-1 update, 13
low-rank approximation, 50 matrix-vector product, 11
lower triangular solve, 175–178 MGS, 64
LU decomposition, 161 Modified Gram-Schmidt, 64
LU factorization, 159–193 Moore-Penrose generalized inverse, 50
complete pivoting, 174 multiplication
cost, 164–165 matrix-matrix, 16
existence, 161 blocked, 20
existence proof, 173–174 cost, 19
partial pivoting, 165–172 element-by-element, 17
algorithm, 167 via matrix-vector multiplications, 18
LU factorization:derivation, 161–162 via rank-1 updates, 18
MAC, 19 via row-vector times matrix multiplications,
Matlab, 75 18
matrix matrix-vector, 11
condition number, 54 cost, 12
conjugate, 4 multiply-accumulate, 19
low-rank approximation, 50
notation
orthogonal, 35–55
FLAME, 12
orthogormal, 37
permutation, 165 Octave, 75
spectrum, 217 orthonormal basis, 57
transpose, 4–7 outer product, 13
unitary, 37
matrix-matrix multiplication, 16 partial pivoting
blocked, 20 LU factorization, 165–172
cost, 19 permutation
element-by-element, 17 matrix, 165
via matrix-vector multiplications, 18 preface, ii
via rank-1 updates, 18 product
via row-vector times matrix multiplications, 18 dot, 9
matrix-matrix operation inner, 9
gemm, 16 matrix-matrix, 16
matrix-matrix multiplication, 16 matrix-vector, 11
matrix-matrix product, 16 outer, 13
matrix-vector multiplication, 11 projection
algorithm, 13 onto column space, 49
by columns, 13 pseudo inverse, 50
402
QR factorization, 61 Hermitian transpose, 5
Gram-Schmidt, 57–72 orthogonal, 37
orthonormal, 37
rank-1 update, 13 perpendicular, 37
algorithm, 15 scaling
by columns, 15 cost, 8
by rows, 15 transpose, 4
cost, 16 vector addition
via axpy, 15 scaled, 8
via dot, 15 vector-vector operation, 7
Reflector, 85 axpy, 8
reflector, 85 dot, 9
residual, 303 scal, 7
scal, 7
sca
cost, 8
scaled vector addition, 8
cost, 9, 11
scaling
vector
cost, 8
singular value, 41
Singular Value Decomposition, 35–55
geometric interpretation, 41
reduced, 45
theorem, 41
solve
triangular, 175–178
Spark webpage, 75
spectral radius
definition, 217
spectrum
definition, 217
transpose, 4–7
matrix, 5
vector, 4
triangular solve, 175
lower, 175–178
upper, 178
triangular system solve, 178
upper triangular solve, 178
vector
complex conjugate, 4
conjugate, 4
403