A0 = [3 6 -1; -6 -6 1; 2 1 -1]
r = sqrt(A0(1,1)^2 + A0(2,1)^2)
c = A0(1,1)/r
s = A0(2,1)/r
O12 = [c s 0; -s c 0; 0 0 1]
A1 = O12*A0
r = sqrt(A1(1,1)^2 + A1(3,1)^2)
c = A1(1,1)/r
s = A1(3,1)/r
O13 = [c 0 s; 0 1 0; -s 0 c]
A2 = O13 * A1
r = sqrt(A2(2,2)^2 + A2(3,2)^2)
c = A2(2,2)/r
s = A2(3,2)/r
O23 = [1 0 0; 0 c s; 0 -s c]
A3 = O23 * A2

R = A3
Q = (O23*O13*O12)'
Q2= O12'*O13'*O23'
AN = Q*R
A0 - AN
Q*Q'