% P3
% Checks out GoodPair

  randn('seed',0)
% generate a random, ill-conditioned, upper triangular T...
  n = 20;
  [U0,S0,V0] = svd(randn(n,n));
  [Q,T]  = qr(U0*(eye(n,n) - triu(ones(n,n),1))*V0);

% Generate a good pair and see how well they approximate
% the small singular triple...

  [y,d] = GoodPair(T);
  sigma  = 1/norm(y);
  u = d;
  v = y*sigma;
  
  [U,S,V] = svd(T);
  u_cos = abs(u'*U(:,n));
  v_cos = abs(v'*V(:,n));
  
  clc
  fprintf('True sigmaMin      = %20.15e\n',S(n,n))
  fprintf('Estimated sigmaMin = %20.15e\n',sigma)
  fprintf('cosine of angle between u and U(:,n) = %8.6f\n',u_cos)
  fprintf('cosine of angle between v and V(:,n) = %8.6f\n',v_cos)
  
 