A = [-1 -5 4; -1 -5 -2; 1 7 0; 1 7 6];
[Q,R] = QRfactor(A)

A = [1 1 1; 10^-8 0 0; 0 10^-8 0; 0 0 10^-8];
[Q,R] = QRfactor(A);
Q'*Q

[Q,R] = modifiedQR(A);
Q'*Q

A = [-1 -5 4; -1 -5 -2; 1 7 0; 1 7 6];
[Q,R] = QRfactor(A);
Atilde = inv(R)*Q'

Atilde*A

P = Q*Q'

x = [2 1 2]'; e1 = [1 0 0]';
w1 = x+sign(x(1))*norm(x)*e1

H1 = eye(3)-2*(w1*w1')/(w1'*w1)

y = H1*x

x = [2 1 2]'; e2 = [0 1 0]'; xtilde = [0 1 2]';
w2 = xtilde+sign(x(2))*norm(xtilde)*e2

H2 = eye(3)-2*(w2*w2')/(w2'*w2)

y = H2*x

A = [-1 -5 4; -1 -5 -2; 1 7 0; 1 7 6];
[Q,R] = householderQR(A)

[Q,R] = qr(A)
