Professional Documents
Culture Documents
Karianne Bergen
kbergen@stanford.edu
Institute for Computational and Mathematical Engineering,
Stanford University
K. Bergen
(ICME)
1 / 140
Course Topics
K. Bergen
(ICME)
2 / 140
K. Bergen
(ICME)
3 / 140
(Greek letters)
(ICME)
4 / 140
a11
a21
an = .
..
A = a1 a2
a12
a22
..
.
am1 am2
a1n
a2n
.. ,
.
amn
aT1
aT2
AT =
T
am
K. Bergen
(ICME)
(upper case)
5 / 140
Operations on vectors
Scalar multiplication:
x1
x1
x2 x2
x = . = .
.. ..
(x)i = xi ,
xn
xn
Vector addition/subtraction:
(x + y)i = xi + yi ,
x1
y1
x 1 + y1
x 2 y2 x 2 + y2
x+y = . + . =
..
.. ..
.
xn
yn
x n + yn
n
X
xi yi = x1 y1 + x2 y2 + + xn yn
i=1
(ICME)
xy
6 / 140
Vector norms
Positivity: f (x) = 0 x 0
K. Bergen
(ICME)
u, v Rn
7 / 140
n
X
|vi |
i=1
n
X
!1
vi2
vT v
i=1
(ICME)
8 / 140
Questions?
K. Bergen
(ICME)
9 / 140
Mini-Quiz 1:
v = 6
2
K. Bergen
(ICME)
10 / 140
Solution (Q1):
Solutions:
1-norm:
kvk1 =
3
X
vi = 3 + 6 + 2 = 11
i=1
2-norm:
kvk2 =
3
X
!1
2
vi2
32 + 62 + 22 = 9 + 36 + 4 = 49 = 7
i=1
-norm
kvk = max |vi | = max{3, 6, 2} = 6
i
K. Bergen
(ICME)
11 / 140
Cauchy-Schwartz Inequality
for x, y Rn
K. Bergen
(ICME)
12 / 140
uv
K. Bergen
(ICME)
13 / 140
uT v u
kuk kuk
K. Bergen
(ICME)
14 / 140
Questions?
K. Bergen
(ICME)
15 / 140
Mini-Quiz 2:
K. Bergen
(ICME)
16 / 140
Solution (Q2):
Give an algebraic proof for the triangle inequality
kx + yk2 kxk2 + kyk2
using the Cauchy-Schwartz inequality. (Hint: expand kx + yk2 )
Solution:
kx + yk2 = (x + y)T (x + y)
= xT x + 2xT y + y T y
= kxk2 + kyk2 + 2 xT y
(by Cauchy-Schwartz)
= (kxk + kyk)
K. Bergen
(ICME)
17 / 140
(A)ij = Aij ,
a11
am1
a1n
..
a11
=
am1
amn
a1n
..
.
amn
Matrix addition:
(A + B)ij = Aij + Bij
a11 + b11
a1n + b1n
..
A+B =
,
.
am1 + bm1
amn + bmn
K. Bergen
(ICME)
A, B Rmn
18 / 140
Matrix-vector multiplication
Matrix-vector multiplication:
(Ax)i =
n
X
Aij xj ,
A Rmn ,
x Rn
j=1
x1
x2
Ax = a1 a2 an . = x1 a1 +x2 a2 + +xn an
..
xn
Matrix-vector product in terms as a vector of scalar products
a
T1
a
T1 x
T
T
a
2
2 x
Ax = . x =
.
..
..
a
Tm
K. Bergen
(ICME)
a
Tm x
19 / 140
Matrix-matrix multiplication
Matrix product:
(AB)ij =
p
X
A Rmp ,
Aik Bkj ,
B Rpn
k=1
a
T1
T
a
2
(AB)ij = a
Ti bj ,
A= .
..
a
Tm
products:
B = b1 b2
bn
Since inner products are only defined for vectors of the same
length, the matrix product requires that a
i , bj Rp for all i, j.
K. Bergen
(ICME)
20 / 140
AB = A b1 b2
AB =
a
T1
a
T2
..
.
a
Tm
bn = Ab1 Ab2
B =
a
T1 B
a
T2 B
..
.
a
Tm B
Abn
(ICME)
21 / 140
1 1
1 0
and B =
, then
0 1
1 1
2 1
1 1
AB =
6
=
= BA.
1 1
1 2
K. Bergen
(ICME)
22 / 140
x1 y1 x1 y2 x1 yn
x1
x2
x 2 yn
x2 y1 x2 y2
xy T = . y1 y2 yn = .
..
..
..
..
.
.
xm y1 xm y2
xm
xy T
xm yn
= x i yj
ij
x Rm , y Rn ,
xy T Rmn
K. Bergen
(ICME)
23 / 140
Questions?
K. Bergen
(ICME)
24 / 140
Mini-Quiz 3:
Which of the following vector and matrix operations are well-defined?
1
2
3
x
A
xy
4
5
6
= 5,
1
x = 5 ,
2
K. Bergen
(ICME)
xT y
xT z
zxT
4
y = 0 ,
1
z=
3
,
0
Az
z T Ay
A=
4 0 2
1 5 3
25 / 140
Solution (Q3):
Which of the following vector and matrix operations are well-defined?
1
2
3
x
A
xy
Yes
Yes
Yes
4
5
6
= 5,
1
x = 5 ,
2
K. Bergen
(ICME)
xT y
xT z
zxT
Yes
No
Yes
4
y = 0 ,
1
z=
3
,
0
Az
No
z T Ay
Yes
A=
4 0 2
1 5 3
26 / 140
Transpose of a Matrix
Transpose: the transpose of matrix A Rmn is the matrix
AT Rnm formed by exchanging the rows and columns of A:
(AT )ij = Aji
Properties:
(AT )T
T
(A + B)
K. Bergen
(ICME)
= A
= AT + B T
(AB)T
= B T AT
(B)T
= (B T )
27 / 140
Trace of a Matrix
Trace: the trace of a square matrix A Rnn is the sum of its
diagonal entries:
n
X
tr(A) =
aii
i=1
tr(A) = tr(A )
tr(AB) = tr(BA)
The trace of a matrix product functions similarly to the inner
product of vectors:
X
tr(AT B) =
Aij Bij , A, B Rmn
i,j
K. Bergen
(ICME)
28 / 140
Matrix norms
Induced norm (operator norm) corresponding to vector norm k k:
kAk = max kAxk
kxk=1
I
I
I
Frobenius norm:
v
uX
n
q
um X
|aij |2 = trace(AT A)
kAkF = t
i=1 j=1
K. Bergen
(ICME)
29 / 140
(ICME)
30 / 140
K. Bergen
(ICME)
31 / 140
(ICME)
32 / 140
Questions?
K. Bergen
(ICME)
33 / 140
Mini-Quiz 4:
Determine whether each statement given below is True or False:
There exist matrices A, B 6= 0 such that AB = 0.
The trace is invariant under cyclic permutations:
tr(ABC) = tr(CAB) = tr(BCA).
The definition of the induced norm allows us to use different vector
norms on the numerator and denominator
kAk, = max kAxk .
kxk =1
(ICME)
34 / 140
Solutions (Q4):
Determine whether each statement given below is True or False:
There exist matrices A, B 6= 0 such that AB = 0.
1 2
2 4
TRUE : For example, when A =
, and B =
.
2 4
1 2
The trace is invariant under cyclic permutations:
tr(ABC) = tr(CAB) = tr(BCA).
TRUE
Use the property that tr(XY ) = tr(Y X):
To show that tr(ABC) = tr(CAB), let X = AB, and Y = C.
To show that tr(ABC) = tr(BCA), let X = A and Y = BC.
K. Bergen
(ICME)
35 / 140
Solutions (Q4):
Determine whether each statement given below is True or False:
The definition of the induced norm allows us to use different vector
norms on the numerator and denominator
kAk, = max kAxk .
kxk =1
K. Bergen
(ICME)
T
= max max(
ai xi ) = max |aij |.
kxk1 =1
i,j
36 / 140
d1
(
di if i = j
0
Dij =
,
D=.
..
0 if i 6= j
0
0
0
..
.
dn
1 0 0
(
0 1
0
1 if i = j
Iij =
,
I = .
..
.
.
.
.
. .
0 if i 6= j
0 0 1
AIn = Im A = A
AI = IA = A
K. Bergen
(ICME)
37 / 140
l11
l21
L= .
..
l22
..
.
lm1 lm2
I
I
I
..
u11 u12
u22
U =
..
lmn
u1n
u2n
..
.
umn
K. Bergen
(ICME)
38 / 140
1
2
A = AT Rnn ,
A= .
..
..
.
it is equal to
..
.
n
K. Bergen
(ICME)
39 / 140
Questions?
K. Bergen
(ICME)
40 / 140
Mini-Quiz 5:
Determine whether each statement given below is True or False:
For any A Rnn , AT A is symmetric.
For any A Rnn , A AT is symmetric.
Invariance under Unitary Multiplication.
For any matrix x Rm and unitary Q Rmm , we have
kQxk2 = kxk2
Let D Rnn = diag(d1 , , dn ) be any diagonal matrix, then
DA = AD for any matrix A Rnn .
K. Bergen
(ICME)
41 / 140
Solution (Q5):
K. Bergen
(ICME)
AT
0 2
=
.
2 0
42 / 140
Solution (Q5):
Invariance under Unitary Multiplication.
For any matrix x Rm and unitary Q Rmm , we have
kQxk2 = kxk2
TRUE : kQxk22 = (Qx)T (Qx) = xT QT Qx = xT x = kxk22
Similarly, for the matrix 2-norm and Frobenius norm, we have:
kQAk22 = max (QA)T (QA)
= max AT QT QA
= max AT A)
= kAk22
and kQAk2F
= tr (QA)T (QA)
= tr AT A
= kAk2F
K. Bergen
(ICME)
43 / 140
Solution (Q5):
Determine whether each statement given below is True or False:
Let D Rnn = diag(d1 , , dn ) be any diagonal matrix, then
DA = AD for any matrix A Rnn .
FALSE
DA rescales the rows of A while AD rescales the columns of A:
d1 a
T1
a
1
d1 0 0
T d2 a
0 d2
T2
0
2
=
DA = .
6=
.
.
.
..
..
..
. .. ..
T
T
dn a
n
a
n
0 0 dn
AD = a1
K. Bergen
(ICME)
d1 0
0 d2
an .
..
..
.
0 0
.. = d1 a1
.
dn an
dn
44 / 140
Vector Spaces
K. Bergen
(ICME)
45 / 140
Linear Transformations
Linear transformation: T : Rn Rm is a linear transformation if
for all x, y Rn the following properties hold:
I
T (x + y) = T (x) + T (y)
T (x) = T (x)
K. Bergen
(ICME)
46 / 140
Linear Combinations
Let v1 , v2 , , vr Rm be a set of vectors. Then any vector v
which can be written in the form
v = 1 v1 + 2 v2 + + r vr ,
i R i = 1, . . . , r
K. Bergen
(ICME)
47 / 140
Linear Independence
Linear dependence: a set of vectors v1 , v2 , , vr is linearly
dependent if there exists a set of scalars 1 , 2 , , r R with
at least one i 6= 0 such that
1 v1 + 2 v2 + + r vr = 0
That is, a set of vectors is linearly dependent if one of the vectors
in the set can be written as a linear combination of one or more
other vectors in the set.
Linear independence: a set of vectors v1 , v2 , , vr is linearly
independent if it is not linearly dependent. That is
1 v1 + 2 v2 + + r vr = 0
K. Bergen
(ICME)
1 = = r = 0
48 / 140
Questions?
K. Bergen
(ICME)
49 / 140
Mini-Quiz 6:
Are the following sets of vectors linearly independent or linearly
dependent?
1
{a, b, c}
{b, c, d}
{a, b, d}
{a, b, c, d}
1
a = 0 ,
0
K. Bergen
(ICME)
0
b = 1 ,
1
0
c = 0 ,
1
0
d = 1
1
50 / 140
Solution (Q6):
Are the following sets of vectors linearly independent or linearly
dependent?
1
{a, b, c}
independent
{b, c, d}
dependent: b + 2c = d
{a, b, d}
independent
K. Bergen
(ICME)
51 / 140
The basis for a subspace S is not unique, but all bases for the
subspace contain the same number of vectors.
For example, consider the case where S = R2 :
1
0
1
1
,
and
,
are both bases that span R2 .
0
1
1
1
K. Bergen
(ICME)
52 / 140
R(A) Rm
N (A) Rn
The range and nullspace of AT are called the row space and left
nullspace of A.
I
K. Bergen
(ICME)
53 / 140
Rank of a Matrix
K. Bergen
(ICME)
54 / 140
N (AT ) = (R(A))
Corollary (Rank-nullity):
dim (R(A)) + dim (N (A)) = n,
K. Bergen
(ICME)
A Rmn
55 / 140
Questions?
K. Bergen
(ICME)
56 / 140
Mini-Quiz 7:
1 0
1 0 1
32
A = 0 2 R , and B =
R23
0 1 1
0 0
What are their dimensions ( dim (R()) and dim (N ()) )?
K. Bergen
(ICME)
57 / 140
Solution (Q7):
Give the range R() and nullspace N () for the matrices
1 0
1 0 1
32
A = 0 2 R , and B =
R23
0 1 1
0 0
What are their dimensions ( dim (R()) and dim (N ()) )?
Solution:
0
1
R(A) = 0 + 2 , , R ,
N (A) =
0
0
1
1
0
+
, , R ,
N (B) = 1 , R
R(B) =
0
1
1
dim (R(A)) = 2
dim (N (A)) = 0
dim (R(B)) = 2
dim (N (B)) = 1
K. Bergen
(ICME)
58 / 140
K. Bergen
(ICME)
59 / 140
Nonsingular Matrix
Theorem: a matrix A Rmn with m n has full rank if and
only if it maps no two distinct vectors to the same vector, and
Ax = Ay
x = y.
AX = A x1
K. Bergen
(ICME)
xn = Ax1
Axn = e1
60 / 140
en = I
Matrix Inverse
Matrix inverse: the inverse of a square matrix A Rnn is the
matrix B Rnn such that
AB = BA = I
I
I
I
I
(ICME)
61 / 140
A is invertible, A is nonsingular.
There exists a matrix A1 such that AA1 = In = A1 A.
Ax = b has exactly one solution for each b Rn .
Az = 0 has only the trivial solution z = 0, i.e. N (A) =
The columns of A are linearly independent.
A is full rank, i.e. rank(A) = n.
det(A) 6= 0.
0 is not an eigenvalue of A.
K. Bergen
(ICME)
62 / 140
Questions?
K. Bergen
(ICME)
63 / 140
Mini-Quiz 8:
K. Bergen
(ICME)
1
= B 1 A.
64 / 140
Solutions (Q8):
If A and B Rnn are two invertible matrices, which of the following
formulas are necessarily true?
A + B is invertible and (A + B)1 = A1 + B 1 .
FALSE : A =
1 1
,
0 1
1 1
=
,
0 1
B=
1
1 0
,
1 1
1 0
=
,
1 1
2 1
1 2
A+B =
(A + B)
=
2
3
31
13
2
3
(A + B)2 = A2 + 2AB + B 2 .
FALSE : (A + B)2 = A2 + AB + BA + B 2 and AB 6= BA for all
invertible matrix pairs A, B.
K. Bergen
(ICME)
65 / 140
Solutions (Q8):
If A and B Rnn are two invertible matrices, which of the following
formulas are necessarily true?
(ABA1 )3 = AB 3 A1
TRUE
1
= B 1 A
TRUE
(ICME)
66 / 140
x1 3x2 = 7
K. Bergen
(ICME)
2 1
,
1 3
x=
x1
7
, and b =
x2
7
67 / 140
Linear Systems
One of the fundamental problems in linear algebra:
Given A Rmn and b Rm , find x Rn such that
Ax = b.
The set of solutions of a linear system can behave in three ways:
1
2
3
K. Bergen
(ICME)
68 / 140
(ICME)
69 / 140
K. Bergen
(ICME)
70 / 140
A b =
Step 2 : Compute
Step 3 : Solve
+ +
+
K. Bergen
L1
0 +
0 +
L2
+
0
row operations.
+ +
+ +
+ +
+ +
back substitution
+ = U y , Ux = y
x = U 1 y
+
(ICME)
71 / 140
Questions?
K. Bergen
(ICME)
72 / 140
Mini-Quiz 9:
Determine the lower triangular matrices Li that correspond to the
following elementary row operations:
L1 such that L1 A = A1 :
2 8
4
1 4
2
1 = 2 5
1
L1 2 5
4 10 1
4 10 1
L2 such that L2 A1 = A2 :
1 4
2
1 4
2
1 = 0 3 3
L2 2 5
4 10 1
4 10 1
L3 such that L3 A2 = A3 :
1 4
2
1 4
2
L3 0 3 3 = 0 3 3
4 10 1
0 6 9
K. Bergen
(ICME)
73 / 140
Solution (Q9):
1
0 0
2 8
4
1 4
2
1 = 2 5
1
L1 A = A1 : 0 1 0 2 5
0 0 1
4 10 1
4 10 1
2
1 0 0
1 4
2
1 4
2
1 = 0 3 3
L2 A1 = A2 : 2 1 0 2 5
0 0 1
4 10 1
4 10 1
1 0 0
1 4
2
1 4
2
L2 A3 = A3 : 0 1 0 0 3 3 = 0 3 3
4 0 1
4 10 1
0 6 9
L3 L2 L1 such that L3 L2 L1 A = A3 :
1
0 0
2 8
4
1 4
2
2
1 1 0 2 5
1 = 0 3 3
2 0 1
4 10 1
0 6 9
K. Bergen
(ICME)
74 / 140
or
L1 A = U,
1
L1 = L1
1 Ln1
K. Bergen
(ICME)
75 / 140
Partial Pivoting
K. Bergen
(ICME)
76 / 140
Permutations
The reordering, or permutation, of the columns in partial pivoting
can be represented as a linear transformation.
Permutation matrix : a square, binary matrix P Rnn that has
exactly one entry 1 in each row and each column.
I
0 1 0
For example, let P = 0 0 1 ,
1 0 0
1
2
3
A = 10 20 30 ,
100 200 300
10 20 30
3
2
1
P A = 100 200 300 , and AP = 30 20 10 .
1
2
3
300 200 100
K. Bergen
(ICME)
77 / 140
LU Decomposition
Let A Rnn be a square matrix, then the LU decomposition
factors A into the product of a lower triangular matrix L Rnn
and an upper triangular matrix U Rnn
A = LU.
When partial pivoting is used to permute the rows, we obtain a
decomposition for the form Ln1 Pn1 L1 P1 A = U , which can
be written3 in form: L1 P A = U .
In general, any square matrix A Rnn (singular or nonsingular)
has a factorization
P A = LU,
(ICME)
78 / 140
for every z Rn ,
often denoted by A 0.
Example:
A=
xT Ax =
x1 x2
4 2
2 10
4 2 x1
2 10 x2
x 6= 0
K. Bergen
(ICME)
79 / 140
L1 A
0 + + = L1 A = A1
A =
0 + +
0 0
A1 LT
A1 = 0 1 0 + + = A2 = A1 LT1 = L1 ALT1
0
0 + +
K. Bergen
(ICME)
80 / 140
Questions?
K. Bergen
(ICME)
81 / 140
Mini-Quiz 10:
Quadratic forms: a function q(x) : Rn R if it is a linear
combination of functions of the form xi xj . A quadratic form can
be written as
q(x) = xT Ax,
1 2 3
1 3 2
A = 4 5 6 , B = 7 9 8
7 8 9
4 6 5
K. Bergen
(ICME)
82 / 140
Solution (Q10):
Let B Rmn . Show that q(x) = kBxk2 is a quadratic form, find
A such that q(x) = xT Ax, and determine the definiteness of A.
Solution:
q(x) = (Ax)T (Ax) = xT AT Ax = xT Bx,
where B = AT A.
1
A = 4
7
K. Bergen
2 3
1 3 2
1 0 0
5 6 , B = 7 9 8 , and P = 0 0 1
8 9
4 6 5
0 1 0
(ICME)
83 / 140
Orthogonalization
K. Bergen
(ICME)
84 / 140
q1
QT Q = ... q1 qn = In
qnT
I
I
kQxk2 = xT QT Qx = xT Ix = kxk2
K. Bergen
(ICME)
85 / 140
Projectors
uT v u
kuk kuk
K. Bergen
(ICME)
86 / 140
Orthogonal Projectors
K. Bergen
(ICME)
v R(A) 6= xk .
87 / 140
K. Bergen
(ICME)
88 / 140
Questions?
K. Bergen
(ICME)
89 / 140
Mini-Quiz 11:
Show that if P is an orthogonal projector, then I 2P is
orthogonal.
Hint: P T = P for orthogonal projectors and P 2 = P for all
projectors. Q is orthogonal if QT Q = I.
Find the matrix for the orthogonal
A= 0
1
0
1 .
0
K. Bergen
(ICME)
90 / 140
Solution (11):
Show that if P is an orthogonal projector, then I 2P is
orthogonal. Solution:
(I 2P )T (I 2P ) = I 2 2P T I 2IP + 4P T P
= 4P 2 4P + I
= 4P 4P + I
(P T = P )
(P 2 = P )
= I
1 0
Find the orthogonal projector PA onto R(A): A = 0 1.
1 0
R(A) = R Q = 0 1
1
0
2
1
1
2 0 2
PA = PQ = QQT = 0 1 0
1
1
2 0 2
K. Bergen
(ICME)
91 / 140
Gram-Schmidt Orthogonalization
Gram-Schmidt algorithm: a method for computing an orthonormal
basis {q1 , , qm } for a set of vectors A = [a1 , , an ] Rmn .
Each vector is orthogonalized with respect to the previous vectors
and then normalized:
v1 = a1
q1 =
v2 = a2 projq1 a2
q2 =
v1
kv1 k
v2
kv2 k
..
.
vk = ak
..
.
k1
X
projqi ak
qk =
vk
kvk k
i=1
(ICME)
if i j
if i > j
92 / 140
QR Decomposition
In the process of orthogonalizing the columms of matrix A, the
Gram-Schmidt algorithm computes the QR decomposition of A.
QR decomposition: any matrix A Rmn can be decomposed as
A = QR
where Q Rmm is an orthogonal matrix, and R Rmn is an
upper triangular matrix.
For rectangular A Rmn , m n
A = QR = Q1
R1
Q2
= Q1 R1
0
(ICME)
93 / 140
K. Bergen
(ICME)
94 / 140
Questions?
K. Bergen
(ICME)
95 / 140
Mini-Quiz 12:
1
2
12
1
3
13
A=
3
2
3
2
3
1
3
Hint: All three columns are normalized to length 1. The first and
second columns are orthogonal, and the second and third columns
are orthogonal. The projection operator for normalized vectors is
proju v = (uT v)u.
K. Bergen
(ICME)
96 / 140
Solution (Q12):
Use Gram-Schmidt to compute an orthonormal basis for A :
A=
q1 = a1 ,
1
13
3
1
3
1
2
12
2
3
2
3
1
3
q2 = a2
29
3
3
1
q3 =
K. Bergen
(ICME)
16
v3
=
kv3 k 6
26
Applied Linear Algebra
97 / 140
K. Bergen
(ICME)
98 / 140
Least Squares
K. Bergen
(ICME)
99 / 140
K. Bergen
(ICME)
100 / 140
Normal Equations
K. Bergen
(ICME)
101 / 140
kb Ax? k kb Axk,
Ax? = PA b
x Rn
AT (b Ax? ) = 0
AT Ax? = AT b
(ICME)
102 / 140
Questions?
K. Bergen
(ICME)
103 / 140
Mini-Quiz 13
Find the least squares solution of
1 0
1
0 1 x1 = 2 .
x2
0 1
1
by solving Ax = b1 or AT Ax = AT b
Hints:
0
1
R(A) = 0 + 1 , , R ,
0
1
N (AT ) = 1 , R ,
1
0
0
b = 1 0 + 1.5 1 + 0.5 1
0
1
1
K. Bergen
(ICME)
104 / 140
Mini-Quiz 13
Find the least squares solution of
1 0
1
x
0 1 1 = 2 .
x2
0 1
1
Solution:
1
0
b = b1 + b2 + 1.5 + 0.5 ,
1.5
0.5
1 0
A A=
,
0 2
T
1 0
1
x
Ax = b1 = 0 1 1 = 1.5 =
x2
0 1
1.5
1 0 x1
1
=
AT Ax = AT b =
=
0 2 x2
3
K. Bergen
(ICME)
1
A b=
3
T
x1
1
=
x2
1.5
x1
1
=
x2
1.5
105 / 140
compute QR factorization of A : A = QR
form y = QT b
solve Rx = y by back substitution
K. Bergen
(ICME)
106 / 140
form M = AT A
compute the Cholesky factorization of M : M = LLT
form y = AT b
solve Lz = y by forward substitution
solve LT x = z by back substitution
K. Bergen
(ICME)
107 / 140
Matrix Calculus
Vector-by-scalar and Scalar-by-vector derivatives:
x
R, x Rn ,
1
x
2
=
.. ,
.
x
x2
xn
Vector-by-vector derivatives:
y
y Rm , x Rn ,
y
x
1
x
y1
x2
=
..
.
y1
xn
K. Bergen
(ICME)
y2
x1
y2
x2
..
y2
xn
ym
x1
ym
x2
..
ym
xn
108 / 140
xn
(bT x)
= b,
x
(xT Ax)
= A + AT x
x
(Ax)
= AT
x
= 2Ax, if A = AT
Derivative of a quadratic:
x kb
I
Axk22 =
xT AT Ax 2bT Ax + bT b = 2 AT Ax AT b
x kb
Axk22 = 0 = AT Ax = AT b
(ICME)
109 / 140
K. Bergen
(ICME)
110 / 140
For any square matrix A Rnn , there is at least one scalar and
a corresponding vector v 6= 0 such that:
Av = v
or equivalently
(A I)v = 0.
K. Bergen
(ICME)
111 / 140
(a)
(b)
2 1
Figure: Under the transformation matrix A =
, the directions of
1 2
1
1
vectors parallel to v1 =
(blue) and v2 =
(purple) are preserved.
1
1
5
(ICME)
112 / 140
K. Bergen
(ICME)
113 / 140
Similar Matrices
Two matrices A and B are similar is they share the same
eigenvalues.
I
K. Bergen
(ICME)
114 / 140
Diagonalizable Matrices
Diagonalizable matrix : a matrix A Rnn that is similar to a
diagonal matrix, i.e. there exists an invertible matrix P such that
P 1 AP = D,
where D is diagonal.
K. Bergen
(ICME)
115 / 140
Eigendecomposition
Note: this decomposition does not exist for every square matrix A.
1 1
e.g. A =
can not be diagonalized.
0 1
K. Bergen
(ICME)
116 / 140
Spectral Theorem
n
X
i ui uTi = U U T ,
i=1
K. Bergen
(ICME)
117 / 140
Properties of Eigenvalues
The trace of A Rnn is equal to the sum of its eigenvalues:
tr(A) =
n
X
i=1
1
i
K. Bergen
(ICME)
118 / 140
is an
Questions?
K. Bergen
(ICME)
119 / 140
Mini-Quiz 14
K. Bergen
(ICME)
120 / 140
Solution (Q14)
Show that if is an eigenvalue of a nonsingular matrix A with
corresponding eigenvector v, then v is also an eigenvector of A1 with
eigenvalue 1 .
Av = v
A
(Av) = A1 (v)
v = (A1 v)
1
v
K. Bergen
(ICME)
= A1 v
121 / 140
K. Bergen
(ICME)
122 / 140
For a 2 2 matrix,
a b
A=
, the matrix inverse is A1 =
c d
1
adbc
d b
.
c a
(ICME)
123 / 140
2 1
A=
,
1 2
(2 )
1
(A I) =
1
(2 )
det(A I) = (2 )(2 ) 1 1
= 2 4 + 3
This is a 2nd degree polynomial (i.e. quadratic). We want to find
the roots of this polynomial, 1 , and 2 , which will satisfy
det(A i I) = 0.
2 4 + 3 = 0
( 3)( 1) = 0
= 1 = 3,
K. Bergen
(ICME)
2 = 1
Applied Linear Algebra
124 / 140
Az = A(1 v1 + + n vn )
= 1 Av1 + + n Avn
= 1 1 v1 + + n n vn
Ak z = 1 k1 v1 + + n kn vn
(ICME)
125 / 140
K. Bergen
(ICME)
126 / 140
r
X
i ui viT ,
i=1
mm , V Rnn are unitary matrices and
where
U R
r 0
Rmn is a diagonal matrix with
=
0 0
r = diag(1 , , r ) and r min(m, n) = rank(A).
K. Bergen
(ICME)
127 / 140
diagram: http://people.sc.fsu.edu/~jburkardt/latex/fsu_2006/svd.png
K. Bergen
(ICME)
128 / 140
Singular Values
The number of non-zero singular values r is the rank of the matrix.
The singular values are also related to a class of matrix norms:
Spectral norm (induced by the Euclidean vector norm):
q
kAk2 = max (AT A) = max (A).
Frobenius norm:
v
v
u r
uX
n
q
uX
um X
T
2
kAkF = t
|aij | = trace(A A) = t
i2
i=1 j=1
K. Bergen
(ICME)
i=1
129 / 140
K. Bergen
(ICME)
130 / 140
Singular Vectors
The columns of U = [u1 , , um ] and V = [v1 , , vn ] are called
the left and right singular vectors of A, respectively.
The columns of U and V form an orthonormal set of vectors,
which can be regarded as orthonormal bases.
The singular vectors provide a convenient way to represent the
bases of the fundamental subspaces of matrix A.
If A Rmn is a matrix of rank r, then
R(A) = span {u1 , , ur }
N (AT ) = span {ur+1 , , um }
R(AT ) = span {v1 , , vr }
N (A) = span {vr+1 , , vn }
K. Bergen
(ICME)
131 / 140
r
X
i ui viT ,
i=1
kA Bk2 = k+1
k
P
i=1
i ui viT .
K. Bergen
(ICME)
132 / 140
(a) rank-1
approximation
(18,456 bytes 0.6%)
K. Bergen
(ICME)
(b) rank-2
approximation
(36,912 bytes 1.1%)
(c) rank-5
approximation
(92,280 bytes 2.8%)
133 / 140
(a) rank-10
approximation
(184,560 bytes 5.6%)
K. Bergen
(ICME)
(b) rank-20
approximation
(369,120 bytes 11.1%)
(c) rank-40
approximation
(738,240 bytes 22.3%)
134 / 140
(ICME)
135 / 140
Questions?
K. Bergen
(ICME)
136 / 140
Mini-Quiz 15
The SVD is useful in many linear algebra proofs, since it decomposes a
matrix into orthogonal and diagonal factors which have nice properties.
Let A Rmn = U V T . Show that
kAk2 = max (A) =
max
kxk=1, kyk=1
y T Ax.
Hint: Use the SVD and unitary invariance of the Euclidean vector
norm (kU xk = kxk).
Polar decomposition:
Show how any square matrix A Rnn = U V T can be written as
A = QS,
K. Bergen
(ICME)
137 / 140
Solution (Q15)
Let A = U V T . Show that kAk2 = max (A) =
Solution:
max
kxk=1,kyk=1
y T Ax =
=
=
max
kxk=1, kyk=1
max
max
kxk=1,kyk=1
y T Ax.
y T (U V T )x
(y T U )(V T x)
kV T xk=1, kU T yk=1
max
k
xk=1, k
y k=1
yT
x
= max ii
i
= max (A)
Show how any square matrix A = U V T can be written as
A = QS, Q orthogonal, S symmetric positive semi-definite.
Solution:
A = U V T = U In V T = U (V T V )V T = (U V T )(V V T )
A = QS,
K. Bergen
(ICME)
where Q = U V T , and S = V V T .
Applied Linear Algebra
138 / 140
The End!
K. Bergen
(ICME)
139 / 140
(ICME)
140 / 140