Homework 4. For \(r\) varying between 0 and 4, find out the possible "limit cycles"§ of the iterative map:
\begin{equation} x_{n+1}=r x_n(1-x), \qquad x_0= 0.5 \text{(or anything else that is not $0$ nor $1$)} \end{equation}
This converges to a single value for some values of \(r\) but for others results in an "orbit", which can be very long. For every \(0<r<4\), "find" this orbit and plot the orbits together.
Use the "matrix-at-a-time" notation we learned in the last iteration example:
Hint 1: (Am I getting the right answer?) The result should look something like this:

Graphing an iterative function.
Hint 2: (Code takes forever) If your code is running very slowly, you should consider updating all the orbits (one for each \(r\) value) at once. This implies holding a vector that corresponds to the \(r\) values you are considering, and a vector corresponding to the various orbits, and with one line of code you can update all the values in the orbit. Do this in a loop to find "late" elements of the orbit.
Hint 3: (Getting a similar plot, but not quite) You should only plot the late elements, so perhaps iterate without plotting for some time (maybe 1000 iterations?) and then plot successive elements of the orbit (say 100?).
Hint 4: (I don't have so many points in my plot) Be sure to use hold on so that each plot doesn't erase the previous ones.
More ideas:
§a limit cycle is an orbit of an iterative map that the dynamics of the problem converges to, regardless of the initial condition.