Chapter A1 — How fast does an infection grow?¶
Start with a story¶
Imagine a single bacterium lands on a warm, nutrient-rich surface — say, an uncleaned kitchen counter. Under good conditions some bacteria can split in two about once an hour. One becomes two, two become four, four become eight.
This feels harmless at first. After three hours there are only eight cells; you’d never notice them. But this kind of growth has a sting in its tail, and seeing why is the whole point of this chapter.
Let’s define our one new term before we go further.
From the story to a formula¶
If we start with cells and the population doubles every hour, then after hours the number of cells is:
That’s it — no calculus, just repeated multiplication. The “2” is the doubling factor and the “” (the exponent) is how many hours have passed. Equation (1) is the engine behind everything below.
Watch it happen in code¶
Let’s start one cell and let it double every hour for half a day. We’ll build the list of hourly counts with a simple loop.
N0 = 1 # we start with a single cell
hours = 12 # simulate half a day
counts = [N0]
for hour in range(1, hours + 1):
counts.append(counts[-1] * 2) # the population doubles each hour
print(f"Hour 0: {counts[0]:>10,} cells")
print(f"Hour {hours}: {counts[-1]:>10,} cells")Hour 0: 1 cells
Hour 12: 4,096 cells
One cell became thousands in half a day. Notice how little happened in the first few hours and how much happened in the last few — that’s the signature of exponential growth. Let’s make that visible.
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(6, 4))
ax.plot(range(hours + 1), counts, marker="o", color="#c0392b")
ax.set_xlabel("Time (hours)")
ax.set_ylabel("Number of cells")
ax.set_title("One cell, doubling every hour")
fig

The curve in Notebook-code is nearly flat, then shoots upward. This is why an infection (or a viral video, or compound interest) can seem like “nothing is happening” right up until it’s everywhere. The early small numbers hid how fast the rate was building.
Exercise¶
Solution
Doubling and then halving multiplies the count by 2 × 0.5 = 1, so the population
stays flat:
N0 = 1000
counts = [N0]
for hour in range(1, 13):
counts.append(counts[-1] * 2 * 0.5) # double, then lose half
print(counts[-1]) # → 1000.0, unchangedIn one sentence: when the kill rate exactly matches the growth rate, the infection neither grows nor shrinks — and a slightly stronger drug (say, killing 60% per hour) would tip the balance toward shrinking.
## Key takeaways
```{admonition} Key takeaways
:class: note
- **Exponential growth** multiplies by a fixed factor each step; small beginnings
explode surprisingly fast.
- The model is just $N(t) = N_0 \times 2^{t}$ — repeated multiplication, no
advanced math.
- A loop in a few lines of Python reproduces and visualizes the whole story.
- Whether a population grows or shrinks depends on the *balance* of competing
rates (growth vs. death) — a theme we'll meet again throughout the book.