Logistic growth and the carrying capacity · Python Programming Class 11–12 | StemPy Lab
Course 5.1·Lesson 2 of 3
Logistic growth and the carrying capacity
No population doubles for ever: food and space run short. Logistic growth slows the rate by the factor 1−KN
Lesson 2 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
Why growth cannot go on
If one bacterium doubled every 20 minutes for two days, its descendants would weigh more than the Earth. That never happens. Food runs short, waste builds up, and space fills. Each population has a carrying capacityK: the largest count its surroundings can support.
The logistic rule
Exponential growth says the population grows at a rate rN cells per unit time. The logistic rule multiplies that rate by a brake:
dtdN=rN(1−KN)
Read the brake, 1−KN, at three counts:
when N is tiny compared with K, the brake is nearly 1, so the growth is nearly exponential;
when N=2K, the brake is 21;
when N=K, the brake is 0, and the growth stops.
Stepping in small time steps
A computer cannot follow the change continuously. It moves forward in small steps of time dt. In each step the count grows by its rate times the step:
Nnew=N+rN(1−KN)dt
This is Euler's method. In Python it is one line inside a loop:
Here r=0.5 per hour, so dt is in hours, and 240 steps of 0.1 h make 24 hours.
The S-curve
Plot the counts and you see an S-curve. It starts like the exponential, bends at half of K, and levels off at K.
A plot of cells against time in hours, from 0 to 24 hours. A solid blue S-shaped curve starts at 10 cells, rises steeply in the middle and levels off at a dotted line, the carrying capacity of 650 cells. A dot on the curve at half of K is marked as the point of fastest growth. A dashed red exponential curve follows the S-curve at first, then shoots off the top of the plot.
The growth is fastest at N=2K. There the rate is r×2K×21=4rK. For r=0.5 per hour and K=650 cells, that is about 81 cells per hour.
The exact curve
For this rule, mathematicians have found the exact answer:
N(t)=1+(N0K−1)e−rtK
Put N=2K into it, and the time to reach half of K comes out as t=rln(K/N0−1). The exact formula is a good test of the stepped program. With dt=0.1 h the two differ by a few cells near the middle. A smaller step brings them closer.
How small is small?
The step must be small compared with r1, the time over which the population changes a lot. With r=0.5 per hour, r1 is 2 hours, so 0.1 h is fine. A step close to r1 jumps too far. The count can even overshoot K, which the real population never does.
Practise with new numbers
Try it in Python
The program steps the yeast population, prints it next to the exact formula every 4 hours, and plots it with the exponential and the line N=K.
Common mistakes
Forgetting the time step.N = N + r * N * (1 - N / K) takes a step of one whole unit of time. Multiply by dt.
The brake the wrong way round.(1 - K / N) is negative for every count below K. The brake is (1 - N / K).
A step that is too large. If the count overshoots K or swings up and down, make dt smaller.
Mixing units. With r per hour, dt and t are in hours.
Stopping the loop too early. The number of steps is the total time divided by dt.
Remember these
Logistic growth: dtdN=rN(1−KN). It is nearly exponential while N is small and stops at N=K.
An Euler step: N = N + r * N * (1 - N / K) * dt, repeated round(total_time / dt) times.
The S-curve grows fastest at 2K, at a rate of 4rK.
Exact curve: N=1+(K/N0−1)e−rtK. Use it to test the stepped program, and keep dt much smaller than r1.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
A population has K=1000 cells. What is the brake 1−KN when N=900 cells, and what does it mean?
One Euler step: N=100 cells, r=0.2 per hour, K=500 cells and dt=1 h. What is the new count?
At which count does a logistic population grow fastest?
Your stepped count rises above K and then falls back. What should you change?
Why does the logistic curve look exponential at the start?
Enroll free in Growth and Populations by Computer
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.
, so the count follows an S-curve and levels off at the carrying capacity K. A loop steps the growth in small time steps; the step must be small, or the answer drifts from the exact curve.
about 30 min1 simulation1 practice question2 Python programs5 questions to check yourself
This lesson is free to read. Enroll free to keep your place and take the tests.