I am trying to make just a general picture that looks like this one:

enter image description here

It doesn't have to look exactly like this, but just look like a general bifurcation in similar spirit to this one.

And here is the code I tried:

  function logistic()

    local function map(r,x)
      return r*x*(1-x)

    for r = 2.5,4,0.005 do
      x = 0.1
      for i = 1, 200 do
        x = map(r,x)
      for i = 1, 250 do
        x = map(r,x)
  \begin{axis}[tick label style={font=\tiny}]
    \edef\logisticplot{\noexpand\addplot [color=black!10, mesh, only marks,
      mark size = 0.05pt, opacity = 0.1] coordinates{ \directlua{logistic()} };}

I found the code on this website, but I don't understand this language so I can't figure out why the code isn't working: http://texwelt.de/wissen/fragen/7097/wie-kann-man-einen-iterativen-plot-eleganter-schreiben

  • 1
    which engine did you compile the code with? – percusse May 16 '15 at 20:31
  • @percusse Sorry, I don't know what "engine" means. I currently use MiKTeX and TeXnicCenter, and I compiled with LaTeX => PDF – mr eyeglasses May 16 '15 at 21:13
  • 1
    You need to run it with LuaLaTeX -> PDF. And better decrease the loop numbers because it will take a lot of time. Start with 10,20 instead of 200,250 – percusse May 16 '15 at 22:00
  • 1
    @ᴇʏᴇs you should use LuaLaTex in order to compile the tikzpicture, since it's written in Lua, the programming language. – Airman01 May 16 '15 at 22:00

Here is solution provided with a bit of research, minor code modification, and implemented using R and knitr with LaTeX.


%Reference: \verb+http://www.magesblog.com/2012/03/logistic-map-feigenbaum-diagram.html+

logistic.map <- function(r, x, N, M){
  ## r: bifurcation parameter
  ## x: initial value
  ## N: number of iteration
  ## M: number of iteration points to be returned
  z <- 1:N
  z[1] <- x
  for(i in c(1:(N-1))){
    z[i+1] <- r *z[i]  * (1 - z[i])
  ## Return the last M iterations 

## Set scanning range for bifurcation parameter r
my.r <- seq(2.5, 4, by=0.003)
Orbit <- sapply(my.r, logistic.map,  x=0.1, N=1000, M=300)

Orbit <- as.vector(Orbit)
r <- sort(rep(my.r, 301))

plot(Orbit ~ r, pch=".")

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.