Antibiotic Resistance Evolution, Explained

After reading this you will be able to predict when a resistant strain takes over a bacterial population, work out the math behind selection, and see exactly why stopping a course early is what breeds resistance.

What the simulator shows

Picture a dish with one million bacterial cells. Almost all of them are susceptible to a given antibiotic. A tiny fraction, say 1 in 1,000,000, already carries a mutation that makes it resistant. That mutation costs the cell something: it divides a little slower than its susceptible neighbours because building the resistance machinery uses resources.

With no drug present, the slower resistant cells stay rare. The susceptible majority out-grows them and keeps them near their starting frequency. Add the antibiotic and the picture flips. Susceptible cells die back fast. The resistant few survive and now face far less competition for space and nutrients, so they multiply into the gap. Within a handful of generations they can go from 0.0001% of the dish to more than 90%.

The drug did not create the resistance. The mutations were already there. The drug removed the competition, and natural selection did the rest, in fast-forward.

When this model helps, and when it does not

Use the simulator to build intuition about selection pressure: why a full dose that clears the susceptible population behaves so differently from a half dose that only trims it. It is a teaching model of one dish, one drug, one mutation.

It is not a clinical predictor. Real infections span multiple body compartments, immune responses, mixed strains, and drugs with complex pharmacokinetics. This model assumes well-mixed cells, constant conditions, and a single resistance locus. Treat the numbers as illustrations of a mechanism, not as forecasts for any real patient.

This is an educational estimate, not medical advice. Decisions about your own antibiotics belong with a professional. The simulator exists to explain why the standard advice, to finish a prescribed course as directed, has an evolutionary logic behind it.

The math of selection

Each generation, every cell type grows by its own factor. Call the susceptible growth factor w_s and the resistant growth factor w_r per generation. If N_s and N_r are the cell counts, then after one generation:

N_s' = w_s \cdot N_s, \quad N_r' = w_r \cdot N_r

Here N_s' and N_r' are the next-generation counts. The growth factors depend on whether the drug is present.

Without drug, both types roughly double, but the resistant type pays a fitness cost c. So w_s = 2 and w_r = 2(1 - c). With c = 0.1, resistant cells reach w_r = 1.8 per generation.

Add a drug at a dose that kills a fraction k of susceptible cells. Now the susceptible factor becomes w_s = 2(1 - k) while resistant cells still grow at w_r = 2(1 - c). The quantity that decides who wins is the ratio:

s = \frac{w_r}{w_s} = \frac{2(1 - c)}{2(1 - k)} = \frac{1 - c}{1 - k}

s is the per-generation selection coefficient in favour of resistance. When s \gt 1, resistance gains ground each generation. When s \lt 1, resistance loses ground. The resistant frequency after t generations follows the logistic form:

f_t = \frac{f_0 \cdot s^t}{1 - f_0 + f_0 \cdot s^t}

f_0 is the starting resistant frequency and f_t is the frequency after t generations. Both stay between 0 and 1 because the denominator grows with the numerator.

A worked example with the demo data

Run the demo defaults: starting frequency f_0 = 10^{-6}, fitness cost c = 0.1, and compare two doses. A full dose kills k = 0.99 of susceptible cells per generation. An under-dose kills only k = 0.5.

Full dose versus half dose

  1. Full dose selection coefficient: s = (1 - 0.1)/(1 - 0.99) = 0.9/0.01 = 90. Resistance multiplies its relative share 90-fold per generation.
  2. Half dose selection coefficient: s = (1 - 0.1)/(1 - 0.5) = 0.9/0.5 = 1.8. Resistance still gains, but only 1.8-fold per generation.
  3. Full dose, generations to reach 50% resistant: solve s^t \approx 1/f_0 = 10^6. With s = 90, t = \log(10^6)/\log(90) \approx 13.8/4.5 = 3.07. Roughly 3 generations.
  4. Half dose, generations to reach 50%: with s = 1.8, t = 13.8/0.588 \approx 23.5. Roughly 23 generations.

The full dose crashes the total population so fast that the immune system or a completed course clears the survivors before they rebound. The half dose leaves a large surviving susceptible pool that keeps the total high while resistance climbs steadily underneath. That slow climb across many generations is where a resistant strain gets time to establish.

The point is subtle. A high dose selects harder for resistance per generation, but it also ends the whole episode in a few generations. A weak dose selects more gently yet keeps the door open for many generations. Under-treatment loses because of duration, not because it applies gentle pressure.

With a half dose the resistant fraction stays near zero for about 12 generations, then rises sharply through generation 24 and saturates near 1. The long flat start is the dangerous window when resistance is invisible but building.

Reading the results

Watch three things as a run plays out.

Total population
Under a full dose this drops fast. If it reaches zero before resistant cells recover, the infection is cleared. Under a weak dose it stays high, which is the warning sign.
Resistant fraction
This is f_t. It can be tiny while the total falls, then explode once the susceptible cells are gone and the resistant cells stop competing.
Crossover generation
The generation where resistant cells first outnumber susceptible ones. Past this point the drug is largely useless against what remains.

Compare a completed course against an interrupted one at the same dose. Stop the drug at generation 5 and the susceptible population rebounds alongside any resistant cells, so the resistant fraction stays low. Stop at the wrong moment, after susceptibles are thinned but not cleared, and the resistant survivors inherit an empty dish.

Common mistakes

Three misreadings come up often.

Believing the drug causes the mutation. It does not. Set the mutation rate to zero and start with zero resistant cells: no dose, however strong, produces resistance. The mutations must already exist for selection to act on them.

Reading a low resistant fraction as safety. During the flat early phase in the chart above, the resistant fraction sits below 0.001 for a dozen generations. That looks harmless. It is the incubation period for the takeover that follows.

Assuming a stronger dose is always worse for resistance. A stronger dose selects harder per generation, but by ending the episode in about 3 generations instead of 23 it gives resistance far fewer chances to grow in absolute numbers. Duration usually matters more than per-generation pressure.

Without JavaScript: use the formula f_t = f_0 s^t / (1 - f_0 + f_0 s^t) with s = (1-c)/(1-k). At f_0 = 10^{-6}, c = 0.1: a full dose (k = 0.99, s = 90) reaches 50% resistant in about 3 generations; a half dose (k = 0.5, s = 1.8) takes about 23 generations.

Related tools on this site

Resistance evolution sits next to several other quantitative health models. To see how a drug concentration rises and falls between doses, which sets the real-world kill fraction, use the Drug Half-Life & Dosing Simulator. To convert a prescribed mg/kg dose into a volume, see the Dose & Rate Converter. For the population-level cousin of this idea, where enough immunity stops transmission for everyone, try the Herd Immunity Threshold Explorer.

Frequently asked questions

Does taking antibiotics cause resistance?

Not directly. The resistant mutations arise randomly whether or not you take the drug. What antibiotics do is remove susceptible competitors, giving any existing resistant cells room to multiply. Set the mutation rate to zero in the model and no amount of drug produces resistance.

Why finish the course if I feel better?

Feeling better means the susceptible population has been thinned enough that symptoms fade. Resistant survivors and remaining susceptibles can still be present. Stopping at that point, before the population is cleared, is close to the worst case: it removes competition without removing the resistant cells, so they rebound. In the worked example, stopping the half dose at generation 20 leaves the resistant fraction climbing toward 1.

Why can a stronger dose be safer against resistance?

A stronger dose raises the per-generation selection coefficient, which sounds bad, but it clears the whole population in about 3 generations instead of 23. Fewer generations means the resistant cells have fewer chances to grow in absolute number before the episode ends.

What is the fitness cost, and why does it matter?

Resistance usually slows growth because the cell diverts resources into resistance machinery. In the model this is the cost c. A higher cost, say c = 0.3, makes resistant cells lose ground faster once the drug is gone, which is why resistant strains can fade in a population that stops using a drug.

Is this simulation accurate for real infections?

No. It is a single well-mixed dish with one drug and one mutation. Real infections involve immune clearance, multiple sites, mixed strains, and changing drug levels. Use it to understand the mechanism of selection, not to plan treatment.