Box Counting Henon

Box Counting Henon (by  MSc  K. Catrioplas)

Clear["Global`*"]

b=0.3;
a=1.4;
g1[x_,y_]:=1+y-a x^2
g2[x_,y_]:=b x
Print["x1=",g1[x0,y0],"   y1=",g2[x0,y0]]

Check Conservation

M[x_,y_]={{D[g1[x,y],x], D[g1[x,y],y]},{D[g2[x,y],x],D[g2[x,y],y]}};
MatrixForm[M[x,y]]
Det[M[x,y]]

Run trajectory

x0=0; y0=0;
trajectory={{x0,y0}}
n=10000;
For[i=1,i<n,i++, x1=g1[x0,y0]; y1=g2[x0,y0]; AppendTo[trajectory,{x1,y1}]; x0=x1;y0=y1;]
plot=ListPlot[trajectory,PlotRange->All]

(*zoom in*)
ListPlot[trajectory,PlotRange->{{0,0.4
},{0.2,0.28}}]

Plot zoomed

boxsize=0.05;(*for plot reasons only!*)

xall=Table[trajectory[[i,1]],{i,1,Length[trajectory]}];
xmax=Max[xall];
xmin=Min[xall];
yall=Table[trajectory[[i,2]],{i,1,Length[trajectory]}];
ymax=Max[yall];
ymin=Min[yall];
xminzoomed=Floor[xmin/boxsize];
xmaxzoomed=Ceiling[xmax/boxsize];
yminzoomed=Floor[ymin/boxsize];
ymaxzoomed=Ceiling[ymax/boxsize];
Xgrid=Table[i,{i,xminzoomed,xmaxzoomed}];
Ygrid=Table[i,{i,yminzoomed,ymaxzoomed}];

ListPlot[trajectory/boxsize,
PlotRange->{{xminzoomed,xmaxzoomed},{8,-8}},
GridLines->{Xgrid,Xgrid},
GridLinesStyle->Directive[Orange,Dashed]]

Counting

data={};   
For[i=4,i≤2^9,i=2*i,boxsize=1/i; (*several box sizes*)l=Length[Complement[Ceiling[trajectory/boxsize]]];
AppendTo[data,{i,l}];
]
data

Fitting

turnlog[{x_,y_}]:=N[{Log[x],Log[y]}]
logdata=Map[turnlog,data];
f[x_]=Fit[logdata,{1,x},x]

points=ListPlot[logdata,PlotRange->All];
fitting=Plot[f[x],{x,logdata[[1,1]],logdata[[Length[logdata],1]]}];
Show[points,fitting,PlotRange->All]