function prob53(M)

if nargin < 1
	M = 4;
end

x = [1     0     0    -1     0     0    -2    0; ...
     0     1    -1     0     2    -2     0    0]';
y = [-1   -1     -1     1     1     1     1    1]';

n = size(x, 1);

K = (1 + x * x').^M;
yyK = (y * y') .* K;

lm = quadprog(yyK, -ones(n,1), [], [], y', 0, zeros(1,n), 999*ones(1,n));
lm(find(lm < 1e-8)) = 0;
disp('lambda = ');
disp(lm')

VCs = find(lm > 0);
[dist, t] = vcm(x, x(VCs,:), y(VCs), lm(VCs), M)

figure; hold on;
plotdata(x', y'); grid on;

if M == 2
	vcmbound([1,0], 6, 0, 360, x(VCs,:), y(VCs), lm(VCs), M, t);
	set(text(-1.65, 0.5, '+'), 'fontsize', 40);
	set(text( 0.35, 0.5, '-'), 'fontsize', 40);
	axis([-2.5, 3, -2.5, 2.5]);
elseif M == 3
	vcmbound([3,0], 6, 90, 270, x(VCs,:), y(VCs), lm(VCs), M, t);
	set(text(-1.65, 1, '+'), 'fontsize', 40);
	set(text( 2.05, 1, '-'), 'fontsize', 40);
elseif M == 4
	vcmbound([-1,0], 2, 0, 360, x(VCs,:), y(VCs), lm(VCs), M, t);
	vcmbound([-1,7], 8, 230, 310, x(VCs,:), y(VCs), lm(VCs), M, t);
	vcmbound([-1,-7], 8, 50, 130, x(VCs,:), y(VCs), lm(VCs), M, t);
	set(text(-1.65, 0.0, '+'), 'fontsize', 40);
	set(text(-1.00, 2.5, '+'), 'fontsize', 40);
	set(text(-1.00,-2.5, '+'), 'fontsize', 40);
	set(text( 1.35, 0.5, '-'), 'fontsize', 40);
end

%xt = rand(60000,2) * 12 - 6;
%dist = vcm(xt, x(VCs,:), y(VCs), lm(VCs), M, t);
%p = find(abs(dist) < 0.1); plot(xt(p, 1), xt(p, 2), 'k.');

%axis('square');
grid on;

for n = 1:size(x,1)
	text(x(n,1)+0.1, x(n,2)+0.1, [num2str(n)]);
end;

legend('y = +1', 'y = -1', 'boundary');
xlabel('x1'); ylabel('x2');
