clear all, clc
randn('state',0);
F = randn(200,2);
[U,S,V]=svd(F);
svd(F), 
S(2,2)=input('smallest singular value of F   ');
F = U*S*V';
Y = F*[1;1];
for i=1:100,
    Ym = Y + 10^(-9)*randn(200,1);
    R = triu(qr([F Ym]));
    Xqr(:,i) = inv(R(1:2,1:2))*R(1:2,3);
    Xneq(:,i) = inv(F'*F)*F'*Ym;
end
plot(Xqr(1,:),Xqr(2,:),'or')
hold
axis([.5,1.5,.5,1.5])
plot(Xneq(1,:),Xneq(2,:),'xb')
plot([0.9,1.1],[1 1],'g')
plot([1,1],[.9,1.1],'g')
legend('Red is QR','Blue is Normal Equations')
figure(1)
hold