%rbc3rr.m Sept. 19, 1996
%Calculates solution to basic rbc model with parameters as 
% in Farmer's book
%Iterations of T map to REE law of motion. t dating of expectations
m=0.35;nu=0.65;discount=0.99;delta=0.025;phi=1;mu=m;
rho=0.95;
ytok=(phi/discount+delta-1)/m;
ctok=ytok-delta+1-phi;
bet11=1+m*nu*ytok*discount/((1-nu)*phi);
bet12=(discount/phi)*m*ytok*(1-mu/(1-nu));
bet13=-(discount/phi)*m*ytok/(1-nu);
d11=-(ctok+ytok*nu/(1-nu))/phi;
d12=(1-delta+ytok*mu/(1-nu))/phi;
d13=(ytok/(1-nu))/phi;
f=eye(3);
f(2,1)=d11; f(2,2)=d12; f(2,3)=d13;
g=zeros(3);
g(1,1)=bet11;g(1,2)=bet12;g(1,3)=bet13;g(2,2)=1;
g(3,3)=1/rho;
j=inv(f)*g;
[q d]=eig(j)
p=inv(q);
%c=pieck*k+piecs*s
pieck=-p(1,2)/p(1,1);
piecs=-p(1,3)/p(1,1);

mdel=zeros(3);
mdel(2,1)=d11;mdel(2,2)=d12;mdel(2,3)=d13;
mdel(3,3)=rho;
mbet=zeros(3);mbet(1,1)=bet11;mbet(1,2)=bet12;mbet(1,3)=bet13;
bre=zeros(3);
bre(1,1)=pieck*d11;bre(1,2)=pieck*d12;
bre(1,3)=pieck*d13+rho*piecs;
bre(2,1)=d11;bre(2,2)=d12;bre(2,3)=d13;bre(3,3)=rho;
tbre=(inv(eye(3)-mbet*bre))*mdel;
bre
tbre

inib=bre+.05*rand(3,3)
%inib=rand(3,3)
oldb=inib;
for i=1:100
	b=(inv(eye(3)-mbet*oldb))*mdel
	oldb=b
end;
	
	


