Mathsy Coding

A Quick Look At Exponential Growth

A quick look at exponential growth
Edits:
  • : Changing image and file paths

Since exponential growth has been so much in the news lately, let’s take a quick look at it!

Continuous Case

Exponential growth refers to the case where a population of something (birds, diseased people, radioactive particles of some sort) changes at a rate that is strictly proportional to how many of that thing there already are. For instance, in the case of bacteria, a single bacterium may split once a day. Then at the initial point in time there will be just one bacterium; the next day there will be two (increased by 1 bacterium / day); the day after there will be 4 (an increase of 2 bacteria / day) and so on and so forth. In this case the constant of proportionality was one (the rate was the same as the population), but in general there’s no reason that that needs to be the case. We can express this mathematically, for a population PP evolving with a constant of proportionality kk over time tt as

dPdt=kP(t)\frac{dP}{dt} = k P(t)

Using separation of variables and assuming that P(0)=P0P(0) = P_0, we can find a closed-form solution:

dPdt=kP(t)1P(t)dP=kdtlnP(t)=kt+CP(t)=ekt+C(Assuming P(t) > 0)=eCekt=AektP0=Aek0P0=AP(t)=P0ekt\begin{align*} \frac{dP}{dt} &= k P(t) \\ \int \frac{1}{P(t)} dP &= \int k dt \\ \ln |P(t)| &= kt + C \\ P(t) &= e ^ {kt + C} \qquad \text{(Assuming P(t) > 0)} \\ &= e^C e^{kt} \\ &= A e^{kt} \\ P_0 &= A e^ {k \ast 0} \\ P_0 &= A \\ \therefore P(t) &= P_0 e ^ {kt} \end{align*}

Discrete Case

This is the solution for a population evolving continuously. However, we may want to consider the case where the population is either evolving discretely or where we can imagine that it does. For instance, our initial example with the bacteria could be better modelled via a discrete process where at a time tt, the population Pt=kPt1P_t = kP_{t - 1}. In this case, our closed-form solution for a given time step tt where the initial population is P0P_0 is P(t)=P0ktP(t) = P_0 k ^ t. Let’s prove this inductively:

Base case: t=0t = 0. Then P0=P0k0=P0P_0 = P_0 k ^ 0 = P_0, as predicted.

Induction step: Let’s say that this holds for time t1t - 1. Then Pt=kPt1=k(P0kt1)=P0ktP_t = k P_{t - 1} = k \left( P_0 k^{t - 1} \right) = P_0 k^t.

So that proves it then!

Converting Between Them

Now let’s take a look at how we can switch back and forth between these models. One case where we might want to do this if if the population if changing continuously, but we can only sample it discretely - for instance, we might only be able to check the population size once a year. Our data are discrete, even though the underlying phenomenon isn’t. If we do this, we’ll find a (discrete) kdk_d, but we want to convert it to a continuous kck_c. It turns out that doing so isn’t too difficult:

Pt+1=kdPtPt+1Pt=kdP0ekc(t+1)P0ekct=kdP0ekctekcP0ekct=kdekc=kdkc=lnkd\begin{align*} P_{t + 1} &= k_d P_t \\ \frac{P_{t + 1}}{P_t} &= k_d \\ \frac{P_0 e^{k_c(t + 1)}}{P_0 e^{k_c t}} &= k_d \\ \frac{P_0 e ^{k_c t} e^{ k_c }}{P_0 e^{ k_c t }} &= k_d \\ e^{k_c} &= k_d \\ k_c &= \ln k_d \end{align*}

Now let’s double-check our math graphically. Let’s say we check a population of mice once a year, and find that each year the population is twice that of the previous year. That means that kd=2k_d = 2, and so kc=ln20.693k_c = \ln 2 \approx 0.693\dots. If we plot the population growing discretely with kd=2k_d = 2 and continuously with kc=ln2k_c = \ln 2, we should find that the plots coincide. Plotting was done using MatPlotLib.

Continuous and Discrete Exponential Growth

import math
import numpy as np
import matplotlib.pyplot as plt

k_disc = 2
k_cont = math.log(k_disc)

continuous_xs = np.linspace(0, 5, 1000)
continuous_ys = [math.exp(k_cont * x) for x in continuous_xs]

discrete_xs = range(0, 5 + 1)
discrete_ys = [k_disc ** x for x in discrete_xs]

fig, ax = plt.subplots()
plt.title("Discrete and Continuous Exponential Growth")
plt.xlabel("Time (years)")
plt.ylabel("Population")
ax.plot(continuous_xs, continuous_ys, "g-", label="Continuous")
ax.plot(discrete_xs, discrete_ys, "ro", label="Discrete")
ax.legend()
plt.savefig("exponentials")

Just by looking at it, we can see that we were bang on!