//========================================================================= #define PROGRAMMER "SOLUTIONS, NoFrills" #define PROG_CODE "soln" #define COURSE "ECE-1021" #define YEAR (2003) #define TERM "Fall" #define SECTION (0) #define ASSIGNMENT "HW #2A" #define REVISION (0) #define TITLE "Beyond Numeracy" #define SUBTITLE "Study in Chaos" #define EMAIL "wbahn@eas.uccs.edu" #define FILENAME "02a0soln.txt" //========================================================================= // PROBLEM: // // Simulate the population of some item (egrets) according to the // Feigenbaum model presented in the text. // // The model is supposed to demonstrate that, for some combinations of // inputs, the system stabilizes to a single value, for others it // oscillates between two values after it settles down, and for others // it appears to generate random fluctuations. // // PSEUDOCODE: // // // 1) TASK: Get data from the user // 1.1) GET: Rate (rate: floating point value between 0 and 4) // 1.2) GET: Population (pop: integer between 0 and 1,000,000) // 1.3) GET: Years (pop: positive integer) // 2) TASK: Compute and Display Year-by-Year Population // 2.1) SET: year = 0 // 2.2) PUT: year and pop // 2.3) WHILE: (year < years) // 2.3.1) SET: year++ // 2.3.2) SET: pop *= (rate)*(1- pop/N) (N = 1,000,000) // 2.3.3) PUT: year and pop // // QUESTIONS IN HOMEWORK (To be turned in with Pseudocode) // 1) QUESTION The problem states that the formula guarantees that the population for the next year will always be between 0 and one million (under the assumption that the current year's population is within that range). Analyze this claim - either prove that it is true or show the conditions under which it is false. ANSWER Part A: next >= 0 next = rate * cy * (1 - cy/N) >= 0 Since rate, cy, and N are all positive, the only way for this to be false is for (1 - cy/N) to be negative. To prevent this, we need to satisfy the condition: (1 - cy/N) >= 0 ==> cy <= N (stipulated by problem) Notice that rate can be ANY nonnegative value, even greater than 4. Part B: next <= N next = rate * cy * (1 - cy/N) <= N This as a maximum value problem where we want the maximum value of next (as a function of the current population) to be less than N Taking the derivative and setting it equal to zero: d(next)/dcy = rate * (1 - 2cy/N) = 0 which occurs when cy = N/2. The maximum population is then: next = rate * (N/2) * (1 - (1/2)) = rate * (N/4) For this to ne less than N, we need rate to be less than 4. 2) QUESTION The problem states that, for at least some growth rates, this system settles into a stable value. Given the value of R (the rate), what is the equation the yields that stable value? Given the constraints specified on the rate in the problem, what is the maximum stable population (and what growth rate yields that maximum value). For what rate is the stable population zero? For what values of the rate are there no stable values? ANSWER If the population is stable, that simply means that the next year's population is equal to the current year's population. Or: cy = rate * cy * (1 - cy/N) This means that, for a given rate, the stable population is: cy = N * ( 1 - (1/rate) ) Notice the second factor on the right hand side: 1) It gets larger as rate gets larger and is 2) It is equal to zero if rate = 1 3) It is negative if rate is less than 1 Given the constraints on rate (0 <= rate <= 4) The maximum stable popluation occurs at rate = 4 cy(max) = N * ( 1 - 1/4 ) = 3N/4 For a stable population of zero, rate must be equal to 1. Since cy is guaranteed to never be negative, there is no way for it to stabilize at rates less than one.