Question: The Logistic Map Function(python) Write three functions: log map(): Takes two arguments, the amplitude a and the population of the current generation x and returns
The Logistic Map Function(python)
Write three functions:
log map(): Takes two arguments, the amplitude a and the population of the current generation x and returns the population of the next generation f(a, x) = ax(1 x). This entire function can be written in two lines, the def statement and the return statement!
compare(): Takes four arguments: 1) the amplitude a, 2) the number of generations n, 3) initial population xa, and 4) initial population xb. Uses a for-loop with a call to log map() for each of the different initial population values to calculate successive populations. Prints the generation number, the value of xa, the value of xb, and the difference between the two. It also prints the header as shown below in the listing. Note that youll have to use tabs in the print statement. The character for a tab is \t. The command youll use is print(Gen #, \t\txa, \t\t\txb, \t\t\txa - xb). If this doesnt look good on your screen, try using different numbers of tabs.
main(): Prompts user for the amplitude a, the number of generations n, and the initial values xa and xb and calls compare(). The following demonstrates the proper behavior of this program:
Enter the amplitude a: 0.99
Enter the number of generations n: 200
Enter the two initial populations: 0.30001, 0.30000
Gen. # xa xb xa - xb
1 0.207903959901 0.20789999999999997 3.959901000022414e-06
2 0.16303310432489854 0.16303081409999998 2.2902248985601226e-06
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
