The logistic map

Introduced by the biologist Robert May in 1976, the logistic map turned out to be a lot more complex that meets the eye.

Definitions

The logistic map is a recursive sequence defined as:

\[x_{n+1}=rx_n(1-x_n),\]

where \(r\in [1,4]\) is the growth ratio and with \(x_0\in[0,1]\). The goal of this module is to be able tu visualize the logistic map, but also to create its bifurcation diagram and link it to the Mandelbrot set.

The bifurcation diagram is a plot of where the logistic map tends to. It shows us that as the growth ratio approaches \(4\), the chaotic behaviour appears.

Summary of the outputs

Methods Output
float video matplotlib plot
animate_logistic X
connections X
logistic X
logistic_draw X
bifurcation X X
logi_branch_points X
plot_logi_interact X

animate_logistic(save=False)

Represents the evolution of the logistic map.

We can see the creation of the sequence step by step. The graph of the function is animated. It shows the convergence of the sequence when r is small enough, then, the chaotic representation.

Parameters

save (boolean) – the ability to save the video in a file

Returns

the matplotlib animation. If save==True, it saves the animation in ‘temp’ and in a .mp4 format

Return type

plot the animated graph

bifurcation(show=True)

Builds the bifurcation diagramm of the logistic map.

The x-axis corresponds to the common ratio, r (in [0,4]), and the y-axis corresponds to the x points of the logistic function. This graph summarizes the different possibilities of the logistic draw according to r. The final graph represents bifurcations. When r is equal to 3, we see the first bifurcation.

Parameters

show – True. Otherwise, the tuples of points coordinates.

Returns

the bifurcation graph or the coordinates

Return type

matplotlib graph or list of float tuples

connections()

Shows the link between Mandlebrot, logistic map and bifurcation.

This function shows the connections with the two Mandlebrot objects of this package: the Mandlebrot set and the logistic map. The moving red line shows the place that we are on these three graphs, at the same time. It saves the video in .avi in the ‘temp’ directory.

Return type

Matplotlib animation and a save in a .avi format

logi_branch_points(x0, mu, nb_iter=100)

It creates of the logistic sequence points.

This function makes all coordinates of the sequence’s points and puts them in a list. It creates stairs too.

Parameters
  • x0 (float) – the starting point included in [0,1]

  • mu (float) – the common ratio

Nb_iter

the number of iterations of the sequence

Returns

list of sequence points

Return type

list of tuples

logistic(r, x)

Calculates values of the logisitc function.

Parameters
  • r (float) – the common ratio

  • x (float) – the value of the research point

Returns

the logistic value of x

Return type

float

logistic_draw(x0, r, iteration, points)

First way to be able to draw the logistic sequence.

It draws the logistic function, the (y=x) line. With these lines, the logistic sequence can be drawn.

Parameters
  • x0 (float) – the starting point included in [0,1]

  • r (float) – the common ratio

  • iteration (integer) – the number of iteration to draw these lines

  • points (integer) – the number of points between 0 and 1 on the x-axis

Returns

the curves (y=x) and logistic function with the creation of the logistic sequence

Return type

plot the graph

plot_logi_interact(x0, r, nb_iter=100, linsdim=100, colors='red')

Another way to plot the logistic function which is faster so more pleasant to use with the interaction.

This function creates the logistic sequence. Meaning, we start with x0, then we know the second point drawing the ‘stair’ with (y=x) and the logistic function. And we do it again, up to nb_iter. But here, we know all points thanks to the logi_branch_points function.

Parameters
  • x0 (float) – the starting point included in [0,1]

  • r (float) – the growth ratio

  • nb_iter (integer) – the number of iterations of the sequence

  • linsdim (integer) – number of points between 0 and 1 on the x-axis

  • colors (string) – color for the cobweb

Returns

graph representing logistic sequence

Return type

matplotlib plot