%%
% Parameters
tic
betta=0.98;
f_p=3.5;  %%1.0203; % Reaction to inflation fp> 1/beta & gama>(1/beta-1)
gama=0.5;
el_time=toc
%%
tic
No_controls=1;
No_states=1;

A=[f_p*betta 0 0; -(1/betta) (1/betta - gama) f_p; 0 0 1];


[V D]=eig(A);
roots=diag(D);

J=D;
P=V;
el_time=toc
%%
%Check Jordan decomposition
tic
Check_J=norm(A - P*J*P^(-1));

%In case you have symbolic toolbox

        % Apply the Jordan Decomposition and check it
        [P, J] = jordan(A); 
        
        check = A - P * J * inv(P); 
        if norm(check) > 1e-6
            warning('Jordan decomposition accuracy issue');
        end

        roots = diag(J); 
  toc      
        %%
if max(Check_J)<10^(-10)
    display('Jordan decomposition checked')

else
    display('Jordan decomposition accuracy failed')
end

No_unstable_roots=size(roots(roots>1),1);
No_stable_roots=size(roots(roots<1),1);

f_p_stable=[];
gama_stable=[];
it_stable=1;

if No_controls==No_unstable_roots
    display('BK conditions are satisfied')
    
    f_p_stable(it_stable)=f_p;
    gama_stable(it_stable)=gama;
    
    it_stable=it_stable+1;
end

if No_controls>No_unstable_roots   
    display('No stable solution')
end

if No_controls<No_unstable_roots   
    display('Infinite solutions')
end


