# Bifurcation diagram of a difference equation

The function is

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


How to make the bifurcation graphic of it? What information may I take from the diagram?

• We need an equation not a function. Is this a difference equation or differential equation? – Chris K Jul 26 '19 at 8:29
• Ok the difference equation the following: x_{n+1}=f(x_n,a) – Javohir Usmonov Jul 26 '19 at 8:47
• What are the ranges of $x$ and $a$? – Αλέξανδρος Ζεγγ Jul 27 '19 at 9:18

In general you need a DE or a recurrence relation to generate a bifurcation diagram. For example, the logistic map is:

x[n+1]=r x[n](1-x[n])


Check logistic map at Mathworld: Logistic map

Here is code to generate the bifurcation diagram for the logistic map:

  ListPlot[Table[
Map[{r, #} &,
DeleteDuplicates[
SetPrecision[
Take[RecurrenceTable[{x[n + 1] == r x[n] (1 - x[n]),
x[1] == 0.6}, x, {n, 1, 100}], -20], 5]]], {r, 1, 4,
0.001}], PlotStyle -> Black]


This is my answer after guessing the ranges of $$x$$ and $$a$$:

data = Flatten[Thread /@
ParallelTable[
{a, DeleteDuplicates[Chop@FixedPoint[x \[Function] f[x, a], #, 1000] & /@ Subdivide[0., 1., 100]]},
{a, 0, 2, .001}
],
1];


where, to speed up the calculation, I use the parallel version of Table. One can further make it faster by defining a compiled version of f using Compile, I suppose.

Then make the figure:

ListPlot[data, PlotTheme -> {"Scientific", "SansLabels", "LargeLabels"}, FrameLabel -> {"a", "x"}, PlotStyle -> {Blue, PointSize[.0002]}]