Dimension Demonstration
Compute the dimension of the attractor of the Hénon map
Compute the Hénon attractor with the standard values
x(:,k+1)=henon(x(:,k),a,b);
plot(x,y,'.','markersize',4)
Box-counting step
[epsilon(k),Nboxes(k)]=countAndPlotBoxes(x,y,K);
Processing the box-counting step
p=polyfit(log(epsilon),log(Nboxes),1);
loglog(epsilon,Nboxes,'o',epsilon,exp(polyval(p,log(epsilon))));
set(gca,'xscale','log','yscale','log')
legend('data','least squares line');
fprintf('The calculated dimension is %0.2f.\n',abs(p(1)))
The calculated dimension is 1.27.
Definition of the Hénon map
The Hénon map, most commonly studied with a=1.4, b=.3
Function to count boxes for fixed
function [dx,Nboxes]=countAndPlotBoxes(x,y,K)
Scale and reposition the point set so that it fits in the box [0,1]x[0,1]
xmax=max(x); xmin=min(x); width=xmax-xmin;
ymax=max(y); ymin=min(y); height=ymax-ymin;
Define the grid size
Define a square box with unit-length sides
Plot the point set
plot(x,y,'.','markersize',4)
The main step:
Loop through all the sub-boxes of length and width dx. Set isFilled(row,col) to 1 if there is a point in the box, and to zero if not. If it is filled, plot a pink square.
Note that this makes use of two built-in MATLAB commands
- inpolygon tests whether each point (x(row,col),y(row,col)) is in the box defined by xv and yv. This is vectorized and avoids the need for loops. (Not something you'd use very often.)
- any returns 1 if any elements of a matrix are nonzero and returns 0 otherwise. The all command is similar. These are very useful utilities.
isFilled(row,col)=any(inpolygon(x,y,xv,yv));
patch(xv,yv,zeros(1,5),'facecolor',[1 .7 .7],'edgecolor','k','facealpha',0.7)
Nboxes=sum(isFilled(:)); %count the number of filled boxes
title(sprintf('$\\epsilon=%0.3f, N_{\\rm boxes}=%i$',dx,Nboxes))