% P3

clc
randn('seed',0)
n = 201;
disp('nPos0 = "exact" number of eigs in open right half plane.')
disp('nPos = number of eigs in open right half plane via OrthoEig.')
disp(' ')
disp(' k nPos0 nPos')
disp('---------------------------------')
for k=1:20
[Q,R] = qr(k*eye(n,n) + randn(n,n));
d = eig(Q);
nPos0 = sum(real(d)>0);
nPos = OrthoEig(Q);
fprintf('%2d %4d %4d\n',k,nPos0,nPos)
end