# prize35-12 Exercise 1: how big must a reintroduced herd be? r, K = 0.4, 300 def first_year(start, loss, target=150, limit=60): n = start for year in range(1, limit + 1): n = n + r * n * (1 - n / K) - loss n = max(n, 0) if n >= target: return year return None print("start herd year reaching 150 (3 lost each year)") for start in (6, 7, 8, 12, 20, 40): y = first_year(start, 3) print(f"{start:10} {y if y else 'never within 60 years'}") smallest = next(s for s in range(1, 100) if first_year(s, 3)) print("smallest herd that ever reaches 150:", smallest) print("turning point where growth just equals the loss:", round(K / 2 * (1 - (1 - 4 * 3 / (r * K)) ** 0.5), 1)) # Output: # start herd year reaching 150 (3 lost each year) # 6 never within 60 years # 7 never within 60 years # 8 21 # 12 13 # 20 10 # 40 6 # smallest herd that ever reaches 150: 8 # turning point where growth just equals the loss: 7.7 # Reading it: with 3 animals lost every year, a herd below about 7.7 can never grow, because its natural growth is smaller than the loss. # Just above that line the herd grows slowly at first, so a bigger founding group reaches a viable size much sooner.