2 added 525 characters in body
source | link

If you want to translate Matlab code into Mathematica, my advice is - don't! As programming languages, the two are very different and an idiom that works well in one is unlikely to work well in the other.

As far as this specific problem goesA fundamental theorem theorem in discrete dynamics states that if there's an attractive orbit, there is exactlythen it must attract at least one critical point. Thus, if your objective is to find an attractive orbit and the period of that orbit is 8. There are other orbits (of periods 1, 2the logistic map, and 4) but a randomly chosen initial seed will almost certainly convergethen it makes sense to start at the lone attractive orbitcritical point of $0.5$, rather than a random point. Thus

There's really no need for super high precision. The parameter $a=3.569945$ agrees with the problem is rather set up to make it impossibleaccumulation point to miss the attractivemillionths place and the following code finds an orbit of period 512 after about 37000 iterates. I might illustrate this in Mathematica like so:

af[x_] = 3.569945 x (1 +- Sqrt[6]x);
i += 1/10;0;
f[x_]orbit = a*x*Monitor[
  NestWhileList[(i++; f[#]) &, 0.5, Unequal, {1, -1025}, x);50000],
SeedRandom[1];i];
Partition[NestList[f

Here's the period.

{period} = DeleteDuplicates[
  Flatten[Differences[Position[Chop[orbit - Last[orbit]], Random[]0]]]]

(* Out: {512} *)

Let's check it.

Nest[f, 300]Last[orbit], 8][[period] -5 ;;]]Last[orbit]

(* //-5.60663*10^-14 Column*)

enter image description here We expect this to work, since we're searching for stability. Thus, again, high precision is unnecessary. Of course, for parameters slightly larger than the accumulation point, we expect no attractive orbits.

If you want to translate Matlab code into Mathematica, my advice is - don't! As programming languages, the two are very different and an idiom that works well in one is unlikely to work well in the other.

As far as this specific problem goes, there is exactly one attractive orbit and the period of that orbit is 8. There are other orbits (of periods 1, 2, and 4) but a randomly chosen initial seed will almost certainly converge to the lone attractive orbit. Thus the problem is rather set up to make it impossible to miss the attractive orbit. I might illustrate this in Mathematica like so:

a = 1 + Sqrt[6] + 1/10;
f[x_] = a*x*(1 - x);
SeedRandom[1];
Partition[NestList[f, Random[], 300], 8][[-5 ;;]] // Column

enter image description here

If you want to translate Matlab code into Mathematica, my advice is - don't! As programming languages, the two are very different and an idiom that works well in one is unlikely to work well in the other.

A fundamental theorem theorem in discrete dynamics states that if there's an attractive orbit, then it must attract at least one critical point. Thus, if your objective is to find an attractive orbit of the logistic map, then it makes sense to start at the lone critical point of $0.5$, rather than a random point.

There's really no need for super high precision. The parameter $a=3.569945$ agrees with the accumulation point to the millionths place and the following code finds an orbit of period 512 after about 37000 iterates.

f[x_] = 3.569945 x (1 - x);
i = 0;
orbit = Monitor[
  NestWhileList[(i++; f[#]) &, 0.5, Unequal, {1, 1025}, 50000],
i];

Here's the period.

{period} = DeleteDuplicates[
  Flatten[Differences[Position[Chop[orbit - Last[orbit]], 0]]]]

(* Out: {512} *)

Let's check it.

Nest[f, Last[orbit], period] - Last[orbit]

(* -5.60663*10^-14 *)

We expect this to work, since we're searching for stability. Thus, again, high precision is unnecessary. Of course, for parameters slightly larger than the accumulation point, we expect no attractive orbits.

1
source | link

If you want to translate Matlab code into Mathematica, my advice is - don't! As programming languages, the two are very different and an idiom that works well in one is unlikely to work well in the other.

As far as this specific problem goes, there is exactly one attractive orbit and the period of that orbit is 8. There are other orbits (of periods 1, 2, and 4) but a randomly chosen initial seed will almost certainly converge to the lone attractive orbit. Thus the problem is rather set up to make it impossible to miss the attractive orbit. I might illustrate this in Mathematica like so:

a = 1 + Sqrt[6] + 1/10;
f[x_] = a*x*(1 - x);
SeedRandom[1];
Partition[NestList[f, Random[], 300], 8][[-5 ;;]] // Column

enter image description here