A = [3 6 -1; -6 -6 1; 2 1 -1]
I = [1 0 0; 0 1 0; 0 0 1]
a = [A(1,1); A(2,1); A(3,1)]
u = a
u(1) = a(1) + sqrt(a(1)^2+a(2)^2+a(3)^2)
w = u'*A
b = u*w
lenU = sqrt(u(1)^2+u(2)^2+u(3)^2)
m = (2/lenU^2).*b
H1 = I - (u*u') * 2/lenU^2
A1 = H1 * A
A = A - m

a = [A(1,2); A(2,2); A(3,2)]
u = a
u(1) = 0
u(2) = a(2) + sqrt(a(2)^2+a(3)^2)
w = u'*A
b = u*w
lenU = sqrt(u(1)^2+u(2)^2+u(3)^2)
H2 = I - 2/lenU^2*(u*u')
A1 = H2 * A1
A = A - (2/lenU^2).*b

Q = H1 * H2

B = Q * A