L. Vandenberghe
EE133A Spring 2015
Homework 1
Due: Wednesday 4/8/2015.
Data les for homework problems can be found at
www.seas.ucla.edu/~vandenbe/ee133a.
Homework is due at 4:00PM on the due date. There is a submission box in the TA
meeting room (67-112
EE133A HW1-MATLAB
I = find(labels < 5);
digits = digits(:,I);
labels = labels(:,I);%only condier digits 0-4,reduce # of columns
[n,N]=size(digits);%28*28 image for each col of digits-size
J0=NaN;
z = rand(n,5);%generate initial values
Dis=zeros(5,N);
for
L. Vandenberghe
EE133A
10/15/2014
Homework 1 solutions
1. (a) Not linear or ane. Choose
1
0
x=
,
0
1
y=
1
= .
2
,
We have
f (x) = f (y) = 1,
f (x) + f (y) = 1,
and
x + y =
1/2
1/2
,
f (x + y) = 0.
Therefore f (x + y) = f (x) + f (y). This example shows th
L. Vandenberghe
EE133A Spring 2015
Homework 2
Due: Wednesday 4/15/2015.
Reading assignment: Chapter 4, chapter 5, and sections 6.1, 6.2, 6.3 in chapter 6 of the
course reader.
1. Distance between parallel hyperplanes. Consider two hyperplanes
H1 = cfw_x R
L. Vandenberghe
EE133A Spring 2015
Homework 4
Due: Wednesday 5/6/2015.
Reading assignment: Sections 6.4 and 7.3 in the course reader, and the notes on LU
factorization on the course website.
1. Let Q be an n n orthogonal matrix, partitioned as
Q=
Q1 Q2
wh
L. Vandenberghe
EE133A
10/28/2015
Homework 4 solutions
1. Exercise 5.4. 2n ops. The diagonal elements of A1 are 1/Aii . Computing the trace
of A1 requires n divisions and n 1 additions.
2. Exercise 5.7.
(a) The i, j-element of DX + XD is (Dii + Djj )Xij .
L. Vandenberghe
EE133A
10/7/2015
Homework 1 solutions
1. Exercise 1.1 (c, d).
(a) Ane. Working out the squares gives
f (x) =
=
=
=
(x c)T (x c) (x d)T (x d)
(xT x cT x xT c + cT c) (xT x dT x xT d + dT d)
xT x 2cT x + cT c xT x + 2dT x dT d
2(d c)T x + c
L. Vandenberghe
EE133A
10/14/2015
Homework 2 solutions
1. Exercise 1.20.
(a) We rst expand the square in the numerator of J:
(c1 1 + c2 a b)T (c1 1 + c2 a b)
n(1 + c2 )
2
c2 n + 2c1 1T (c2 a b) + c2 a b 2
= 1
n(1 + c2 )
2
2
c + 2c1 (c2 ma mb ) + c2 a b 2
L. Vandenberghe
EE133A
10/21/2015
Homework 3 solutions
1. Exercise 3.1. The gures show the three interpolating polynomials. The polynomial
is the solid line. The function f (t) = 1/(1 + 25t2 ) is the dashed line.
Degree 5
1
0.8
0.6
0.4
0.2
0
0.2
1
0.5
0
0
Fall Quarter 2015
EE133A. Mathematics of Design
Course objectives: Provide an introduction to numerical computing and
numerical linear algebra, with applications to problems in engineering and
data analysis.
Catalog description: Introduction to numerical
EE133A Formulas
Inner product, norm, angle.
Relation between inner product, norms, and angle:
aT b = a
b cos (a, b).
Average value of elements of an n-vector: avg(a) = (1T a)/n.
Root-mean-square value of an n-vector: rms(a) = a / n.
Standard deviatio
L. Vandenberghe
EE133A
11/2/2015
Midterm solutions
Problem 1. In the homework you derived the following factorization of a circulant Toeplitz matrix
T (a) with the n-vector a as its rst column:
a1
a2
a3
.
.
.
an
a1
a2
.
.
.
T (a) =
an1 an2
an an1
an1
a
L. Vandenberghe
EE133A
4/29/15
Midterm Exam
You have time until 9:50.
Only this booklet should be on your desk. You do not need a calculator.
Please turn o and put away your cellphones.
Write your answers neatly and concisely in the space provided aft
L. Vandenberghe
EE133A
11/25/2015
Homework 6 solutions
1. Exercise 8.15.
(a) The variable z only appears in the kth term (aT y + z bk )2 . The optimal choice,
k
therefore, is z = bk aT y so the kth term vanishes.
k
(b) The problem in part (a) can be writt
EE133A Mathematics of DesignWeek 1
Cameron Allan Gunn
Electrical Engineering Department
UCLA
1
Introduction
This week we will work through the foundations of using the programming language MATLAB. If you have
used programming languages in the past, some o
EE133A Formulas
Inner product, norm, angle.
Relation between inner product, norm, and angle:
aT b = a
b cos (a, b).
Average value of elements of an n-vector: avg(a) = (1T a)/n.
Root-mean-square value of an n-vector: rms(a) = a / n.
Standard deviation
L. Vandenberghe
EE133A (Spring 2015)
15. Problem condition
condition of a mathematical problem
matrix norm
condition number
15-1
Sources of error in numerical computation
Example: evaluate a function f : R R at a given x
sources of error in the result:
Homework 1 Solutions
1.1 (c,d)
(a) Affine. We prove this by demonstrating that it can be written in the affine form f (x) = aT x + b
(slide 1-30).
Expanding the norms,
f (x) = kx ck2 kx dk2
= (x c)T (x c) (x d)T (x d)
= (xT x 2cT x xT c + cT c) (xT x dT x
L. Vandenberghe
EE133A
5/6/2015
Homework 4 solutions
1. (a) Since Q is orthogonal we have QT Q = QQT = I. Expanding QQT = I gives
QQT =
h
Q1 Q2
ih
Q1 Q2
iT
= Q1 QT1 + Q2 QT2 = I.
Therefore
A = Q1 QT1 Q2 QT2 = Q1 QT1 (I Q1 QT1 ) = 2Q1 QT1 I
and
A = Q1 QT1
L. Vandenberghe
EE133A (Spring 2015)
14. Nonlinear least squares
denition
Newton method
Gauss-Newton method
14-1
Nonlinear least squares
m
ri(x)2 = r(x)
minimize
2
i=1
ri is a nonlinear function of the n-vector of variables x
r(x) = (r1(x), r2(x), .
L. Vandenberghe
EE133A (Spring 2015)
7. Linear equations
QR factorization method
factor and solve
LU factorization
7-1
QR factorization and inverse
QR factorization of nonsingular matrix
every nonsingular A Rnn has a QR factorization
A = QR
Q Rnn is o
L. Vandenberghe
EE133A (Spring 2015)
8. Least squares
least-squares problem
solution of a least-squares problem
solving least-squares problems
8-1
Least-squares problem
given A Rmn and b Rm, nd vector x Rn that minimizes
m
Ax b
2
=
n
Aij xj bi
i=1
2
j=
L. Vandenberghe
EE133A (Spring 2015)
6. QR factorization
triangular matrices
QR factorization
modied Gram-Schmidt algorithm
complex QR factorization
6-1
Triangular matrix
a square matrix A is lower triangular if Aij = 0 for j > i
A11
A21
.
.
.
0
A22
.
L. Vandenberghe
EE133A (Spring 2015)
5. Orthogonal matrices
matrices with orthonormal columns
orthogonal matrices
tall matrices with orthonormal columns
complex matrices with orthonormal columns
5-1
Orthonormal vectors
a set of real m-vectors cfw_a1,
L. Vandenberghe
EE133A (Spring 2015)
4. Matrix inverses
left and right inverse
linear independence
nonsingular matrices
matrices with linearly independent columns
matrices with linearly independent rows
4-1
Left and right inverse
AB = BA in general,
L. Vandenberghe
EE133A (Spring 2015)
3. Matrices
notation and terminology
matrix operations
linear and ane functions
complexity
3-1
Matrix
a rectangular array of numbers, for example
0
1 2.3 0.1
A = 1.3 4 0.1 0
4.1 1
0
1.7
numbers in array are the e
L. Vandenberghe
EE133A (Spring 2015)
2. Norm, distance, angle
norm
distance
angle
hyperplanes
complex vectors
2-1
Euclidean norm
(Euclidean) norm of vector a Rn:
a
a2 + a2 + + a2
n
1
2
=
=
aT a
if n = 1, a reduces to absolute value |a|
measures the
L. Vandenberghe
EE133A
4/8/2015
Homework 1 solutions
1. (a) Take ai = |xi | and bi = 1/n, i = 1, . . . , n, in the Cauchy-Schwarz inequality
aT b kakkbk.
With this choice of a, b,
n
1X
a b=
|xi |,
n i=1
T
1
kbk = ,
n
kak = kxk,
and the Cauchy-Schwarz ineq