Chaos

Useful to know: loops.

Let's look at an example of chaos arising from simplicity in nature: the logistic map. It's a simplified model used to describe population sizes and can be written mathematically as $x_{n+1} = rx_n(1 - x_n)$ where $0 < r < 4$ is a parameter and $0 < x_n < 1$ represents the population size at time step $n$. Starting with an initial population size of $x_0 = 0.5$ and $r$ as an input parameter, return a list of the first 50 values of the logistic map $x_0, x_1, x_2, \dots, x_{49}, x_{50}$. You should see different behavior depending on the value of $r$, but we'll leave you to play around with it and we'll have more to say on the solution notes.

Input: The parameter $r$.

Output: A list containing the first 50 values of the logistic map $(x_0, x_1, x_2, \dots, x_{49}, x_{50})$.

Example input

2.81

Example output

[0.500000, 0.702500, 0.587272, ⋯, 0.644125, 0.644130, 0.644126]

You must be logged in to submit code but you can play around with the editor.

You must be logged in to upload code.

• There's a huge amount of stuff we could say about the logistic map.