<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Post, logistic map example</title>
    <link>http://www.mapleprimes.com/posts/128749-Logistic-Map-Example</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Wed, 10 Jun 2026 07:49:20 GMT</lastBuildDate>
    <pubDate>Wed, 10 Jun 2026 07:49:20 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Post, logistic map example</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Post, logistic map example</title>
      <link>http://www.mapleprimes.com/posts/128749-Logistic-Map-Example</link>
    </image>
    <item>
      <title>branched</title>
      <link>http://www.mapleprimes.com/posts/128749-Logistic-Map-Example?ref=Feed:MaplePrimes:logistic map example:Comments#comment128762</link>
      <itunes:summary>I have branched this off as a separate Post. It was originally an Answer to a &lt;a href="http://www.mapleprimes.com/questions/128361-Need-Help-In-Using-Maple"&gt;Question&lt;/a&gt; whose author had also asked a &lt;a href="http://www.mapleprimes.com/questions/128437-Bifurcation-Diagram-Help"&gt;duplicate&lt;/a&gt;. The source is a modification of from this earlier &lt;a href="http://www.mapleprimes.com/questions/36580-Bifurcation-Diagram"&gt;post&lt;/a&gt;. Another related &lt;a href="http://www.mapleprimes.com/questions/96451-How-Do-I-Write-Efficient-Codes-Using"&gt;Question&lt;/a&gt; did not yet have a satisfying answer (in the efficiency sense, which was mentioned by the submitter).
&lt;p&gt;Patrick T. has started us off. I think that computing directly into a float[8] Array, and then writing that out directly using ImageTools, should be a way to get sharply detailed results quickly. The crucial parts might be Compiled, or possibly Threaded with evalhf, and act inplace on a given Array. But until someone codes that up, here is a modification of Patrick's tweak.&lt;/p&gt;
&lt;p&gt;This runs in Maple 15. It also ran in Maple 12, but without the Threads:-Sleep call, whose purpose is only to incur a delay while the plot file driver writes out the first, large image file. In Maple 12, one would have to manually run it, and wait a little. On a fast i7 in Windows 7, 10 seconds seems long enough for the 4096x4096 jpeg.&lt;/p&gt;
&lt;pre&gt;
Bifurcation := proc(initialpoint,xexpr,ra,rb,acc)
  local p1,hr,A,L1,i,j,phi:
  global r,L2:
  hr := unapply(xexpr,x);
  A := Vector(600):
  L1 := Vector(acc*500):
  for j from 1 to acc+1 do
    r := (ra + (j-1)*(rb-ra)/acc):
    A[1] := hr(initialpoint):
    for i from 2 to 500 do
      A[i] := evalf(hr(A[i-1])):
    end do:
    for i from 1 to 400 do
      L1[i+400*(j-1)] := [r,A[i+100]]:
    end do:
  end do:
  L2 := {seq(L1[i], i = 1..acc*400)}:
  p1 := plots:-pointplot(L2, 'symbol' = solidcircle, 'symbolsize' = 2, 'color' = blue):
  unassign('r'):
  return(p1):
end proc:

P1 := Bifurcation(1/2,r*x*(1-x),2.5,4,250):

P:=plots:-display(P1, 'axes' = box, 'labels' = [r, x] ):

# A very large image is needed, to get symbolsize=2 to be seen.
plotsetup(jpeg,plotoptions="height=4096,width=4096",
          plotoutput=cat(kernelopts(homedir),"/bifu4096.jpg")):

plots:-display(P);

Threads:-Sleep(10): # or be patient, and wait

image:=ImageTools:-Read(cat(kernelopts(homedir),"/bifu4096.jpg"),
                        format=JPEG):

ImageTools:-Write(cat(kernelopts(homedir),"/bifu640.jpg"),
                  ImageTools:-Scale(image,1/6.4),format=JPEG):
&lt;/pre&gt;
&lt;p&gt;
I'm not altogether content with the above code. I didn't change the methodology. (It builds L2 as a listlist for `pointplot` instead of a float[8] Array for `plot` with style=point. It doesn't use evalhf or any other acceleration. I'm a little picky about globals, in the sense that I prefer code without them, when possible.) It's a good start, to build from, and the topic is interesting.
&lt;/p&gt;
A few other comments are in order here. I've noticed that very large exported image files are needed for small symbolsize, in order to export something which is non-empty. In fact, the same thing happens in the Standard GUI itself -- if one makes the symbolsize too small, then the plot is shown as non-empty only if the plot window has been (manually) resized as quite large. Is this really useful, helpful, and best?
&lt;p&gt;&lt;!--break--&gt;&lt;p&gt;acer&lt;/p&gt;
ps. My firefox is only showing me the Mapleprimes post editor in raw html form, for a day or so. So I don't have the nice editor, and cannot upload files. (Am I the only one with this issue?) If one person who doesn't have this issue would care to produce and upload the final 640x640 image using the above code, that might be nice, thanks.</itunes:summary>
      <description>The latest comments added to the Post, logistic map example</description>
      <guid>128762</guid>
      <pubDate>Wed, 14 Dec 2011 09:40:46 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>Image</title>
      <link>http://www.mapleprimes.com/posts/128749-Logistic-Map-Example?ref=Feed:MaplePrimes:logistic map example:Comments#comment128776</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/128749-Logistic-Map-Example#comment128762"&gt;@acer&lt;/a&gt;&amp;nbsp;&lt;a href="/view.aspx?sf=128776/427040/bifu640.jpg"&gt;&lt;img src="/view.aspx?sf=128776/427040/bifu640.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, logistic map example</description>
      <guid>128776</guid>
      <pubDate>Wed, 14 Dec 2011 20:20:47 Z</pubDate>
      <itunes:author>Preben Alsholm</itunes:author>
      <author>Preben Alsholm</author>
    </item>
    <item>
      <title>nice!</title>
      <link>http://www.mapleprimes.com/posts/128749-Logistic-Map-Example?ref=Feed:MaplePrimes:logistic map example:Comments#comment128780</link>
      <itunes:summary>&lt;p&gt;Thanks acer,&lt;/p&gt;
&lt;p&gt;when I saw the question the first time, I thought there's something I too would like to know how to do, but being busy with other (less fun but paid) things I merely made a mental note of it. I was quite surprised to discover a little later that no answer had been forthcoming. Even more surprised when google did not return too much on Maple and bifurcation (There is a very useful Maple application by Doug Meade, &lt;a href="http://www.maplesoft.com/applications/view.aspx?SID=4694"&gt;http://www.maplesoft.com/applications/view.aspx?SID=4694&lt;/a&gt;). Nusc's code was right there within mapleprimes, but the OP seemed unaware of it. I made small modifications suggested by Robert Israel and re-posted. I'm glad that the topic has interested you. The plot you get (thanks Preben for posting) is a great improvement. I did originally notice the code was not efficient, and immediately thought about your excellent post&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/123463-ImageTools-For-Complex-argument--Plot"&gt;http://www.mapleprimes.com/posts/123463-ImageTools-For-Complex-argument--Plot&lt;br&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;That post had much about how to efficiently create colorful density plots. I have just discovered a colorful variant of the bifurcation diagram, written for r*x(1-x^3). The code is written in C. [EDIT: code deleted for fear of copyright issues] Please refer to &lt;span&gt;David Green, the author, http://www.flickr.com/photos/davidmxg/5271405684/&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="/view.aspx?sf=128780/427050/LogisticMap_DavidGre.jpg"&gt;&lt;img src="/view.aspx?sf=128780/427050/LogisticMap_DavidGre.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, logistic map example</description>
      <guid>128780</guid>
      <pubDate>Wed, 14 Dec 2011 22:44:29 Z</pubDate>
      <itunes:author>PatrickT</itunes:author>
      <author>PatrickT</author>
    </item>
    <item>
      <title>@acer : how is this?
with(ImageTools):BF8 := proc</title>
      <link>http://www.mapleprimes.com/posts/128749-Logistic-Map-Example?ref=Feed:MaplePrimes:logistic map example:Comments#comment128835</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/128749-Logistic-Map-Example#comment128762"&gt;@acer&lt;/a&gt; : how is this?&lt;/p&gt;
&lt;pre&gt;with(ImageTools):&lt;br&gt;BF8 := proc(ra, rb, xr, yr, n)&lt;br&gt;local data;&lt;br&gt;&amp;nbsp; data := ImageTools:-Create(yr, xr, 1);&lt;br&gt;&amp;nbsp; worker(data, HFloat(evalf(ra)), HFloat(evalf(rb)), xr, yr, n);&lt;br&gt;&amp;nbsp; return data;&lt;br&gt;end proc:&lt;br&gt;worker := proc(&lt;br&gt;&amp;nbsp; data :: Array(datatype=float[8], order=C_order),&lt;br&gt;&amp;nbsp; ra :: float[8],&lt;br&gt;&amp;nbsp; rb :: float[8],&lt;br&gt;&amp;nbsp; xr :: posint,&lt;br&gt;&amp;nbsp; yr :: posint,&lt;br&gt;&amp;nbsp; n :: posint)&lt;br&gt;local&lt;br&gt;&amp;nbsp; ix :: posint,&lt;br&gt;&amp;nbsp; iy :: posint,&lt;br&gt;&amp;nbsp; r :: float[8],&lt;br&gt;&amp;nbsp; rscale :: float[8],&lt;br&gt;&amp;nbsp; x :: float[8],&lt;br&gt;&amp;nbsp; y :: posint;&lt;br&gt;&lt;br&gt;&amp;nbsp; rscale := (rb - ra) / (xr - 1);&lt;br&gt;&amp;nbsp; for ix to xr do&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; r := ra + rscale * (ix - 1);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x := HFloat(0.5);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for iy to 3 do&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Warmup.&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x := r * x * (1-x);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end do;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for iy to n do&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x := r * x * (1-x);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y := trunc(x * yr) + 1;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data[y, ix] := data[y, ix] + 1;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end do;&lt;br&gt;&amp;nbsp; end do;&lt;br&gt;end proc:&lt;br&gt;worker := Compiler:-Compile(worker):&lt;br&gt;m := BF8(2.6, 4, 1000, 1000, 250):&lt;br&gt;map[inplace, evalhf](`/`, m, max(m)):&lt;br&gt;m3 := m ^~ (1/3):&lt;br&gt;ImageTools:-Write("abc.tiff", m3):&lt;/pre&gt;
&lt;p&gt;Leads to this image (converted to png). As you see it's upside down; easy to fix but I didn't bother. If your screen is too narrow (as mine is - I use my monitor in portrait mode), there's a scaled down version below.&lt;/p&gt;
&lt;p&gt;Erik.&lt;/p&gt;
&lt;p&gt;&lt;a href="/view.aspx?sf=128835/427150/abc.png"&gt;&lt;img src="/view.aspx?sf=128835/427150/abc.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="/view.aspx?sf=128835/427150/abc2.png"&gt;&lt;img src="/view.aspx?sf=128835/427150/abc2.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, logistic map example</description>
      <guid>128835</guid>
      <pubDate>Thu, 15 Dec 2011 23:19:53 Z</pubDate>
      <itunes:author>epostma</itunes:author>
      <author>epostma</author>
    </item>
    <item>
      <title>wonderful</title>
      <link>http://www.mapleprimes.com/posts/128749-Logistic-Map-Example?ref=Feed:MaplePrimes:logistic map example:Comments#comment128838</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/128749-Logistic-Map-Example#comment128835"&gt;@epostma&lt;/a&gt; It is beautiful.&lt;/p&gt;
&lt;p&gt;Your code produces the grayscale tiff in under a second on my machine, with very modest memory use. This should be taken as target performance for the Standard GUI, for `plot`+`style=point` with an mx2 float[8] Array as well!&lt;/p&gt;
&lt;p&gt;Now, it looks as if you are keeping track of the number of times that you "end up" at any data[y,ix] point, and using that for the grayscale. How about using those values (scaled) for the Hue layer of an HSV image?&lt;/p&gt;
&lt;p&gt;If only we could programatically embed images right into worksheets, instead of fumbling with resource hungry point-plots. And of course I don't count ImageTools:-Preview which is a rough scaled-down, slow point-plot, or ImageTools:-View which is only a popup.&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, logistic map example</description>
      <guid>128838</guid>
      <pubDate>Fri, 16 Dec 2011 00:43:06 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>wow</title>
      <link>http://www.mapleprimes.com/posts/128749-Logistic-Map-Example?ref=Feed:MaplePrimes:logistic map example:Comments#comment128844</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/posts/128749-Logistic-Map-Example#comment128835"&gt;@epostma&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;wow, so elegant and, as acer points out, so fast. A big thank you.&lt;/p&gt;
&lt;p&gt;P.S. I'll need some time to fully understand your code, right now I just marvel.&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, logistic map example</description>
      <guid>128844</guid>
      <pubDate>Fri, 16 Dec 2011 01:33:28 Z</pubDate>
      <itunes:author>PatrickT</itunes:author>
      <author>PatrickT</author>
    </item>
  </channel>
</rss>