% eig2.m

% Symmetric matrices, eigenvectors and ON-bases.
clear

% Generate a random, square matrix
N=100;
A=randn(N,N);

% Make it symmetric
A=A+A';

[V,D]=eig(A);

sprintf('The eigenvectors are orthonormal')
norm(V*V'-eye(N),'fro')
pause

sprintf('The inverse of the eigenvector matrix equals the transpose')
norm(V'-inv(V),'fro')
pause

sprintf('The matrix is diagonalized by the eigenvector matrix')
norm(D-V'*A*V,'fro')
pause

sprintf('The eigenvalues are real-valued')
norm(real(D)-D,'fro')