function [B,gamma] = counterexample_hager(n) % % This function generates nxn matrices % on which Hager's condition estimator % can utterly fail. % % Written by Ming Gu for Math 221, Fall 2007 % % Warning: This code only works properly for % n > 2. % % % hager's condition number estimator will not % be able to detect the magnitude of B(2:n,2:n). % Hence one can make the estimator look very bad % by choosing very large values of scl. % e = ones(n-1,1); e = e/norm(e); E = eye(n-1) - e*e'; Bhat= E*randn(n-1,n-1)*E; scl = 1e10; b = rand(n-1,1); B = [rand,b';b,scl*Bhat]; kl = 10; gamma = hager(B,kl); return