function curseofdim
%
%  Fig. 8.1 Bellman's Curse of dimensionality illustrated (3,2007):
%
clc
%
nxmax = 10;
nx = 1:nxmax; % dimensions
Nx = 32; % nodes per dimension
NDV = nx.*Nx.^nx; % Order of typical size array (diagonal case);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
scrsize = get(0,'ScreenSize');
ss = [3.0,2.8,2.6,2.4,2.2,2.0];
nfig = 1;
figure(nfig);
%
plot(nx,NDV,'k-'...
    ,'linewidth',5);
axis tight
title('Curse of Dimensionality: n_x exp(n_x ln(N_x)) for N_x=32'...
        ,'Fontsize',44,'FontWeight','Bold');
xlabel('n_x, State Dimensions'...
        ,'Fontsize',44,'FontWeight','Bold');
ylabel('NDV, Problem Size'...
        ,'Fontsize',44,'FontWeight','Bold');
set(gca,'Fontsize',36,'FontWeight','Bold','linewidth',3);
set(gcf,'Color','White','Position'...
    ,[scrsize(3)/ss(nfig) 70 scrsize(3)*0.60 scrsize(4)*0.80]);
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Nxmax = 64;
Nx3 = 1:Nxmax; % nodes per dimension
ln2Nx3 = log2(Nx3); %log_2(Nodes)
BPGB8 = 8/1024^4;
NDV3 = zeros(nxmax,Nxmax);
for i=1:nxmax
    for j=1:Nxmax
        %Order of typical size array (diagonal case):
        NDV3(i,j) = nx(i)*Nx3(j)^nx(i)*BPGB8;
    end
end
%
nfig = nfig+1;
figure(nfig);
% Caution: mesh takes reverse arguments for y & x in z:
mesh(ln2Nx3,nx,NDV3,'linewidth',2) 
colormap(gray);
axis tight
title('Curse of Dimensionality: N_{DV} = 8n_x exp(n_x ln(N_x)) in GB'...
        ,'Fontsize',28,'FontWeight','Bold');
ylabel('  n_x, State Dimensions'...
        ,'Fontsize',28,'FontWeight','Bold');
xlabel('log_2(N_x), log_2(Nodes)'...
        ,'Fontsize',28,'FontWeight','Bold');
zlabel('N_{DV}, Problem Size Order (GB)'...
        ,'Fontsize',28,'FontWeight','Bold');
set(gca,'Fontsize',28,'FontWeight','Bold','linewidth',3);
set(gcf,'Color','White','Position'...
    ,[scrsize(3)/ss(nfig) 70 scrsize(3)*0.60 scrsize(4)*0.80]);
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
log2NDV3 = zeros(nxmax,Nxmax);
for i=1:nxmax
    for j=1:Nxmax
        %Order of typical size array (diagonal case):
        log2NDV3(i,j) = log2(8*nx(i)*Nx3(j)^nx(i));
    end
end
%
nfig = nfig+1;
figure(nfig);
% Caution: mesh takes reverse arguments for y & x in z:
mesh(ln2Nx3,nx,log2NDV3,'linewidth',2) 
colormap(gray);
axis tight
title('Curse of Dimensionality: N_{DV} = log_2(8*n_x exp(n_x ln(N_x)))'...
        ,'Fontsize',28,'FontWeight','Bold');
ylabel('  n_x, State Dimensions'...
        ,'Fontsize',28,'FontWeight','Bold');
xlabel('log_2(N_x), log_2(Nodes)'...
        ,'Fontsize',28,'FontWeight','Bold');
zlabel('log_2(N_{DV}), Log2(ProblemSize)'...
        ,'Fontsize',28,'FontWeight','Bold');
set(gca,'Fontsize',28,'FontWeight','Bold','linewidth',3);
set(gcf,'Color','White','Position'...
    ,[scrsize(3)/ss(nfig) 70 scrsize(3)*0.60 scrsize(4)*0.80]);
% End curseofdim
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%