# prize35-8 Exercise 3: what happens to the averages if the predator's death rate rises? def average_after_settling(d, years=120): prey, pred = 40.0, 20.0 a, b, c = 0.6, 0.02, 0.01 dt = 0.01 total_prey = total_pred = count = 0 for step in range(int(years / dt)): if step * dt >= years / 2: total_prey += prey total_pred += pred count += 1 new_prey = prey + (a * prey - b * prey * pred) * dt new_pred = pred + (c * prey * pred - d * pred) * dt prey, pred = new_prey, new_pred return total_prey / count, total_pred / count for d in [0.5, 0.7]: mean_prey, mean_pred = average_after_settling(d) print(f"predator death rate {d}: average prey {mean_prey:.1f}, average predators {mean_pred:.1f}") print("model equilibria: prey = d / c, predators = a / b") print("d = 0.5 ->", 0.5 / 0.01, "prey and", 0.6 / 0.02, "predators") print("d = 0.7 ->", 0.7 / 0.01, "prey and", 0.6 / 0.02, "predators") # Output: # predator death rate 0.5: average prey 50.3, average predators 29.7 # predator death rate 0.7: average prey 70.8, average predators 30.1 # model equilibria: prey = d / c, predators = a / b # d = 0.5 -> 50.0 prey and 30.0 predators # d = 0.7 -> 70.0 prey and 30.0 predators # Reading it: raising the predator death rate leaves the average number of predators about the same (30) but raises the average number of prey (50 to 70). # In this model the predators' death rate sets the prey balance point (d / c), while the prey's growth rate and the capture rate set the predators' (a / b). # So making life harder for predators does not shrink their average numbers here: it is the prey that benefit.