""" Exercise A.19 from a primer on. Solve the logistic equation and demonstrate that certain parameter choices give rise to oscillating solutions. For experiments of this kind it is convenient to read in the parameters as command line arguments, but hard-coding the values directly in the file is also perfectly fine. """ import numpy as np import matplotlib.pyplot as plt import sys y0 = float(sys.argv[1]) q = float(sys.argv[2]) N = int(sys.argv[3]) y = np.zeros(N + 1) y[0] = y0 for n in range(1, N + 1): y[n] = y[n-1] + q * y[n-1] * (1 - y[n-1]) plt.plot(y) plt.show()