# Question:How to optimize code for counting experimental invariant density?

## Question:How to optimize code for counting experimental invariant density?

Maple

Hi! I have recently started some Maple in chaos in dynamical systems and I am thinking about counting experimental invariant denisty measure (which is in brief  "how often the point visits the given interval") for some discrete mappings (in this case it's logistic mapping 3.7*x*(1-x)).

restart;
with(plots);
x := array(1 .. 10^6 + 2);

x[1] := 0.2;
for i to 10^6 do
x[i + 1] := 3.7*x[i]*(1 - x[i]);
end do;

counter := 0;
for i to 10^6 do
if 0 <= x[i] and x[i] < 0.1 then counter := counter + 1; end if;
end do;
counter;
counter := 0;
for i to 0^6 do
if 0.2 <= x[i] and x[i] < 0.3 then counter := counter + 1; end if;
end do;
counter;
..........

counter := 0;
for i to 10^6 do
if 0.9 <= x[i] and x[i] < 1 then counter := counter + 1; end if;
end do;
counter;
display(plot([[0, 0], [0.3, 0]]), plot([[0.3, 74089], [0.4, 74089]]), plot([[0.4, 57290], [0.5, 57290]]), plot([[0.5, 86726], [0.6, 86726]]), plot([[0.6, 122087], [0.7, 122087]]), plot([[0.7, 269178], [0.8, 269178]]), plot([[0.8, 185490], [0.9, 185490]]), plot([[0.9, 115405], [1, 115405]]))

I don't know how can I automate this code. I need smaller intervals because I took length 0.1 which is not good enough.

I want to get something like this (it is for logistic map such as above but in below example they plotted this graph for 4*x*(1-x) )