%DGROW   generates a plot of the actual and approximate solution to
%
%                 max  sum beta^t log(c[t])   
%                 c[t] 
%                      s.t. c[t] + k[t+1] = lambda k[t]^alpha
%
%        on [0,kmax].  The approximate solution is c^h(k) where
%
%             c^h(k) = theta(1) k + theta(2) k^2 + ... theta(n) x^n.
%
%        One of three possible methods are used (Least squares, Galerkin,
%        or Collocation) and the user is queried about which to use, 
%        what kmin and kmax to use and the degree of the approximation.
%

%        Ellen McGrattan, 8-30-96


alpha  = .25;
beta   = .96;
lambda = 1/(beta*alpha);
m      = 20;  %# of quadrature points

clc
home
disp('    THE APPROXIMATION OF c(k) FOR THE DETERMINISTIC GROWTH MODEL')

disp('    ------------------------------------------------------------')
disp(' ')
meth= input(['Method? (1=Least sqs., 2=Galerkin, 3=Collocation) ']);
kmin= input('Minimum k value? ');
kmax= input('Maximum k value? ');
n   = input('Degree of approximation? ');
param = [alpha;beta;lambda;m];
disp(' ')

if meth == 1;
  theta = dgrowl(kmin,kmax,n,param);
elseif meth==2;
  theta = dgrowg(kmin,kmax,n,param);
else
  theta = dgrowc(kmin,kmax,n,param);
end;
k = [kmin:.01:kmax]';
plot(k,(1-alpha*beta)*lambda*k.^alpha,k, ...
     ( (k*ones(1,n)).^(ones(length(k),1)*[1:n]))*theta)

