%dlqrmon.m
%  program to compute equilibrium for class exercise (Laffer curve)
gam1=100;
gam2=50;
g=.075;
M0=100;
m1=[1 gam2;1 0];
m2=[0 gam1; 1 g];
[w,d]=eig(m2,m1);
v=inv(w);
a1=w*d*v;
a10=w*(d^10)*v;

p0=-v(2,2)\v(2,1)*M0;
x0=[M0 p0]'
x1=a1*x0
x10=a10*x0

pp0=p0+1;
xx0=x0;xx0(2)=pp0+1;
xx1=a1*xx0;
xx10=a10*xx0;


return



d = diag(d);
i = find(real(d)==NaN);
d(i) = inf*ones(length(i),1);
[d,index] = sort(abs(d));        % sort on magnitude of eigenvalues
%if (~((d(n) < 1) & (d(n+1) > 1)))
%  %error('Can''t order eigenvalues, (A,B) may be uncontrollable.')
%  msg = 0; f=0; p=0;
%  return
%end
% select vectors with eigenvalues inside unit circle
%chi = v(1:n,index(1:n));
%lambda = v((n+1):(2*n),index(1:n));
%p = real(lambda/chi);
%r = R+B'*p*B;
%f = (r*(eye(k)+R\W3'*C3)+B'*p*A3*C3)\(B'*p*(A+A3*c)+r/R*(W'+W3'*c));

