% Least squares results:

alpha  = 1/3;
beta   = .96;
lambda = 1/(alpha*beta);
kmin   = .01;
kmax   = 2;
k      = [kmin:.01:kmax]';

theta = [ ...
   5.0346e+00
  -3.7712e+00
   9.8184e-01];
n  = length(theta);
f3 = ((k*ones(1,n)).^(ones(length(k),1)*[1:n]))*theta;

theta = [ ...
   6.8266e+00
  -8.9457e+00
   5.3213e+00
  -1.1182e+00];
n  = length(theta);
f4 = ((k*ones(1,n)).^(ones(length(k),1)*[1:n]))*theta;

theta = [ ...
   8.5403e+00
  -1.6693e+01
   1.6610e+01
  -7.7193e+00
   1.3457e+00];
n  = length(theta);
f5 = ((k*ones(1,n)).^(ones(length(k),1)*[1:n]))*theta;

plot(k,(1-alpha*beta)*lambda*k.^alpha,k,f3,'--',k,f4,':',k,f5,'-.')
legend(' Exact',' n = 3',' n = 4',' n = 5')
title('Figure 6. Least squares approximations to deterministic growth model')
xlabel('k')
ylabel('c(k)')
print -deps fig6

kmin   = .1;
kmax   = 2;
k      = [kmin:.01:kmax]';

theta = [ ...
   1.3440e+01
  -2.7568e+01
   2.0516e+01
  -4.8838e+00];
n  = length(theta);
f4 = ((k*ones(1,n)).^(ones(length(k),1)*[1:n]))*theta;

theta = [ ...
   13.3933
  -36.5238
   43.8885
  -23.0637
    4.3732];
n  = length(theta);
f5 = ((k*ones(1,n)).^(ones(length(k),1)*[1:n]))*theta;

figure(2)
plot(k,(1-alpha*beta)*lambda*k.^alpha,k,f4,':',k,f5,'-.')
legend(' Exact',' n = 4',' n = 5')
title('Figure 7. Collocation approximations to deterministic growth model')
xlabel('k')
ylabel('c(k)')
print -deps fig7

kmin   = .01;
kmax   = 2;
k      = [kmin:.01:kmax]';

theta = [ ...
   5.5692e+00
  -4.6172e+00
   1.2836e+00];
n  = length(theta);
f3 = ((k*ones(1,n)).^(ones(length(k),1)*[1:n]))*theta;

theta = [ ...
   7.5175e+00
  -1.0907e+01
   6.9335e+00
  -1.5263e+00];

n  = length(theta);
f4 = ((k*ones(1,n)).^(ones(length(k),1)*[1:n]))*theta;

theta = [ ...
   9.4435e+00
  -2.0562e+01
   2.2009e+01
  -1.0776e+01
   1.9537e+00];

n  = length(theta);
f5 = ((k*ones(1,n)).^(ones(length(k),1)*[1:n]))*theta;

figure(3)
plot(k,(1-alpha*beta)*lambda*k.^alpha,k,f3,'--',k,f4,':',k,f5,'-.')
legend(' Exact',' n = 3',' n = 4',' n = 5')
title('Figure 8. Galerkin approximations to deterministic growth model')
xlabel('k')
ylabel('c(k)')
print -deps fig8
