Académique Documents
Professionnel Documents
Culture Documents
Vandenberghe
EE133A
10/15/2014
Homework 1 solutions
1. (a) Not linear or affine. Choose
"
x=
1
0
"
y=
0
1
1
== .
2
We have
f (x) = f (y) = 1,
and
"
x + y =
1/2
1/2
f (x) + f (y) = 1,
#
f (x + y) = 0.
(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 + kck2 kdk2 .
a = 2(d c),
The function is linear if kck = kdk.
(d) Not linear or affine. Choose
x= 1
,
4
y= 1
,
0
1
== .
2
We have
f (x) = f (y) = 1,
1
f (x) + f (y) = 1,
and
x + y = 1 ,
2
f (x + y) = 2.
=
=
=
=
30
60
70
65.
Subtracting the first equation from the second gives 90a1 = 30. Hence, a1 = 1/3. Subtracting the first equation from the third gives 90a2 = 40, Hence a2 = 4/9. Subtracting
the first equation from the fourth gives 90a3 = 35, Hence a3 = 35/90. Plugging in these
values in any of the four equations and solving for b gives b = 55/3.
If all processors operate at the same power P1 = P2 = P3 = Q, then T 85 if
55
7
85,
(a1 + a2 + a3 )Q + b = Q +
6
3
i.e., Q 57.1.
3. (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 we have
aT b =
n
1X
|xi |,
n i=1
kak = kxk,
1
kbk = ,
n
The upper bound in the Cauchy-Schwarz inequality holds with equality if and
only if a and b are aligned. Applying this to b = (1/n, 1/n, . . . , 1/n), we can
conclude that
n
1X
1
|xi | = kxk
n i=1
n
if the absolute values of the elements of x are all equal. Therefore x must be of
the form x = (, , . . . , ) for some 0.
2
xk
k=1
and
n
n
X
!1/2
xk
k=1
n
X
1
k=1 xk
n
X
1
k=1 xk
!1/2
1/ xk .
xk and bk =
4. The MATLAB code is as follows. Note that there are many other correct ways to get
the same result in MATLAB.
load mnist;
I = find(labels < 5);
digits = digits(:, I);
[n, M] = size(digits);
K = 5;
% cluster centers are stored as columns of Z
Z = rand(n, K);
D = zeros(K, M);
Jprev = NaN;
for iter = 1:100
% assign vectors to clusters
% D is a K x M matrix with D(k,j) the distance of point j to center k
for k = 1:K
D(k,:) = sqrt( sum( (digits - Z(:, k*ones(1,M))).^2) );
end;
% d and class are 1 x M arrays
% d(k) is the minimum value in column k of D
% class(k) is the row index of the minimum
[d, class] = min(D);
% the cost J is the average of the sum of squared elements of d
if iter > 1
if J == Jprev, break; end;
Jprev = J;
end;
J = (1/M) * norm(d)^2;
3