function [base,alpha,lambdamin2]=base_eig(A,lambdamin1,vh)
% This function computes an orthonormal basis (base) for minimum eigenvalue of A (lambdamin1)
%========================================================================
n=length(A);
alpha=[];base=[];
flag_shd=1;
nA = normest(A,1);
nAn=nA/sqrt(n);
base=[base,vh];
alpha=[alpha;nAn];
while flag_shd
    opts.issym=1;
    opts.isreal=1;
    opts.v0=randn(n,1);
    [v,d]=eigs(@Asecfun,n,1,'sa',opts);
    v=v/norm(v);
    if d>1e-8
        lambdamin2=d+lambdamin1;
        break;
    else
        alpha=[alpha;nAn];
        base=[base,v];
        
    end
end

    function [v] = Asecfun(u)
        
        if flag_shd==1
            v=A*u-lambdamin1*u+(base*(alpha.*(base'*u)));
        end
    end
end
