2
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

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).

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Jarek Mazur Apr 29 '15 at 7:19

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.