14.7 N-Body Simulation closed Module 14, where every model conserved something: energy, momentum, angular momentum. Module 15 turns to systems with nothing to conserve. A population gains by births and loses by deaths, and the books never balance in the mechanical sense. The consequence is the picture of 3.8 Autonomous Equations, Equilibria & Stability: trajectories from different starts converge on an attractor, a state the system forgets its history in. In one dimension an attractor is a fixed point, which is why this lesson leans on the phase line. Not every model in the module settles to a point, and the last two sections show that even one equation can leave “fixed points attract” behind.
Transcript
- Exponential growth, N prime equals r N, says a culture of 1000 cells with r equal to 0.7 per hour doubles every 0.990 hours, and after 48 hours the formula gives 3.9 times 10 to the 17 cells. No flask holds that. What fails is the constant per-capita rate: crowding makes it fall as N grows, and the simplest model lets it fall linearly.
- Letting the per-capita rate fall linearly gives the logistic equation, N prime equals r N times one minus N over K. With r equal to 0.8, K equal to 100 and N0 equal to 5, the solution is an S-curve whose inflection sits at K over 2, at t equal to 3.68, and it climbs from 10 percent to 90 percent of K in 5.49 time units. On the phase line, 0 is unstable and K is stable, so every positive start ends at K.
- Real data are noisy, so here the numbers are synthetic: seed 15, noise 0.08, truth N0 equal to 5, r 0.8, K 100. Fit the log of N by Gauss-Newton and 11 steps give r equal to 0.8291 plus or minus 0.0364 and K equal to 102.14 plus or minus 3.36. The truth lies within 1.5 standard errors. Now keep only the first 6 points, before the curve flattens: K is 106.5 plus or minus 9.9, and with 5 points 100.2 plus or minus 20.1. The steep part pins r; K is known only once the data approach it.
- Gompertz growth drops the per-capita rate linearly in the log of N. With u equal to the log of N over K, u prime is minus r u, so it solves in closed form, and its inflection is at K over e, about 37 percent of K against 50 percent for the logistic. On the same 13 points the logistic has rms residual 0.0696 and K equal to 102.1, the Gompertz 0.1049 and K equal to 116.5 plus or minus 8.1. On the first 8 points Gompertz gives K equal to 163 plus or minus 35. When the plateau is unobserved, model choice moves K by a large factor.
- Harvest a logistic stock at a constant yield h. The two equilibria are 65.8 and 34.2 at h equal to 18, 61.2 and 38.8 at 19, with recovery time 5.59, and they merge at h equal to 20, the maximum sustainable yield r K over 4, reached at N equal to 50. At h equal to 19, only 5 percent under it, a die-off of 40 percent puts the stock at 36.7, below the threshold of 38.8, and it is extinct at t equal to 11.1. At h equal to 21 the stock reaches zero at 30.2. Constant effort fails only above r.
- The strong Allee effect makes the per-capita rate negative below a threshold A, here 20. The system is bistable: extinction and K both attract. Add effort E and at 0.5 the equilibria are 41.3, unstable, and 78.7, stable. They merge at E equal to 0.64, and past it only zero remains. Ramp the effort up and back down: the stock collapses at 0.686 and does not return when E returns to 0. The logistic model under the same ramp collapses at 0.803 and recovers at 0.393. Recovery of an Allee stock means restocking above the threshold.
- Many species breed once a year, so the model is a map, x goes to mu x times one minus x, which is also Euler's method on the logistic equation. The fixed point loses stability at mu equal to 3 and the period doubles at 3.449490, 3.544090, 3.564407. The gaps shrink by 4.751, 4.656, 4.668, 4.669, toward the Feigenbaum constant, from memory. The Lyapunov exponent is minus 0.223 at 2.8, plus 0.50 at 3.9, which is chaos, and ln 2 at 4.
- A one-dimensional ODE cannot oscillate, but a population that responds to its past density can. In Hutchinson's equation, from memory, the delayed term gives the characteristic equation lambda equals minus r e to the minus lambda T. A pair of imaginary roots is a Hopf bifurcation, at r T equal to pi over 2, with period 4T. With r equal to 1 the real part is minus 0.058 at T equal to 1.4, so the oscillation decays, and plus 0.033 at 1.7: a steady cycle from 0.334 K to 1.943 K, period 6.96. At r T equal to 2.5 the swing runs from 0.0016 K to 4.68 K.
- One species is a one-dimensional problem, and even so we met folds, a threshold with hysteresis, and oscillation once generations are discrete or responses delayed. Next, predator and prey couple two species. The Lotka-Volterra equations turn out to have a conserved quantity and closed orbits, a reminder of Module 14 inside a biological model. Holling functional responses then lead to limit cycles and the paradox of enrichment, and competing species to competitive exclusion.
Exponential growth and its failure
If each individual contributes the same births and deaths, and . A culture with cells and per hour doubles every hours, and after hours the formula says cells. No flask holds that. What fails is the constant per-capita rate : crowding makes it fall as grows, and the simplest model lets it fall linearly.
Logistic growth, revisited
Put :
3.8 Autonomous Equations, Equilibria & Stability derives the solution by separation. Here is the per-capita rate of a nearly empty habitat and the level where births balance deaths. The growth rate is a parabola, so at (unstable, ) and at (stable, ), and is fastest at , where the curve has its inflection. With , , the inflection is at , and the time to climb from to of is .
The phase line replaces the energy surface of Module 14. Arrows point up on and down above , so every positive start ends at . The slope of at an equilibrium is the rate of approach, here as a time scale.
Fitting a model to data
A model is useful once its constants are measured. To keep the numbers honest the lab uses synthetic data: numpy default_rng(15), true , , , , noise with standard normal, rounded to (the values are in the exercise).
Fit , not : the noise is proportional to size, so the residuals have equal spread, whereas residuals in would let the big late points dominate. Minimise over . Linearise about the current guess, with , and set the gradient of to zero:
These normal equations answer the “tall” case of 1.3 Linear Systems, Kernel & Column Space: more data than unknowns, so take the closest solution. Update and repeat: Gauss-Newton. With , and , the Jacobian columns are
If a step raises the cost, halve it until it does not.
Result. From the start the iteration reaches the minimum in steps (the sim shows each one) at
with an rms residual of . The are standard errors , . A separate scipy least_squares run agrees to five digits, and fresh data sets (seed ) scatter in and with standard deviations and , so the formula is honest. The true values lie within about standard errors.
What the data can and cannot say. Keep only the first points (, before the curve flattens): . With points, , right by luck and uncertain by a fifth. The -standard-deviation band of the fitted curve at is for all points and for . The steep part pins ; is known only once the data approach it.
A tempting shortcut regresses the per-capita rate on (intercept , slope ). Here it gives , , but over the repeats its scatter in is against .
Gompertz growth
Replace the linear drop in per-capita rate with a drop linear in : . Put . Then , so and
Differentiating gives , so the inflection is where : at , about of against the logistic . The peak growth rate is . The curve is asymmetric where the logistic is symmetric about its inflection. Since as , the theta-logistic tends to Gompertz ( is logistic). The per-capita rate is unbounded as .
Against the data. On all thirteen points the logistic has rms residual and , the Gompertz and ; the curves differ by at most (at ). On the first points Gompertz gives , and on the first it fits fractionally better ( against ) with . Whenever the plateau is unobserved, model choice moves by a large factor.
Harvesting and sustainability
Harvest a logistic stock with , . 3.8 Autonomous Equations, Equilibria & Stability analysed the constant yield : the equilibria are and they merge at , the peak of , the maximum sustainable yield (MSY), reached at . The new point is what happens near that edge.
| stable | unstable | recovery time | |
|---|---|---|---|
| (semi-stable) | no linear rate |
At , only under the MSY, a one-off die-off of from puts the stock at , below the unstable equilibrium , and it is extinct at (from it is ). At the stock starting at reaches zero at (from : ). This is the fold of 3.9 Bifurcations: slow recovery near the edge is critical slowing down, and above it there is nothing to settle on.
Constant effort removes a fraction: . Now the per-capita rate is , a logistic with smaller growth rate, so and the yield is , a parabola with the same maximum at , . But the equilibrium moves smoothly with and is approached at rate : , at (rate ), and , at . More effort catches less. Only at does the stock die out, and that is a transcritical, not a fold, crossing. Catch per unit effort is proportional to , a warning a fixed quota lacks.
In the sim’s right panel the curve , the per-capita rate, is the equilibrium yield of effort , solid where decreases (stable). For Gompertz, never reaches zero, and the MSY is at , .
The Allee effect
Some species suffer at low density (mates are hard to find). The strong Allee effect makes the per-capita rate negative below a threshold :
With , , there are three equilibria. (stable: extinction attracts), (unstable, the threshold) and (stable). The system is bistable, and the threshold is a separatrix on the phase line. A start at is at by and by ; a start at is at at and at to six digits by . Two units decide the fate. A weak Allee effect, say , has no threshold: the per-capita rate is still positive but rises with at low density (for it peaks at near ).
Harvesting a strong Allee population. With effort , and peaks at with value . For there are two positive equilibria: at they are (unstable) and (stable). At they merge and for larger only remains. The yield on the stable branch peaks at (at , ), twice the logistic MSY, but that is only of below the collapse effort .
Hysteresis. Ramp from slowly up to and back over time units. The stock drops below of at (just above the fold, a small lag) and does not come back as returns to , because is stable for every . The logistic model under the same ramp collapses at (just past its own , where the fold-free transcritical point sits) and recovers above at on the way back down, a delay but not a permanent loss. Recovery of an Allee stock means restocking above the threshold: above at , and above with no harvesting. This is the hysteresis of 3.9 Bifurcations: turning the knob back does not undo the jump.
Discrete generations and Euler’s method
Many species breed once a year, so the natural model is a map, with the population as a fraction of its maximum. The same map appeared in 3.8 Autonomous Equations, Equilibria & Stability: Euler’s method on the logistic ODE with step is exactly this map with . For an ODE the oscillation is an artifact of the method; for a population with discrete generations it is real.
The fixed point has multiplier , so it is stable for . A 2-cycle takes over at and loses stability at . Solving numerically for the parameter where each -cycle has multiplier (Newton on , and independently with scipy fsolve) gives the period-doubling points
with ratios of successive gaps , approaching the Feigenbaum constant (the digits from memory). The doublings pile up near (extrapolating with ; from memory ). Beyond it the Lyapunov exponent , the mean of along an orbit, can be positive, which means chaos.
| attractor | ||
|---|---|---|
| fixed point | ||
| 4-cycle | ||
| chaotic | ||
| 3-cycle (window opens at , checked) | ||
| chaotic | ||
| chaotic |
For Euler on the logistic ODE chaos starts at , i.e. for . (See 4.5 Stability Regions & Stiffness for stepping limits.)
Delay equations (a glimpse)
A one-dimensional ODE cannot oscillate, but real populations respond to past density: maturation takes time. Hutchinson’s equation (from memory, 1948) is
The state is now the whole history on . is still an equilibrium; with , . Try :
A pair of imaginary roots marks a Hopf bifurcation. The real part of gives , so ; the imaginary part gives . The stability limit is
with period at onset. For the roots are real (they merge where the line is tangent to the exponential) and the return to is monotone; between and it is a damped oscillation. With , the real part of the leading root is at and at (roots from the Lambert W function, scipy).
The sim integrates the equation by RK4 with a cubic-Hermite history. A separate method-of-steps solution in scipy (solve_ivp, tolerance ) agrees to better than in the amplitudes below and in the periods. At the solution stays within of from to . At it settles into a steady cycle between and , period . At : to , period . At the cycle swings from to with period , so the model population falls to of every cycle.
Using the lab
- Logistic: the dotted line is at ; select Gompertz and it moves to .
- Constant yield: slide from to and watch the equilibria merge.
- Strong Allee: start at and , then add effort and press the sweep button.
- Fit: use points, then , then Gompertz. Map: jump to , then . Delay: cross .
The exercise: Gauss-Newton for the logistic curve
The playground runs the harvested stock with RK4 and the Hutchinson equation with Euler on a grid that holds exactly. In the exercise you write the model, its Jacobian and the damped Gauss-Newton loop; the tests check the numbers above.
Concept checks
Problems
For with and , find the largest growth rate and where it occurs. Compare it with the logistic with the same and .
Show worked solution
has at , where . The logistic peaks at at . At the peak the per-capita rate is for Gompertz and for the logistic, so the Gompertz peak is higher ( against ), though the two ‘s do not mean the same thing.
A logistic stock is harvested at constant effort . Find the equilibrium, the yield , the effort that maximises it, and the rate at which the stock returns after a small disturbance. Evaluate for , , .
Show worked solution
has the stable equilibrium . The yield is , with at , so at . The slope of the right-hand side at is , so a disturbance decays like . For : , , rate (time constant ).
For Hutchinson’s equation with find the critical delay and the period of the oscillation at onset, and check the characteristic equation at .
Show worked solution
The characteristic equation is . At onset and , so . The check: . The period is .
What comes next
One species is a one-dimensional problem, and even so we met folds, a threshold with hysteresis, and oscillation once generations are discrete or responses delayed. 15.2 Predator–Prey & Competing Species couples two species. The Lotka-Volterra equations turn out to have a conserved quantity and closed orbits, a reminder of Module 14 inside a biological model; Holling functional responses then lead to the limit cycles and the paradox of enrichment of the Rosenzweig-MacArthur model, and competing species to competitive exclusion.
Key Takeaways
- Exponential growth fails because the per-capita rate falls with crowding; logistic growth has its inflection at and climbs from to of in .
- Fit by Gauss-Newton (, step halving): , from points, from .
- Gompertz solves by and has its inflection at , peak rate .
- Constant yield and constant effort share the maximum , but yield has a fold at (finite-time extinction above it) while effort fails only at .
- A strong Allee effect gives bistability with threshold ; harvesting folds at , and collapse does not reverse when effort returns.
- Euler on the logistic ODE is the map , : doublings at (ratio ), chaos beyond .
- A delay turns the logistic into an oscillator: the Hopf point of is , with onset period .