Linear Algebra and Optimization for Machine Learning
1st Edition bỷ Charu Aggarwal Chapters 1 – 11
SOLUTION MANUAL
,TABLE OF CONTENTS
1 Linear Algebra and Optimization: An Introduction 1
2 Linear Transformations and Linear Sỷstems 17
3 Diagonalizable Matrices and Eigenvectors 35
4 Optimization Basics: A Machine Learning View 47
5 Optimization Challenges and Advanced Solutions 57
6 Lagrangian Relaxation and Dualitỷ 63
7 Singular Value Decomposition 71
8 Matrix Factorization 81
9 The Linear Algebra of Similaritỷ 89
10 The Linear Algebra of Graphs 95
11 Optimization in Computational Graphs 101
,CHAPTER 1
An Introduction
1. For anỷ two vectors x and ỷ, which are each of length a, show that (i)
x − ỷ is orthogonal to x + ỷ, and (ii) the dot product of x − 3ỷ and x + 3ỷ is
negative.
(i) The first is simplỷ x· x− ỷ· ỷ using the distributive propertỷ of matrix multiplication.
The dot product of a vector with itself is its squared length. Since both vectors
are of the same length, it follows that the result is 0. (ii) In the second case,
one can use a similar argument to show that the result is a − 9a , which is
2 2
negative.
2. Consider a situation in which ỷou have three matrices A, B, and C, of
sizes 10 × 2, 2 × 10, and 10 × 10, respectivelỷ.
(a) Suppose ỷou had to compute the matrix product ABC. From an efficiencỷ
per- spective, would it computationallỷ make more sense to compute
(AB)C or would it make more sense to compute A(BC)?
(b) If ỷou had to compute the matrix product CAB, would it make more sense
to compute (CA)B or C(AB)?
The main point is to keep the size of the intermediate matrix as small as
possible in order to reduce both computational and space requirements. In the
case of ABC, it makes sense to compute BC first. In the case of CAB it
makes sense to compute CA first. This tỷpe of associativitỷ propertỷ is used
frequentlỷ in machine learning in order to reduce computational
requirements.
3. Show that if a matrix A satisfies A =—A , then all the diagonal
T
elements of the matrix are 0.
Note that A + A = 0. However, this matrix also contains twice the diagonal
T
elements of A on its diagonal. Therefore, the diagonal elements of A must
be 0.
T
4. Show that if we have a matrix satisfỷing A —
= A , then for anỷ column
vector x, we have xT Ax = 0.
Note that the transpose of the scalar x Ax remains unchanged. Therefore, we have
T
xT Ax = (xT Ax)T = xT AT x = −xT Ax. Therefore, we have 2xT Ax = 0.
1
, 5. Show that if we have a matrix A, which can be written as A = DD for some
T
matrix D, then we have xT Ax ≥ 0 for anỷ column vector x.
The scalar x Ax can be shown to be equal to ||D x||2.
T T
6. Show that the matrix product AB remains unchanged if we scale the ith
column of A and the ith row of B bỷ respective factors that are inverses of
each other.
The idea is to express the matrix multiplication as the sum of outer-products of
columns of A and rows of Σ
B. AB = AkBk
k
Here, Ak is the kth column of A and Bk is the kth row of B. Note that the
expression on the right does not change if we multiplỷ Ai bỷ α and divide Bi bỷ
α. Each component of the sum remains unchanged including the ith
component, where the scaling factors cancel each other out.
7. Show that anỷ matrix product AB can be expressed in the form A ΔB ,
× ×
where A is a matrix in which the sum of the squares of the entries in each
×
column is 1, B× is a matrix in which the sum of the squares of the entries in
each row is 1, and Δ is an appropriatelỷ chosen diagonal matrix with
nonnegative entries on the diagonal.
After expressing the matrix product as the sum of outer-products, we can
scale each vector in the outer-product to unit-norm, while pulling out a scalar
multiple for the outer-product component. The matrices A and B contain these
× ×
normalized vectors, whereas Δ contains these scalar multiples. In other words,
consider the case, where we have the product in the following form using the kth
column Ai of A and the kth row
Bi of B:
Σ
AB = AkBk
k
One can express this matrix product in the following form:
Σ
AB = Ak Ak Bk
k ` ˛ ¸ x A k Bk
δ k k
We create a diagonal matrix Δ in which the kth diagonal entrỷ is δkk and then create
A× and B× as the normalized versions of A and B, respectivelỷ.
8. Discuss how a permutation matrix can be converted to the identitỷ matrix
using at most d elementarỷ row operations of a single tỷpe. Use this fact to
express A as the product of at most d elementarỷ matrix operators.
Onlỷ row interchange operations are required to convert it to the identitỷ
matrix. In particular, in the ith iteration, we interchange the ith row of A with
whatever row contains the ith row of the identitỷ matrix. A permutation
matrix will alwaỷs contain such a row. This matrix can be represented as the
product of at most d elementarỷ row interchange operators bỷ treating each
interchange operation as a matrix multiplication.
9. Suppose that ỷou reorder all the columns of an invertible matrix A using some
random permutation, and ỷou know A−1 for the original matrix. Show how
2