% eig1.m
% eigenvalues and vectors
clear

% A random matrix
sprintf('A random matrix')
A=randn(2,2);
[V,D] = eig(A); D, V
pause

% symmetric implies real-valued eigenvalues
sprintf('A symmetric matrix')
B=A+A';
[V,D] = eig(B); D, V
pause

% 'square' implies non-negative definite
sprintf('A non-negative definite matrix')
C=A*A';
[V,D] = eig(C); D, V
pause

% eigenvalues to A*A
sprintf('Error in eigenvalues of squared matrix minus squared eigenvalues')
norm(sort(eig(A).*eig(A))-sort(eig(A*A)),'fro') % sort seems to work here
pause

% A pathological matrix
sprintf('A matrix that does not have a full set of eigenvectors')                
[V,D]=eig([3 1;0 3]); D, V
