Exercise 11 (RELEVANT FOR PYTHON OR MATLAB, NOT RELEVANT FOR ALL PROGRAMMING LANGAUGES):
You might have noticed that your program becomes very slow if you have a very large number of time steps. Part of this is unavoidable; each time step requires the computer to do some processessing. However, much of the computation time is consumed by appending new values onto the arrays.
Rewrite your program so that, instead of repeatedly appending to the arrays, you create large empty arrays before the loop; then in each iteration of the loop, you record the new numbers in the appropriate element of the array. Observe and discuss how this affects the computation time.