function [lambda x flops i] = RQI(T,n,Gbound,flops)

%Rayleigh Quotient Iteration starting with lambda instad of v
flop=0;

i=0;

%A = T-Gbound*eye(n);  flops = flops+2*n;
%[x flop] = QRsolve(A,zeros(n,1),n,flops);
%x=x/norm(x);  flops = flops+flop+n;
x=rand(n,1);
x=x/norm(x);
lambda = x'*T*x;  flops = flops+6*n;

dt=1;

while dt>0
    
    A = T-lambda*eye(n);  flops = flops+2*n;
    dt=det(A);
    [x flop] = QRsolve(A,x,n,flops); 
    x=x/norm(x);  flops = flops+flop+n;
    i=i+1;
    lambda = x'*T*x;  flops = flops+6*n;
end







    
    
    
   