Starting from:

$25

Problem Set #0: Linear Algebra and Multivariable

CS229 Problem Set #0 

Problem Set #0: Linear Algebra and Multivariable
Calculus
Notes: (1) These questions require thought, but do not require long answers. Please be as
concise as possible. (2) If you have a question about this homework, we encourage you to post
your question on our Piazza forum, at https://piazza.com/stanford/fall2018/cs229. (3) If
you missed the first lecture or are unfamiliar with the collaboration or honor code policy, please
read the policy on Handout #1 (available from the course website) before starting work. (4)
This specific homework is not graded, but we encourage you to solve each of the problems to
brush up on your linear algebra. Some of them may even be useful for subsequent problem sets.
It also serves as your introduction to using Gradescope for submissions.
1. [0 points] Gradients and Hessians
Recall that a matrix A ∈ R
n×n is symmetric if AT = A, that is, Aij = Aji for all i, j. Also
recall the gradient ∇f(x) of a function f : R
n → R, which is the n-vector of partial derivatives
∇f(x) =




∂x1
f(x)
.
.
.

∂xn
f(x)



where x =



x1
.
.
.
xn


 .
The hessian ∇2f(x) of a function f : R
n → R is the n × n symmetric matrix of twice partial
derivatives,
∇2
f(x) =








2
∂x2
1
f(x)

2
∂x1∂x2
f(x) · · ·

2
∂x1∂xn
f(x)

2
∂x2∂x1
f(x)

2
∂x2
2
f(x) · · ·

2
∂x2∂xn
f(x)
.
.
.
.
.
.
.
.
.
.
.
.

2
∂xn∂x1
f(x)

2
∂xn∂x2
f(x) · · ·

2
∂x2
n
f(x)







.
(a) Let f(x) = 1
2
x
T Ax + b
T x, where A is a symmetric matrix and b ∈ R
n is a vector. What
is ∇f(x)?
(b) Let f(x) = g(h(x)), where g : R → R is differentiable and h : R
n → R is differentiable.
What is ∇f(x)?
(c) Let f(x) = 1
2
x
T Ax+b
T x, where A is symmetric and b ∈ R
n is a vector. What is ∇2f(x)?
(d) Let f(x) = g(a
T x), where g : R → R is continuously differentiable and a ∈ R
n is a vector.
What are ∇f(x) and ∇2f(x)? (Hint: your expression for ∇2f(x) may have as few as 11
symbols, including 0 and parentheses.)
2. [0 points] Positive definite matrices
A matrix A ∈ R
n×n is positive semi-definite (PSD), denoted A  0, if A = AT and x
T Ax ≥ 0
for all x ∈ R
n. A matrix A is positive definite, denoted A  0, if A = AT and x
T Ax > 0 for
all x 6= 0, that is, all non-zero vectors x. The simplest example of a positive definite matrix is
the identity I (the diagonal matrix with 1s on the diagonal and 0s elsewhere), which satisfies
x
T
Ix = kxk
2
2 =
Pn
i=1 x
2
i
.
CS229 Problem Set #0 2
(a) Let z ∈ R
n be an n-vector. Show that A = zzT
is positive semidefinite.
(b) Let z ∈ R
n be a non-zero n-vector. Let A = zzT
. What is the null-space of A? What is
the rank of A?
(c) Let A ∈ R
n×n be positive semidefinite and B ∈ R
m×n be arbitrary, where m, n ∈ N. Is
BABT PSD? If so, prove it. If not, give a counterexample with explicit A, B.
3. [0 points] Eigenvectors, eigenvalues, and the spectral theorem
The eigenvalues of an n × n matrix A ∈ R
n×n are the roots of the characteristic polynomial
pA(λ) = det(λI − A), which may (in general) be complex. They are also defined as the the
values λ ∈ C for which there exists a vector x ∈ C
n such that Ax = λx. We call such a pair
(x, λ) an eigenvector, eigenvalue pair. In this question, we use the notation diag(λ1, . . . , λn)
to denote the diagonal matrix with diagonal entries λ1, . . . , λn, that is,
diag(λ1, . . . , λn) =







λ1 0 0 · · · 0
0 λ2 0 · · · 0
0 0 λ3 · · · 0
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
0 0 0 · · · λn







.
(a) Suppose that the matrix A ∈ R
n×n is diagonalizable, that is, A = TΛT
−1
for an invertible
matrix T ∈ R
n×n, where Λ = diag(λ1, . . . , λn) is diagonal. Use the notation t
(i)
for the
columns of T, so that T = [t
(1)
· · · t
(n)
], where t
(i) ∈ R
n. Show that At(i) = λit
(i)
, so
that the eigenvalues/eigenvector pairs of A are (t
(i)
, λi).
A matrix U ∈ R
n×n is orthogonal if U
TU = I. The spectral theorem, perhaps one of the most
important theorems in linear algebra, states that if A ∈ R
n×n is symetric, that is, A = AT
,
then A is diagonalizable by a real orthogonal matrix. That is, there are a diagonal matrix
Λ ∈ R
n×n and orthogonal matrix U ∈ R
n×n such that U
T AU = Λ, or, equivalently,
A = UΛU
T
.
Let λi = λi(A) denote the ith eigenvalue of A.
(b) Let A be symmetric. Show that if U = [u
(1)
· · · u
(n)
] is orthogonal, where u
(i) ∈
R
n and A = UΛU
T
, then u
(i)
is an eigenvector of A and Au(i) = λiu
(i)
, where Λ =
diag(λ1, . . . , λn).
(c) Show that if A is PSD, then λi(A) ≥ 0 for each i.

More products