Skip to main content
Differential equations 3
This material has been adapted from material by Fergus Cooper and others from the "Essential Mathematics" module at the Doctoral Training Centre, University of Oxford.

This material has been adapted from material by Fergus Cooper and others from the "Essential Mathematics" module at the Doctoral Training Centre, University of Oxford.

Creative Commons License
This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1

This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1

Creative Commons License

Differential equations 3


YouTube lecture recording from October 2020

A recording of this lecture from October 2020; the material has changed a little since.
Youtube lecture thumbnail

Why steady states?

Often we don't need the full solution of a differential equation: we want to know where the system ends up, and whether it goes back there if something nudges it.
These long-run states are the steady states, and we can find them, and decide whether they are stable, without solving the equation.
In this lecture we find the steady states of models from biology and chemistry, written down using the law of mass action.

Steady-state solutions

It is often useful to find the steady state of a system described by ordinary differential equations. This occurs when all rates (i.e. derivatives) are zero.
A steady state may be stable or unstable, depending on whether or not small deviations from the steady state tend to be corrected or amplified.
We can evaluate the stability of a steady state by considering the sign of the derivative nearby.

Example 1: radioactive decay

Recall the radioactive decay equation
dNdt=−λN.\frac{dN}{dt} = -\lambda N.
We can solve it numerically, as in lecture 9:
import numpy as np from scipy.integrate import solve_ivp lam = 1.0 N0 = 1.0 t = np.linspace(0, 6, 100) def dNdt(t, N): return -lam * N solution = solve_ivp(dNdt, [0, 6], [N0], t_eval=t) N = solution.y[0]
Let us examine a plot of the solution, NN, and the gradient dN/dtdN/dt as functions of time:
Plot of N and dN/dt against t
Here the steady state occurs when N=0N=0, and is 'reached' after infinite time.
If NN moves away from 00, then dN/dt=−λNdN/dt = -\lambda N has the opposite sign to NN: negative when NN is positive, and positive when NN is negative.
So NN always moves back towards 00, and the steady state is stable.

Example 2: production and degradation of a protein

Radioactive decay only loses NN, but most quantities in biology are also produced. Consider a simple model of the production and degradation of a protein SS, with concentration s=[S]s=[S]:
→  v1  S→  v2  \xrightarrow{\;v_1\;} S \xrightarrow{\;v_2\;}
where v1v_1 and v2v_2 are the rates of production and degradation.
We can represent the change in concentration of the protein by
dsdt=v1−v2\frac{ds}{dt} = v_1 - v_2
so the steady state occurs when v1=v2v_1 = v_2.
To go further, we need to know how v1v_1 and v2v_2 depend on the concentrations.

Chemical reactions to equations: mass action

The law of mass action tells us how to write down the rates of reactions. Under the law of mass action, we assume that:
  • chemical reactions have uniform mixing
  • rates are proportional to the product of the concentrations of the reactants
  • predator/prey interactions, and epidemics, have similar rules
Let us look at some examples:
  1. A and B produce C. The reaction is governed by A meeting B:
    A+B→kCA+B\underset{k}{\rightarrow} C
    Then we get the following differential equations:
    d[A]dt=−k[A][B]d[B]dt=−k[A][B]d[C]dt=k[A][B]\begin{aligned} \frac{d[A]}{dt} &= -k[A][B] \\ \frac{d[B]}{dt} &= -k[A][B] \\ \frac{d[C]}{dt} &= k[A][B] \end{aligned}
  2. Predation of R by W
    R+W→kWR+W\underset{k}{\rightarrow} W
    Gives the following differential equation:
    dRdt=−kRW\frac{dR}{dt} = -kRW
  3. Constant production (zeroth order)
    0→kA0 \underset{k}{\rightarrow} A
    Gives the following differential equation:
    d[A]dt=k\frac{d[A]}{dt} = k
  4. Degradation/death
    C→k0C \underset{k}{\rightarrow} 0
    Gives the following differential equation:
    d[C]dt=−k[C]\frac{d[C]}{dt} = -k[C]

Steady states of reaction models

Example 2, continued: production and degradation under mass action

Back to our protein: with constant production and degradation,
→  k1  S→  k2  \xrightarrow{\;k_1\;} S \xrightarrow{\;k_2\;}
mass action gives v1=k1v_1=k_1 and v2=k2sv_2=k_2 s, so the equation is
dsdt=k1−k2s.\frac{ds}{dt} = k_1 - k_2 s.
The steady state is given by s=k1/k2s = k_1/k_2, and it is stable. Here is a plot of ds/dtds/dt against ss for k1=k2=1k_1 = k_2 = 1, so that the steady state is at s=1s = 1:
Plot of ds/dt against s, with arrows towards the steady state at s = 1
We can see that it is stable by examining the graph:
  • If we move to the left of s=1s=1, the gradient is positive, so we move back towards s=1s=1
  • If we move to the right of s=1s=1, the gradient is negative, so we, again, move back towards s=1s=1
The arrows on the ss axis show which way ss moves.
We can solve the differential equation by separation of variables:
∫1k1−k2s ds=∫dt−1k2ln⁡∣k1−k2s∣=t+ck1−k2s=Ae−k2twhere A=±e−k2cs(t)=Be−k2t+k1k2where B=−A/k2\begin{aligned} \int \frac{1}{k_1 - k_2 s}\,ds &= \int dt \\ -\frac{1}{k_2}\ln|k_1 - k_2 s| &= t + c \\ k_1 - k_2 s &= Ae^{-k_2 t} &&\text{where } A = \pm e^{-k_2c} \\ s(t) &= Be^{-k_2 t} + \frac{k_1}{k_2} &&\text{where } B = -A/k_2 \end{aligned}
If the initial concentration of SS is s0s_0, then s0=B+k1/k2s_0 = B + k_1/k_2, so B=s0−k1/k2B = s_0 - k_1/k_2 and
s(t)=s0e−k2t+k1k2(1−e−k2t)s(t) = s_0 e^{-k_2 t} + \frac{k_1}{k_2}\left(1-e^{-k_2 t}\right)
Thus, the concentration of SS relaxes exponentially to the steady state, no matter the initial condition. Here it is for k1=k2=1k_1 = k_2 = 1, from several initial concentrations:
Plot of s against t from five initial concentrations, all tending to s = 1

Example 3: positive feedback

To understand different possibilities for these steady states, let us suppose instead that SS enhances its own production (positive feedback) and the degradation rate is nonlinear.
If we were to have the following form for v1v_1 and v2v_2:
  • v1=k1sv_1=k_1 s
  • v2=k2s2v_2=k_2 s^2
then:
dsdt=k1s−k2s2\frac{ds}{dt} = k_1s - k_2 s^2
This system will be at steady state when k1s=k2s2k_1 s = k_2 s^2, i.e.
  • s=0s=0 or
  • s=k1/k2s=k_1/k_2
We can plot ds/dtds/dt versus ss to see if they are stable or unstable. Here, k1=k2=1k_1 = k_2 = 1:
Plot of ds/dt against s, with arrows away from s = 0 and towards s = 1
The local behaviour near the fixed point at s=1s=1 is the same as in the previous plot, so we can immediately see that it is a stable steady state.
The local behaviour near the fixed point at s=0s=0 is the opposite: moving one way or the other, the gradient will take ss even further away.

Non-graphical method

Let us investigate this same behaviour in a more rigorous manner.
dsdt=k1s−k2s2\frac{ds}{dt} = k_1s - k_2 s^2
When ss is small (and positive, since it is a concentration) s≫s2s\gg s^2 so the derivative k1s−k2s2k_1 s - k_2 s^2 will be positive, making s=0s=0 an unstable steady state.
For the other steady state, consider small deviations by ε\varepsilon from the steady state, e.g. s=k1/k2+εs=k_1/k_2 + \varepsilon.
Substituting s=k1/k2+εs=k_1/k_2 + \varepsilon into the equation:
dsdt=k1(k1k2+ε)−k2(k1k2+ε)2=k12k2+k1ε−k12k2−2k1ε−k2ε2=−k1ε−k2ε2\begin{aligned} \frac{ds}{dt} &= k_1\left(\frac{k_1}{k_2}+\varepsilon\right) - k_2\left(\frac{k_1}{k_2}+\varepsilon\right)^2 \\ &= \frac{k_1^2}{k_2} + k_1\varepsilon - \frac{k_1^2}{k_2} - 2k_1\varepsilon - k_2\varepsilon^2 \\ &= -k_1\varepsilon - k_2\varepsilon^2 \end{aligned}
For small ε\varepsilon, ε2\varepsilon^2 is much smaller than ε\varepsilon, so ds/dt≈−k1εds/dt \approx -k_1\varepsilon, which has the opposite sign to ε\varepsilon. So ss moves back towards the steady state, and it is stable.
The slope at a steady state
The non-graphical method works for any equation of the form ds/dt=f(s)ds/dt = f(s). Suppose s∗s^* is a steady state, so that f(s∗)=0f(s^*) = 0. Close to s∗s^*, the curve of ff is close to its tangent:
dsdt=f(s)≈f′(s∗) (s−s∗)\frac{ds}{dt} = f(s) \approx f'(s^*)\,(s - s^*)
If f′(s∗)<0f'(s^*) < 0, then ds/dtds/dt has the opposite sign to s−s∗s - s^*, so ss moves back: the steady state is stable. If f′(s∗)>0f'(s^*) > 0, then ss moves away: it is unstable.
For example, for positive feedback, f′(s)=k1−2k2sf'(s) = k_1 - 2k_2 s, so f′(0)=k1>0f'(0) = k_1 > 0 (unstable) and f′(k1/k2)=−k1<0f'(k_1/k_2) = -k_1 < 0 (stable).

Example 4: the logistic equation

The growth of a cell colony can be modelled by the logistic equation
dNdt=rN(1−NK)\frac{dN}{dt} = rN\left(1 - \frac{N}{K}\right)
where N(t)N(t) is the number of cells at time tt, and rr and KK are constant parameters (both positive).
Try finding the steady states of the logistic equation, and deciding whether each one is stable, before reading on.
The steady state for the system, or equilibrium population size, occurs when the growth rate is zero, i.e.
dNdt=0⇒rN=rKN2⇒N=0 or N=K.\frac{dN}{dt} = 0 \quad\Rightarrow\quad rN = \frac{r}{K}N^2 \quad\Rightarrow\quad N = 0 \text{ or } N = K.
This is positive feedback with k1=rk_1 = r and k2=r/Kk_2 = r/K: the same equation as the growing leaf in lecture 10, and the logistic model of lecture 3.
Here is a plot, for r=K=1r=K=1:
Plot of dN/dt against N, with arrows away from N = 0 and towards N = K
For small positive NN, rN>0rN>0 and N<KN<K so dN/dt>0dN/dt>0 and the population size will increase, meaning that N=0N=0 is an unstable steady state.
In fact the growth rate is positive for 0<N<K0<N<K and negative for N>KN>K, making N=KN=K a stable steady state.
We can solve the differential equation to examine the transient behaviour, that is, how the population approaches KK. It is lecture 10's leaf equation with k1=rk_1 = r and k2=r/Kk_2 = r/K, so the same partial fractions give
N=rert+d1+(r/K)ert+dN = \frac{r e^{rt+d}}{1 + (r/K)e^{rt+d}}
where ed=N0/(r−rN0/K)e^d = N_0/(r - rN_0/K), from the initial condition N(0)=N0N(0)=N_0. Simplifying,
N(t)=KN0ertK+N0(ert−1).N(t) = \frac{K N_0 e^{rt}}{K + N_0(e^{rt}-1)}.
Here it is for r=K=1r=K=1, from initial population sizes below and above KK:
Plot of N against t from four initial population sizes, all tending to N = K

Solving numerically: a recap

In lecture 9 we solved dy/dt=f(t,y)dy/dt = f(t, y) numerically with Euler's method. From y0y_0 at t0t_0, we take steps of size hh along the tangent:
yn+1=yn+h f(tn,yn)y_{n+1} = y_n + h\,f(t_n, y_n)
The smaller the step, the more accurate the answer, but the more steps we need. Introductory problem 2 below works through Euler's method by hand and in Python.
In practice we use SciPy's solve_ivp, as we have throughout these lectures, which uses a more sophisticated method and chooses the step size for us.

Summary of first order differential equations

To solve a differential equation:
  1. Calculate the general solution: try to write it as a separable equation first. Other methods exist, such as integrating factors (see Extension problems 2).
  2. The general solution includes an arbitrary constant, which we can find from the initial condition (if we are given one).
  3. Check the solution numerically with Python, or solve numerically if we can't solve by hand.
To find steady state (equilibrium) solutions, find points where all (first) derivatives are zero.
To determine the stability of these steady states, look at the sign of the first derivative in the vicinity of the steady state. You can sketch the first derivative, or use Python to help with this.

Introductory problems

For more practice, an AI tool can write new problems like the ones below. Ask it for problems of the same type and difficulty, or for problems set in your own field. For example, you could ask it to "write five biochemistry problems on steady states and their stability, at the level of these ones". Work them on paper first, then ask the tool to check your answers and to explain any step you are unsure of.

Introductory problems 1

Determine the steady states and their stabilities, for each of the following:
  1. dx/dt=x(a−x)dx/dt = x(a-x), where aa is a positive constant
  2. dx/dt=x2−4x+3dx/dt = x^{2}-4x+3
  3. dx/dt=ex(x2−1)dx/dt = e^{x}(x^{2}-1)
  4. dN/dt=r0N(1−N/K)dN/dt = r_{0}N\left(1-N/K\right), where r0<0r_{0}<0 and r0r_{0}, KK are constants
  5. dx/dt=Ax/(h+x)dx/dt = Ax/(h+x), where AA and hh are negative constants

Introductory problems 2

Consider the differential equation
dydt=−2ywithy(0)=1.\frac{dy}{dt} = -2y \quad\text{with}\quad y(0) = 1.
  1. Solve the equation exactly, by separation of variables.
  2. Use Euler's method by hand, with a step size of δt=0.1\delta t = 0.1, to estimate y(0.1)y(0.1), y(0.2)y(0.2) and y(0.3)y(0.3). Compare your estimate of y(0.3)y(0.3) with the exact value.
  3. Write a Python function that uses Euler's method to estimate y(1)y(1). Find the error in your estimate for δt=0.1\delta t = 0.1 and for δt=0.05\delta t = 0.05. What happens to the error when the step size is halved?

Main problems

Main problems 1

Not all chemical systems relax exponentially to steady state. Consider the bimolecular decay reaction
A+A⟶kA + A \stackrel{k}{\longrightarrow}
Assuming kk is a mass action constant, form and solve a differential equation representing the change in concentration of AA.
If a(0)=a0a(0)=a_0 you should get
a(t)=12kt+1a0.a(t) = \frac{1}{2kt + \frac{1}{a_0}}.

Main problems 2

The SISSIS model is an appropriate model for diseases that mutate quickly and can therefore infect people multiple times, such as the common cold or sexually transmitted infections like gonorrhea and chlamydia.
In the model, individuals are 'susceptible' until they are 'infected', and then they return to being 'susceptible' again. Infection requires the interaction of susceptible individuals with infected individuals and therefore follows the law of mass action, whereas the rate at which an individual becomes susceptible again after infection is constant.
  1. Let SS and II be the proportions of the population that are susceptible and infected. If infection happens at rate β\beta and recovery happens at rate γ\gamma, write down differential equations for SS and II.
  2. Noting that SS and II are proportions of the population, which is assumed constant, reduce the system to a single differential equation in terms of II. In other words, write down a single equation, involving just II and its derivative.
  3. Find both steady states of II. Under what conditions on β\beta and γ\gamma are each attainable?
  4. Without solving the differential equation, sketch the behaviour of SS and II over time, starting with a small quantity of infected individuals. Illustrate how both steady states may be achieved.

Main problems 3

Consider a closed reaction system consisting of a single reversible reaction:
A⇌kfkbBA \underset{k_b}{\overset{k_f}{\rightleftharpoons}} B
where kfk_f and kbk_b are mass action coefficients.
  1. Formulate a pair of coupled differential equations for the change in concentration of AA and BB.
  2. Noting that the total concentration TT of reactants is constant (T=[A]+[B]T = [A] + [B]), reduce the system of equations to a single differential equation. In other words, write down a single equation, involving either just AA and its derivative, or just BB and its derivative.
  3. Find the steady-state concentrations of AA and BB.
  4. Solve the single differential equation to reveal the transient behaviour. Sketch the behaviour for different illustrative initial conditions.

Main problems 4

Consider the simple model
dsdt=k−VmaxsKM+s\frac{ds}{dt} = k - \frac{V_{\text{max}}s}{K_M + s}
in which species ss is produced at a fixed rate and consumed via Michaelis-Menten kinetics. Find the steady state of ss, and verify that it is stable for any non-negative parameter values, provided Vmax>kV_{\text{max}} > k.

Main problems 5

Recall the simple model of the production and degradation of a protein from the lecture, shown by the reaction chain
⟶v1S⟶v2\overset{v_1}{\longrightarrow} S \overset{v_2}{\longrightarrow}
where v1v_1 and v2v_2 are reaction rates rather than mass action coefficients.
  1. Suppose v1=k1v_1 = k_1 and v2=k2sv_2 = k_2s, as in the lecture. Write down a differential equation describing the rate of change of S, and find the steady state concentration of S in terms of the two parameters k1k_1 and k2k_2 (i.e. the concentration at which the rate of change is zero). At what rate is S being produced in steady state?
  2. Now suppose that
    v1=k0+k1s2k2+s2andv2=k3sv_1 = k_0 + \frac{k_1 s^2}{k_2+s^2} \quad\text{and}\quad v_2 = k_3 s
    and take the parameter values to be k0=6/11k_0=6/11, k1=60/11k_1=60/11, k2=11k_2=11, k3=1k_3=1. Determine the number of steady states and the type of each.

Extension problems

Extension problems 1

Various mathematical models have been proposed for the initial growth of solid tumours, and some are summarised in The Model Muddle: In Search of Tumor Growth Laws. They are differential equations describing the rate of change of tumour volume VV as a function of time tt, for example:
  1. dV(t)/dt=rV(t)dV(t)/dt = rV(t)
  2. dV(t)/dt=rV(t)bdV(t)/dt = rV(t)^b
  3. dV(t)/dt=r0e−ρtV(t)dV(t)/dt = r_0 e^{-\rho t}V(t)
Solve each equation both analytically and numerically, using Python. As was done in Figure 1A in the paper, compare the behaviours of the different growth laws over a suitable time interval for an initially small tumour, again using Python. With VV in mm3^3 and tt in days, take V(0)=1V(0) = 1, r=0.1r = 0.1, b=2/3b = 2/3, r0=0.1r_0 = 0.1 and ρ=0.02\rho = 0.02, and compare the laws over the first 100 days.

Extension problems 2

The lecture does not cover integrating factors, so here is the method. If an equation can be written in the form
dydx+P(x) y=Q(x)\frac{dy}{dx} + P(x)\,y = Q(x)
multiply both sides by the integrating factor I(x)=e∫P(x) dxI(x) = e^{\int P(x)\,dx}. Because dI/dx=P(x) I(x)dI/dx = P(x)\,I(x), the product rule shows that the left-hand side becomes ddx(I(x) y)\frac{d}{dx}\left(I(x)\,y\right), so
I(x) y=∫I(x) Q(x) dxI(x)\,y = \int I(x)\,Q(x)\,dx
Find the solution to the following differential equations subject to the specified boundary conditions, using integrating factors:
  1. dy/dx+y/x=0withy(2)=2forx>0dy/dx + y/x = 0 \quad\text{with}\quad y(2)=2 \quad\text{for}\quad x>0
  2. dy/dx+(2x−1)y=0withy(1)=2dy/dx + (2x-1)y = 0 \quad\text{with}\quad y(1)=2
  3. x3 dy/dx+2y=e1/x2withy(1)=ex^3\,dy/dx + 2y = e^{1/x^2} \quad\text{with}\quad y(1)=e
  4. sec⁡(x) dy/dx+y=1withy(0)=1\sec(x)\,dy/dx + y = 1 \quad\text{with}\quad y(0) = 1
  5. dy/dx+ytan⁡(x)=cos⁡(x)withy(0)=1for0≤x<π/2dy/dx + y\tan(x) = \cos(x) \quad\text{with}\quad y(0)=1 \quad\text{for}\quad 0 \le x < \pi/2

Extension problems 3

Consider the second order differential equation
d2ydx2+y=0\frac{d^2y}{dx^2} + y = 0
Show that y=Aez1x+Bez2xy = Ae^{z_1 x} + Be^{z_2 x} is a solution to this equation for some complex numbers z1z_1, z2z_2 and constants AA, BB (which may also be complex).
  1. Recalling that any complex number zz can be written as z=reiθ=r(cos⁡θ+isin⁡θ)z = re^{i\theta} = r(\cos\theta + i\sin\theta), what does this tell you about the nature of the solution?
  2. If y(0)=1y(0)=1 and y(π/2)=2y(\pi/2)=2 what is the particular solution of the differential equation?