function diff=marchk2(delta);
beta=.95;
alpha=.33;
rho=.95;
tau=1;
sige=.1;
mu=1;
T=2500;

rand('normal');
epsilon=rand(T+1,1)*sqrt(sige);
omega(1,1)=0;
for i=2:T+1; 
  omega(i,1)=rho*omega(i-1)+epsilon(i); 
end;
theta=exp(omega);
tol=1e-5;

taui=1/tau;
k(1,1)=(alpha*beta/(1-beta*mu))^(1/(1-alpha));
c=zeros(T+1,1);

for i=2:T+1;   
  phi=delta(1)*k(i-1)^delta(2)*theta(i)^delta(3);
  k(i,1)=theta(i)*k(i-1)^alpha+mu*k(i-1)-(beta*phi)^(-taui);
end;
c(2:T+1,1)=(beta*delta(1)*k(1:T).^delta(2).*theta(2:T+1).^delta(3)).^ ..
              (-taui);
phi=delta(1)*k(1:T-1).^delta(2).*theta(2:T).^delta(3);
v=c(3:T+1).^(-tau).*(alpha*theta(3:T+1).*k(2:T).^(alpha-1)+mu)-phi;
diff=sum(v.^2)/T;

