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.
Answer
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]
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]
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).
Comments
Post a Comment