3

At the moment I am trying to create a bifurcation diagram of the discontinuous piecewise function given by following Mathematica code:

f[x] = Piecewise[{{-1, x < -1}, {1, x > 1}, {x * (1 - alfa) + alfa, 
1 >= x > alfa}, {x * (1 - alfa) - alfa, -alfa > 
 x >= -1}, {x * (2 - alfa), alfa >= x >= -alfa}}]

where alfa is a parameter. Here you have an appropriate manipulation plot:

Manipulate[Plot[Piecewise[{{-1, x < -1}, {1, x > 1}, {alfa + (1 - alfa) x, 
 1 >= x > alfa}, {-alfa + (1 - alfa) x, -alfa > x >= -1}, {(2 - alfa) x, alfa >= x >= -alfa}}, 0], {x, -2, 2}], {alfa, 0, 1}]

Is it possible? Most of the examples found on the internet deal with continuous functions.

Jarek Mazur
  • 215
  • 1
  • 4

1 Answers1

3

Here's an example of the classic logistic map:

f[x_, r_] := r x (1 - x);
ListPlot@Flatten[Table[Union[{r, #} & /@ 
     Drop[NestList[f[#, r] &, RandomReal[], 600], 500]], {r, 2.5, 4, 0.005}], 1]

enter image description here

Now try it with your function:

f[x_, alfa_] := 
 Piecewise[{{-1, x < -1}, {1, x > 1}, {x*(1 - alfa) + alfa, 
    1 >= x > alfa}, {x*(1 - alfa) - alfa, -alfa > 
     x >= -1}, {x*(2 - alfa), alfa >= x >= -alfa}}]

ListPlot@Flatten[Table[{r, #} & /@ 
    Drop[NestList[f[#, r] &, RandomReal[], 600], 500], {r, -2, 4, 0.01}], 1]

enter image description here

What this code does it apply the function to a random number 600 times, then discard the first 500 results. We are looking for the fixed point(s) of the function for a given value of $r$. The values are then turned into points with a map (/@), collected together and plotted. (Explanation of Mathematica syntax can be found here).

wxffles
  • 14,246
  • 1
  • 43
  • 75
  • Thanks a lot for your quick answer! Would you be so kind and please explain what your code does? I'm relatively new to mathematica and I can't quite grasp what @, & and /@ do in your snippet. – Jarek Mazur Apr 29 '15 at 07:19