October 28, 2004 --- Class 18 --- Energy Conservation; Logistic Map and Chaos Activities: Energy Conservation and the Euler Richardson Method On the homework, you were asked to find the optimal value of dt for solving a differential equation. To do this, you should plot the change in energy for a number of dt values. I looked at values from 10^-2 to 10^-8 using a double precision code. From 10^-2 to 10^-4, the error in energy drops like dt^3. For 10^-5, the curve is not quite so smooth. For smaller values of dt, the improvement is marginal (10-6), or energy conservation is not as good at with dt=10^-5. Who wants to do 10 times as much work and get worse results? With values of dt that are too small, the error comes from round off error. For a single precision code dt=10^-3 is already showing ragged behavior, indicating that round off error is becoming significant. With a time step of 10^-3, the double precision code is conserving energy significantly better than the single precision code. What Value of dt is Needed for a 0.1% Error in the Energy You were asked to solve this problem for part of homework using two values of the angular frequency. I showed a plot of the error in the energy at the end of the first period for different values of dt. We see how the error is proportional to dt^3. It is easy to determine the constant of proportionality in each case. With this knowledge, it is trivial to find the value of dt that results in an error of 0.1%. Chaos and the Logistic Map We introduced the logistic map from consideration of an insect population model. P_{n+1} = P_n (A - B P_n) Upon scaling the population, the population is replaced by x which lies in the range [0,1]. The next generation is given by x <- 4 r x * (1-x) . A program entitled map allows you to follow the time history of a population. Map takes three command line arguments: r, the parameter that appears above in the definition of the map; x_0, the initial value of the population; and iterations, the total number of generations to calculate. In the next class, we shall see what the long term future of the population is.