Skip to main content

Scientific Computing

Essential Maths

Differential ... []

Scientific Computing

Essential Maths

Systems of di... []

This material has been adapted from material by Fergus Cooper from the "Essential Mathematics" module of the SABS R³ Center for Doctoral Training.

This material has been adapted from material by Fergus Cooper from the "Essential Mathematics" module of the SABS R³ Center for Doctoral Training.

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

Steady State Solutions and Mass Action


YouTube lecture recording from October 2020

The following YouTube video was recorded for the 2020 iteration of the course. The material is still very similar:

Youtube lecture thumbnail


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.\displaystyle \frac{{\rm d}N}{{\rm d}t} = -\lambda N.

Let us examine a plot of the solution, NN, and the gradient dNdt\displaystyle \frac{{\rm d}N}{{\rm d}t} as functions of time:

Plot of N vs dNdT

  • Here the steady state occurs when N=0N=0, and is 'reached' after infinite time.

  • For small positive NN the derivative   dNdt  \;\displaystyle \frac{{\rm d}N}{{\rm d}t}\; is negative, moving the system towards the steady state.

  • Physical considerations show that negative NN is impossible, hence the steady state is stable as we would expect.

Example 2: production and degradation of a protein

Consider a simple model of the production and degradation of a protein, shown by the reaction chain     v1Sv2    \;\;\overset{v_1}{\rightarrow}S\overset{v_2}{\rightarrow}\;\; where   v1  \;v_1\; and   v2  \;v_2\; are reaction rates, and let   s=[S]\;s=[S].

We can represent the change in concentration of the protein by

dsdt=v1v2\displaystyle \frac{{\rm d}s}{{\rm d}t} = v_1 - v_2

so the steady state occurs when   v1=v2\;v_1 = v_2.

Mass action

Consider, again, the reaction chain:

    v1Sv2    \displaystyle \;\;\overset{v_1}{\rightarrow}S\overset{v_2}{\rightarrow}\;\;

Suppose the reaction is governed by "mass action" kinetics, so   v1=k1  \;v_1=k_1\; (constant) and   v2=k2s\;v_2=k_2 s.

The equation is then

dsdt=k1k2s.\displaystyle \frac{{\rm d}s}{{\rm d}t} = k_1 - k_2 s.

The steady state is given by s=k1/k2s = k_1/k_2, and it is stable:

Plot illustrating the linear steady state

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


We can solve the differential equation by separation of variables.

1k1k2s ds= dt\displaystyle \int {1\over k_1 - k_2 s}~{\rm d}s = \int~{\rm d}t s(t)=Bek2t+k1k2\displaystyle s(t) = Be^{-k_2 t} + {k_1\over k_2}

Thus, the concentration of SS relaxes exponentially to the steady state, no matter the initial condition.

If the initial concentration of SS is given by s0s_0 then

s(t)=s0ek2t+k1k2(1ek2t)\displaystyle s(t) = s_0 e^{-k_2 t} + {k_1\over k_2}\left(1-e^{-k_2 t}\right)


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=k1sk2s2\displaystyle \frac{{\rm d}s}{{\rm d}t} = k_1s - k_2 s^2

This system will be at steady state when k1s=k2s2\displaystyle k_1 s = k_2 s^2, i.e.

  • s=0s=0 or

  • s=k1/k2s=k_1/k_2

We can plot   dsdt  \;\displaystyle \frac{{\rm d}s}{{\rm d}t}\; versus   s  \;s\; to see if they are stable or unstable. Here, k1=k2=1k_1 = k_2 = 1:

Plot illustrating the quadratic steady state

  • The local behaviour near the fixed point as 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=k1sk2s2\displaystyle \frac{{\rm d}s}{{\rm d}t} = k_1s - k_2 s^2

  • When ss is small (and positive, since it is a concentration) ss2s\gg s^2 so the derivative k1sk2s2k_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.

Then:

s2=k12k22+2εk1k2+ε2  \displaystyle s^2=\frac{k_1^2}{k_2^2} + 2 \varepsilon\frac{k_1}{k_2} + \varepsilon^2\;

The derivative (after substituting ss and s2s^2 into the original differential equation) is:

dsdt=k1εk2ε2\displaystyle \frac{{\rm d}s}{{\rm d}t} = - k_1\varepsilon - k_2\varepsilon^2.

It is, since εε2\varepsilon\gg\varepsilon^2, negative, pushing ss back towards the steady state, hence it is a stable steady state.

Example: the logistic equation

The growth of a cell colony can be modelled by the logistic equation

dNdt=rN(1NK)\displaystyle \frac{{\rm d}N}{{\rm d}t} = rN\left(1 - {N\over K}\right)

where   N(t)  \displaystyle \;N(t)\; is the number of cells at time   t,  \;t,\; and   r  \;r\; and   K  \;K\; are constant parameters (both positive).

The steady state for the system, or equilibrium population size, occurs when the growth rate is zero, i.e.

dNdt=0rN=rKN2N=0 or N=K.\displaystyle \frac{{\rm d}N}{{\rm d}t} = 0 \quad\Rightarrow\quad rN = {r\over K}N^2 \quad\Rightarrow\quad N = 0 {\rm~or~} N = K.

Here is a plot, for r=K=1r=K=1:

Plot illustrating the steady states of the logistic equation

  • for small positive NN, rN>0rN>0 and N<KN<K so dNdt>0\displaystyle \frac{{\rm d}N}{{\rm d}t}>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. This is a separable equation, so

1rKNrN2 dN=1K dt\int {1\over rKN-rN^2}~{\rm d}N = \int {1\over K}~{\rm d}t

This can be solved using partial fractions on the left hand side:

  • With initial conditions N(0)=N0N(0)=N_0 you get

    N(t)=KN0ertK+N0(ert1)\displaystyle N(t) = {K N_0 e^{rt}\over K + N_0(e^{rt}-1)}

Summary of first order differential equations

To solve a differential equation:

  1. Calculate the general solution

    1. Try to write it as a separable equation first

    2. Other methods (e.g. integrating factors) not covered in this course

  2. This general solution will include an arbitrary constant this may be eliminated using initial conditions (if these are given)

  3. Can check your solution numerically using Python

To find steady state (equilibrium) solutions, find points where all (first) derivatives are zero.

To determine stability of these steady states, look at the behaviour of the first derivative in the vicinity of the steady state. You can sketch the first derivative, or use Python to help with this.


Chemical reactions to equations: mass action

Under the law of mass action, we assume the following:

  • that chemical reactions have uniform mixing

  • that rates are proportional to the product of the masses of the reactants

  • that 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+BkC\displaystyle A+B\underset{^k}{\rightarrow} C

    Then we get the following differential equations:

    d[A]dt=k[A][B]\displaystyle \frac{{\rm d}[A]}{{\rm d}t} = -k[A] [B] > d[B]dt=k[A][B]\displaystyle \frac{{\rm d}[B]}{{\rm d}t} = -k[A] [B] > d[C]dt=k[A][B]\displaystyle \frac{{\rm d}[C]}{{\rm d}t} = k[A] [B]

  2. Predation of R by W

    R+WkW\displaystyle R+W\underset{^k}{\rightarrow} W

    Gives the following differential equation:

    dRdt=kRW\displaystyle \frac{{\rm d}R}{{\rm d}t} = -kRW

  3. Constant production (zeroth order)

    0kA\displaystyle 0 \underset{^k}{\rightarrow} A

    Gives the following differential equation:

    d[A]dt=k\displaystyle \frac{{\rm d}[A]}{{\rm d}t} = k

  4. Degradation/death

    Ck0\displaystyle C \underset{^k}{\rightarrow} 0

    Gives the following differential equation:

    d[C]dt=k[C]\displaystyle \frac{{\rm d}[C]}{{\rm d}t} = -k[C]

Numerically solving differential equations

What if we can't solve the differential equation (or don't want to)?

dydt=sin(yln(tcos(y))1+y/et)+3\displaystyle \frac{{\rm d}y}{{\rm d}t} = \sin\left(\frac{y\ln(t\cos(y))}{\sqrt{1+y/e^t}}\right) + 3

Euler's method

Given a differential equation

dydt=f(y,t)\displaystyle \frac{{\rm d}y}{{\rm d}t} = f(y, t)

with initial state   y(t=t0)=y0,  \;y(t = t_0) = y_0,\; we can approximate the state at t=t0+δtt = t_0 + \delta{t} as:

y1=y(t+δt)y0+f(y,t)δt\displaystyle y_1 = y(t + \delta{t}) \approx y_0 + f(y, t) \cdot \delta{t}

and the next state as

y2=y(t+2δt)y1+f(y,t)δt\displaystyle y_2 = y(t + 2\delta{t}) \approx y_1 + f(y, t) \cdot \delta{t}

and so on!

This mean's we can estimate the entire time course of y(t)y(t), provided:

  1. We can calculate f(y,t)f(y, t) (or approximate it with a computer)

  2. We're patient enough to take really tiny steps δt\delta{t}

We have already seen examples of this, using SciPy's ODEInt function, although this uses more sophisticated methods than the one described here.

Introductory problems

Introductory problems 1

Determine the steady states are their stabilities, for each of the following:

  1. dxdt=x(ax)\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{x}{t} = x(a-x), where aa is a positive constant

  2. dxdt=x24x+3\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{x}{t} = x^{2}-4x+3

  3. dxdt=ex(x21)\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{x}{t} = e^{x}(x^{2}-1)

  4. dNdt=r0N(1NK)\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{N}{t} = \displaystyle r_{0}N\left(1-\frac{N}{K}\right), where r0<0r_{0}<0 and r0,  Kr_{0},\;K are constants

  5. dxdt=Axh+x\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{x}{t} = \displaystyle \frac{Ax}{h+x}, where AA and hh are negative constants

Main problems

Main problems 1

Not all chemical systems relax exponentially to steady state. Consider the bimolecular decay reaction

A+Ak\displaystyle A + 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.\displaystyle \quad 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:

AkfkbBA \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=kVmaxsKM+s\def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{s}{t} = k - {V_{\rm max}s\over 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>k\displaystyle V_{\rm 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

v1Sv2\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=k2v_2 = k_2. 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 + {k_1 s^2\over k_2+s^2} \quad\text{and}\quad v_2 = k_3 s
    and take the parameter values to be k0=6/11,  k1=60/11,  k2=11,  k3=1\displaystyle k_0=6/11,\;k_1=60/11,\;k_2=11,\;k_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)\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{V(t)}{t} = rV(t)

  2. dV(t)dt=rV(t)b\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{V(t)}{t} = rV(t)^b

  3. dV(t)dt=r0eρtV(t)\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{V(t)}{t} = 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.

Extension problems 2

Find the solution to the following differential equations subject to the specified boundary conditions, using integrating factors:

  1. dydx+yx=0withy(2)=2forx>0\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{y}{x} + {y\over x} = 0 \quad\text{with}\quad y(2)=2 \quad\text{for}\quad x>0

  2. dydx+(2x1)y=0withy(1)=2\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{y}{x} + (2x-1)y = 0 \quad\text{with}\quad y(1)=2

  3. x3dydx+2y=e1/x2withy(1)=e\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} x^3\,\dd{y}{x} + 2y = e^{1/x^2} \quad\text{with}\quad y(1)=e

  4. sec(x)dydx+y=1withy(0)=1\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \sec(x)\,\dd{y}{x} + y = 1 \quad\text{with}\quad y(0) = 1

  5. dydx+ytan(x)=cos(x)withy(0)=1for0x<π2\displaystyle \def\dd#1#2{{\frac{{\rm d}#1}{{\rm d}#2}}} \dd{y}{x} + y\tan(x) = \cos(x) \quad\text{with}\quad y(0)=1 \quad\text{for}\quad 0 \le x < \frac{\pi}{2}

Extension problems 3

Consider the second order differential equation

d2ydx2+y=0\def\ddd#1#2{{{{\rm d}^2#1}\over{\d{#2}^2}}} \def\d#1{{\rm d}#1} \ddd{y}{x} + y = 0

Show that y=Aez1x+Bez2x\displaystyle y = Ae^{z_1 x} + Be^{z_2 x} is a solution to this equation for some complex numbers z1z_1, z2z_2 and real constants AA, BB.

  1. Recalling that any complex number zz can be written as z=reiθ=r(cosθ+isinθ)\displaystyle 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?