function prob_3_3 close all; Y = [ 0 1 1; 1 0 -1; 1 1 1; 2 0 -1]; w0 = [ 1 1 1 ]; nIters = 50; w(1,:) = w0; for i=2:nIters, tmp1 = Y*(w(i-1,:)')-ones(4,1); f = mean( tmp1.^2 ); gf(1) = 0.5*( tmp1' * Y(:,1) ); gf(2) = 0.5*( tmp1' * Y(:,2) ); gf(3) = 0.5*( tmp1' * Y(:,3) ); gfNorm = norm( gf ); w(i,:) = w(i-1,:) - (1/gfNorm)*gf; end w figure; imagesc( w ); colorbar;