%
% Exercise 3 from Sec 7.1
%
A = [3 -2 4; -2 6 2; 4 2 3]
eig(A)
% Eigenspace for the eigenvalue of -2 and of 7
rref([(A + 2 * eye(3)) zeros(3,1)])
v1 = [-1 -0.5 1]'
rref([(A - 7 * eye(3)) zeros(3,1)])
v2 = [-0.5 1 0]'
v3 = [1 0 1]'
% v1 is orthogonal to v2 and v3, but it must be normalized
u1 = v1/norm(v1)
% Obtain an orthonormal set u2, u3 from v2, v3 by Gram-Schmidt
u2 = v2/norm(v2)
u3 = (v3 - (v3'*u2)*u2)/norm(v3 - (v3'*u2)*u2)
U = [u1 u2 u3]
U' * U
D = diag([-2 7 7])
U * D * U'
