% P2
% Checks out FindNegVec

randn('seed',0)
clc
n = 10;
D = diag([8 2 3 -1 5 6 10 4 3 6]);
% Example 1
[Q,R] = qr(randn(n,n)); A = Q*D*Q';
x = FindNegVec(A);
fprintf('Example 1. x''Ax = %20.15f, norm(x,2) = %5.2f\n',x'*A*x,norm(x))
x = x

% Example 2
[Q,R] = qr(randn(n,n)); A = Q*D*Q';
x = FindNegVec(A);
fprintf('Example 2. x''Ax = %20.15f, norm(x,2) = %5.2f\n',x'*A*x,norm(x))
x = x